lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1019298652.01575597781442.JavaMail.epsvc@epcpadp2>
Date:   Fri, 6 Dec 2019 11:01:46 +0900
From:   Chanwoo Choi <cw00.choi@...sung.com>
To:     Kamil Konieczny <k.konieczny@...sung.com>
Cc:     Andrew Donnellan <ajd@...ux.ibm.com>,
        Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Krzysztof Kozlowski <krzk@...nel.org>,
        Kyungmin Park <kyungmin.park@...sung.com>,
        linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        MyungJoo Ham <myungjoo.ham@...sung.com>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        "cpgs (cpgs@...sung.com)" <cpgs@...sung.com>
Subject: Re: [PATCH v3 2/3] devfreq: add clearing transitions stats

On 12/5/19 11:55 PM, Kamil Konieczny wrote:
> 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@...sung.com>
> ---
> Changes in v3:
> - add checks for zero in input and clear stats only when zero is written
>   to trans_stats
> - change documentation of trans_stat in sysfs
> 
> Changes in v2:
> - instead of creating new sysfs file, add new functionality to trans_stat
>   and clear stats when anything is writen to it
> ---
>  Documentation/ABI/testing/sysfs-class-devfreq | 11 +++++---
>  drivers/devfreq/devfreq.c                     | 27 ++++++++++++++++++-
>  2 files changed, 33 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@...sung.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..218eb64d7f28 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -1478,7 +1478,32 @@ 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);
> +	unsigned int cnt = df->profile->max_state;
> +	int err, value;
> +
> +	if (cnt == 0)
> +		return count;
> +
> +	err = kstrtoint(buf, 10, &value);
> +	if (err || value != 0)
> +		return count;

Better returning -EINVAL to inform the error of user.
I changed it by myself.

> +
> +	mutex_lock(&df->lock);
> +	memset(df->time_in_state, 0, cnt * sizeof(u64));

Changed the size calculation way as following by myself:

    memset(df->time_in_state, 0, (df->profile->max_state *                  
					sizeof(*devfreq->time_in_state)));  

> +	memset(df->trans_table, 0, cnt * cnt * sizeof(int));

Changed the size calculation way with array3_size() as following by myself:
	memset(df->trans_table, 0, array3_size(sizeof(unsigned int),            
					df->profile->max_state,                 
					df->profile->max_state));     


> +	df->last_stat_updated = get_jiffies_64();
> +	df->total_trans = 0;

Changed the init sequence as following by myself.
	df->total_trans = 0;
	df->last_stat_updated = get_jiffies_64();

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ