<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/cpufreq/cpufreq_stats.c, branch v6.3</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.3</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.3'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2022-12-06T11:20:07+00:00</updated>
<entry>
<title>cpufreq: stats: Convert to use sysfs_emit_at() API</title>
<updated>2022-12-06T11:20:07+00:00</updated>
<author>
<name>ye xingchen</name>
<email>ye.xingchen@zte.com.cn</email>
</author>
<published>2022-12-06T08:15:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7ed40bcf8a618436d43b17d565ca35af61bc8e54'/>
<id>urn:sha1:7ed40bcf8a618436d43b17d565ca35af61bc8e54</id>
<content type='text'>
Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen &lt;ye.xingchen@zte.com.cn&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Clean up local variable in cpufreq_stats_create_table()</title>
<updated>2021-06-07T11:47:57+00:00</updated>
<author>
<name>Shaokun Zhang</name>
<email>zhangshaokun@hisilicon.com</email>
</author>
<published>2021-05-31T07:16:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5de1262500708bcf6eef753f5eb9d8adb3d32d33'/>
<id>urn:sha1:5de1262500708bcf6eef753f5eb9d8adb3d32d33</id>
<content type='text'>
Local variable 'count' will be initialized and 'ret' is also not
required, so remove the redundant initialization and get rid of
'ret'.

Signed-off-by: Shaokun Zhang &lt;zhangshaokun@hisilicon.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Use local_clock() instead of jiffies</title>
<updated>2020-12-11T18:53:58+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-11-17T11:32:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7854c7520b86f0c14f7fcfea6fd1785617844341'/>
<id>urn:sha1:7854c7520b86f0c14f7fcfea6fd1785617844341</id>
<content type='text'>
local_clock() has better precision and accuracy as compared to jiffies,
lets use it for time management in cpufreq stats.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Fix string format specifier mismatch</title>
<updated>2020-10-12T10:32:10+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-12T04:50:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b7af6080a3d2d35a410db3eeb162e1ab49c4d27f'/>
<id>urn:sha1:b7af6080a3d2d35a410db3eeb162e1ab49c4d27f</id>
<content type='text'>
Fix following warning:

drivers/cpufreq/cpufreq_stats.c:63:10: warning: %d in format string (no.
1) requires 'int' but the argument type is 'unsigned int'

Fixes: 40c3bd4cfa6f ("cpufreq: stats: Defer stats update to cpufreq_stats_record_transition()")
Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Add memory barrier to store_reset()</title>
<updated>2020-10-07T15:13:15+00:00</updated>
<author>
<name>Rafael J. Wysocki</name>
<email>rafael.j.wysocki@intel.com</email>
</author>
<published>2020-10-06T19:43:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=efad4240da949fc3249015065b95d708b72ae670'/>
<id>urn:sha1:efad4240da949fc3249015065b95d708b72ae670</id>
<content type='text'>
There is nothing to prevent the CPU or the compiler from reordering
the writes to stats-&gt;reset_time and stats-&gt;reset_pending in
store_reset(), in which case the readers of stats-&gt;reset_time may see
a stale value.  Moreover, on 32-bit arches the write to reset_time
cannot be completed in one go, so the readers of it may see a
partially updated value in that case.

To prevent that from happening, add a write memory barrier between
the writes to stats-&gt;reset_time and stats-&gt;reset_pending in
store_reset() and corresponding read memory barrier in the
readers of stats-&gt;reset_time.

Fixes: 40c3bd4cfa6f ("cpufreq: stats: Defer stats update to cpufreq_stats_record_transition()")
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Enable stats for fast-switch as well</title>
<updated>2020-10-05T13:13:43+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-05T07:56:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=96f60cddf7a1c5374296dd14355b519ee3245b3e'/>
<id>urn:sha1:96f60cddf7a1c5374296dd14355b519ee3245b3e</id>
<content type='text'>
Now that all the blockers are gone for enabling stats in fast-switching
case, enable it.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Mark few conditionals with unlikely()</title>
<updated>2020-10-05T13:13:43+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-05T07:56:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4958b46efb6df20fa3abb3a4d007515485f6af16'/>
<id>urn:sha1:4958b46efb6df20fa3abb3a4d007515485f6af16</id>
<content type='text'>
Since this will be part of the scheduler's hotpath in some cases, use
unlikely() for few of the obvious conditionals.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Remove locking</title>
<updated>2020-10-05T13:13:43+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-05T07:56:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=381abb942a392377f614b62c87692f4f2e8aa59b'/>
<id>urn:sha1:381abb942a392377f614b62c87692f4f2e8aa59b</id>
<content type='text'>
The locking isn't required anymore as stats can get updated only from
one place at a time. Remove it.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Defer stats update to cpufreq_stats_record_transition()</title>
<updated>2020-10-05T13:13:42+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-05T07:56:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=40c3bd4cfa6fe5756344709b98611a1ddd15bf9d'/>
<id>urn:sha1:40c3bd4cfa6fe5756344709b98611a1ddd15bf9d</id>
<content type='text'>
In order to prepare for lock-less stats update, add support to defer any
updates to it until cpufreq_stats_record_transition() is called.

The stats were updated from two places earlier:

- show_time_in_state(): This can be easily deferred, all we need is to
  calculate the delta duration again in this routine to show the current
  state's time-in-state.

- store_reset(): This is a bit tricky as we need to clear the stats
  here and avoid races with simultaneous call to
  cpufreq_stats_record_transition().

Fix that by deferring the reset of the stats (within the code) to the
next call to cpufreq_stats_record_transition(), but since we need to
keep showing the right stats until that time, we capture the reset
time and account for the time since last time reset was called until
the time cpufreq_stats_record_transition() update the stats.

User space will continue seeing the stats correctly, everything will
be 0 after the stats are reset, apart from the time-in-state of the
current state, until the time a frequency switch happens.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[ rjw: Minor changelog edits ]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: Use scnprintf() for avoiding potential buffer overflow</title>
<updated>2020-03-14T11:07:38+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2020-03-11T07:13:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3c0897c180c6605ebbdfa1b4badc71e181fc4cdc'/>
<id>urn:sha1:3c0897c180c6605ebbdfa1b4badc71e181fc4cdc</id>
<content type='text'>
Since snprintf() returns the would-be-output size instead of the
actual output size, the succeeding calls may go beyond the given
buffer limit.  Fix it by replacing with scnprintf().

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
</feed>
