<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/cpufreq/cpufreq_stats.c, branch 0x221E-v0.0.1-v6.19</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=0x221E-v0.0.1-v6.19</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=0x221E-v0.0.1-v6.19'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2023-10-24T20:02:06Z</updated>
<entry>
<title>cpufreq: stats: Fix buffer overflow detection in trans_stats()</title>
<updated>2023-10-24T20:02:06Z</updated>
<author>
<name>Christian Marangi</name>
<email>ansuelsmth@gmail.com</email>
</author>
<published>2023-10-24T18:30:14Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ea167a7fc2426f7685c3735e104921c1a20a6d3f'/>
<id>urn:sha1:ea167a7fc2426f7685c3735e104921c1a20a6d3f</id>
<content type='text'>
Commit 3c0897c180c6 ("cpufreq: Use scnprintf() for avoiding potential
buffer overflow") switched from snprintf to the more secure scnprintf
but never updated the exit condition for PAGE_SIZE.

As the commit say and as scnprintf document, what scnprintf returns what
is actually written not counting the '\0' end char. This results in the
case of len exceeding the size, len set to PAGE_SIZE - 1, as it can be
written at max PAGE_SIZE - 1 (as '\0' is not counted)

Because of len is never set to PAGE_SIZE, the function never break early,
never prints the warning and never return -EFBIG.

Fix this by changing the condition to PAGE_SIZE - 1 to correctly trigger
the error.

Cc: 5.10+ &lt;stable@vger.kernel.org&gt; # 5.10+
Fixes: 3c0897c180c6 ("cpufreq: Use scnprintf() for avoiding potential buffer overflow")
Signed-off-by: Christian Marangi &lt;ansuelsmth@gmail.com&gt;
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Improve the performance of cpufreq_stats_create_table()</title>
<updated>2023-08-21T18:57:30Z</updated>
<author>
<name>Liao Chang</name>
<email>liaochang1@huawei.com</email>
</author>
<published>2023-08-18T09:50:00Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ed9571647eff3dd7a53068f83338530959c7ace4'/>
<id>urn:sha1:ed9571647eff3dd7a53068f83338530959c7ace4</id>
<content type='text'>
In the worst case, the freq_table of policy data is not sorted and
contains duplicate frequencies, this means that it needs to iterate
through the entire freq_table of policy to ensure each frequency is
unique in the freq_table of stats data, this has a time complexity of
O(N^2), where N is the number of frequencies in the freq_table of
policy.

However, if the policy.freq_table is already sorted and contains no
duplicate frequencies, it can reduce the time complexity of creating
stats.freq_table to O(N), the 'freq_table_sorted' field of policy data
can be used to indicate whether the policy.freq_table is sorted.

Signed-off-by: Liao Chang &lt;liaochang1@huawei.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Reviewed-by: Dhruva Gole &lt;d-gole@ti.com&gt;
[ rjw: Fix typo in changelog, remove redundant parens ]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Convert to use sysfs_emit_at() API</title>
<updated>2022-12-06T11:20:07Z</updated>
<author>
<name>ye xingchen</name>
<email>ye.xingchen@zte.com.cn</email>
</author>
<published>2022-12-06T08:15:22Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/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:57Z</updated>
<author>
<name>Shaokun Zhang</name>
<email>zhangshaokun@hisilicon.com</email>
</author>
<published>2021-05-31T07:16:07Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/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:58Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-11-17T11:32:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/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:10Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-12T04:50:07Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/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:15Z</updated>
<author>
<name>Rafael J. Wysocki</name>
<email>rafael.j.wysocki@intel.com</email>
</author>
<published>2020-10-06T19:43:43Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/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:43Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-05T07:56:04Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/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:43Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-05T07:56:03Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/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:43Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2020-10-05T07:56:02Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/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>
</feed>
