All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Cc: rafael.j.wysocki@intel.com, myungjoo.ham@samsung.com,
	b.zolnierkie@samsung.com, gregkh@linuxfoundation.org,
	krzk@kernel.org, kyungmin.park@samsung.com,
	m.szyprowski@samsung.com, mchehab@kernel.org, cpgs@samsung.com,
	Kamil Konieczny <k.konieczny@samsung.com>
Subject: Re: [PATCH v4] PM / devfreq: add clearing transitions stats
Date: Fri, 6 Dec 2019 11:19:38 +0900	[thread overview]
Message-ID: <fba062e6-6b49-afcb-70db-c0967989f60c@samsung.com> (raw)
In-Reply-To: <20191206021813.7193-1-cw00.choi@samsung.com>

On 12/6/19 11:18 AM, Chanwoo Choi wrote:
> From: Kamil Konieczny <k.konieczny@samsung.com>
> 
> Add clearing transition table and time in states devfreq statistics
> by writing 0 (zero) to trans_stat file in devfreq sysfs. An example use
> is like following:
> 
> echo 0 > /sys/class/devfreq/devfreqX/trans_stat
> 
> Signed-off-by: Kamil Konieczny <k.konieczny@samsung.com>
> [cw00.choi: Edit return value if entering the wrong value for reset
>  and use arrary3_size() to get the size of 3-dimensional array]
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
>  Documentation/ABI/testing/sysfs-class-devfreq | 11 ++++---
>  drivers/devfreq/devfreq.c                     | 29 ++++++++++++++++++-
>  2 files changed, 35 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq
> index 75897e2fde43..9758eb85ade3 100644
> --- a/Documentation/ABI/testing/sysfs-class-devfreq
> +++ b/Documentation/ABI/testing/sysfs-class-devfreq
> @@ -55,12 +55,15 @@ What:		/sys/class/devfreq/.../trans_stat
>  Date:		October 2012
>  Contact:	MyungJoo Ham <myungjoo.ham@samsung.com>
>  Description:
> -		This ABI shows the statistics of devfreq behavior on a
> -		specific device. It shows the time spent in each state and
> -		the number of transitions between states.
> +		This ABI shows or clears the statistics of devfreq behavior
> +		on a specific device. It shows the time spent in each state
> +		and the number of transitions between states.
>  		In order to activate this ABI, the devfreq target device
>  		driver should provide the list of available frequencies
> -		with its profile.
> +		with its profile. If need to reset the statistics of devfreq
> +		behavior on a specific device, enter 0(zero) to 'trans_stat'
> +		as following:
> +			echo 0 > /sys/class/devfreq/.../trans_stat
>  
>  What:		/sys/class/devfreq/.../userspace/set_freq
>  Date:		September 2011
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index abecadeb3dc2..df31f430051d 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -1478,7 +1478,34 @@ static ssize_t trans_stat_show(struct device *dev,
>  					devfreq->total_trans);
>  	return len;
>  }
> -static DEVICE_ATTR_RO(trans_stat);
> +
> +static ssize_t trans_stat_store(struct device *dev,
> +				struct device_attribute *attr,
> +				const char *buf, size_t count)
> +{
> +	struct devfreq *df = to_devfreq(dev);
> +	int err, value;
> +
> +	if (df->profile->max_state == 0)
> +		return count;
> +
> +	err = kstrtoint(buf, 10, &value);
> +	if (err || value != 0)
> +		return -EINVAL;
> +
> +	mutex_lock(&df->lock);
> +	memset(df->time_in_state, 0, (df->profile->max_state *
> +					sizeof(*df->time_in_state)));
> +	memset(df->trans_table, 0, array3_size(sizeof(unsigned int),
> +					df->profile->max_state,
> +					df->profile->max_state));
> +	df->total_trans = 0;
> +	df->last_stat_updated = get_jiffies_64();
> +	mutex_unlock(&df->lock);
> +
> +	return count;
> +}
> +static DEVICE_ATTR_RW(trans_stat);
>  
>  static struct attribute *devfreq_attrs[] = {
>  	&dev_attr_name.attr,
> 

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

      reply	other threads:[~2019-12-06  2:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20191205145542eucas1p2b39536c9c186d5656f39d214baa32670@eucas1p2.samsung.com>
2019-12-05 14:55 ` [PATCH v3 0/3] devfreq: improve devfreq statistics counting Kamil Konieczny
     [not found]   ` <CGME20191205145543eucas1p11798d11e91f6a691d5989db7cba81b96@eucas1p1.samsung.com>
2019-12-05 14:55     ` [PATCH v3 1/3] devfreq: change time stats to 64-bit Kamil Konieczny
2019-12-06  1:37       ` Chanwoo Choi
     [not found]   ` <CGME20191205145543eucas1p1a317647203c47be07bbcee7867fb3e1e@eucas1p1.samsung.com>
2019-12-05 14:55     ` [PATCH v3 2/3] devfreq: add clearing transitions stats Kamil Konieczny
2019-12-06  2:01       ` Chanwoo Choi
     [not found]   ` <CGME20191205145544eucas1p17e64389fdee24549a523c624c13194d7@eucas1p1.samsung.com>
2019-12-05 14:55     ` [PATCH v3 3/3] devfreq: move statistics to separate struct Kamil Konieczny
2019-12-06  5:30       ` Chanwoo Choi
     [not found]       ` <CGME20191206052729epcas1p110d11c728db1ebd7487c8c5fe936df21@epcas1p1.samsung.com>
2019-12-06  5:33         ` [PATCH v4] PM / devfreq: Move statistics to separate struct devfreq_stats Chanwoo Choi
2019-12-06  5:36           ` Chanwoo Choi
     [not found]   ` <CGME20191206021208epcas1p1d7b3bb434108f38b0ef83b1c7d7a5d79@epcas1p1.samsung.com>
2019-12-06  2:18     ` [PATCH v4] PM / devfreq: add clearing transitions stats Chanwoo Choi
2019-12-06  2:19       ` Chanwoo Choi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fba062e6-6b49-afcb-70db-c0967989f60c@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=cpgs@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=k.konieczny@samsung.com \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=rafael.j.wysocki@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.