Re: [PATCH 3/7] devfreq: add clearing transitions stats in sysfs

From: Chanwoo Choi
Date: Wed Nov 13 2019 - 04:35:50 EST


Hi,

If user only want to use the transitions stats information
from now, the user just read the sysfs twice and then
can calculate them between the read data. It is enough
to get the existing sysfs information.

And I don't know the any other reason. So, I can't agree this patch.
So, Not ack.

Regards,
Chanwoo Choi


On 11/13/19 6:13 PM, Kamil Konieczny wrote:
> Add new function trans_reset in sysfs for clearing transition
> table and time in states devfreq statistics.>
> Signed-off-by: Kamil Konieczny <k.konieczny@xxxxxxxxxxx>
> ---
> drivers/devfreq/devfreq.c | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index ac04b5baef70..0a88055d1362 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -1445,6 +1445,31 @@ static ssize_t trans_stat_show(struct device *dev,
> }
> static DEVICE_ATTR_RO(trans_stat);
>
> +static void defvreq_stats_clear_table(struct devfreq *devfreq)
> +{
> + unsigned int count = devfreq->profile->max_state;
> +
> + spin_lock(&devfreq->stats_lock);
> + memset(devfreq->time_in_state, 0, count * sizeof(u64));
> + memset(devfreq->trans_table, 0, count * count * sizeof(int));
> + devfreq->last_stat_updated = get_jiffies_64();
> + devfreq->total_trans = 0;
> + spin_unlock(&devfreq->stats_lock);
> +}
> +
> +static ssize_t trans_reset_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf,
> + size_t count)
> +{
> + struct devfreq *devfreq = to_devfreq(dev);
> +
> + defvreq_stats_clear_table(devfreq);
> +
> + return count;
> +}
> +static DEVICE_ATTR_WO(trans_reset);
> +
> static struct attribute *devfreq_attrs[] = {
> &dev_attr_governor.attr,
> &dev_attr_available_governors.attr,
> @@ -1455,6 +1480,7 @@ static struct attribute *devfreq_attrs[] = {
> &dev_attr_min_freq.attr,
> &dev_attr_max_freq.attr,
> &dev_attr_trans_stat.attr,
> + &dev_attr_trans_reset.attr,
> NULL,
> };
> ATTRIBUTE_GROUPS(devfreq);
>


--
Best Regards,
Chanwoo Choi
Samsung Electronics