<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/cpufreq/cpufreq_stats.c, branch linux-4.5.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.5.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.5.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2015-01-23T22:06:45Z</updated>
<entry>
<title>cpufreq: stats: drop unnecessary locking</title>
<updated>2015-01-23T22:06:45Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=490285c65e2398a533035dd9d75cb606a61ea39a'/>
<id>urn:sha1:490285c65e2398a533035dd9d75cb606a61ea39a</id>
<content type='text'>
There is no possibility of any race on updating last_index, trans_table or
total_trans as these are updated only by cpufreq_stat_notifier_trans() which
will be called sequentially.

The only place where locking is still relevant is: cpufreq_stats_update(), which
updates time_in_state and last_time. This can be called by two thread in
parallel, that may result in races.

The two threads being:
- sysfs read of time_in_state
- and frequency transition that calls cpufreq_stat_notifier_trans().

Remove locking from the first case mentioned above.

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: don't update stats on false notifiers</title>
<updated>2015-01-23T22:06:45Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e73476949c6d1e2edd04bbf7b5bae30afa370e33'/>
<id>urn:sha1:e73476949c6d1e2edd04bbf7b5bae30afa370e33</id>
<content type='text'>
We need to call cpufreq_stats_update() to update 'time_in_state' for the last
frequency. This is achieved by calling it from cpufreq_stat_notifier_trans(),
which is called after frequency transition.

But if we detect that the cpu's frequency haven't really changed and its a false
POSTCHANGE notification, we don't really need to update time_in_state.

It wouldn't cause any harm in calling cpufreq_stats_update() but we can avoid
calling it here and call it when the frequency really changes. The result will
be the same but more efficient.

Reviewed-by: Prarit Bhargava &lt;prarit@redhat.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: don't update stats from show_trans_table()</title>
<updated>2015-01-23T22:06:45Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9225913d386537f84f0eb72f022a8b4b9e684846'/>
<id>urn:sha1:9225913d386537f84f0eb72f022a8b4b9e684846</id>
<content type='text'>
cpufreq_stats_update() updates time_in_state and nothing else. It should ideally
be updated only in two cases:
- User requested for the current value of time_in_state.
- We have switched states and so need to update time for the last state.

Currently, we are also doing this while user asks for the transition table of
frequencies. It wouldn't do any harm, but no good as well. Its useless here.

Remove it.

Reviewed-by: Prarit Bhargava &lt;prarit@redhat.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: time_in_state can't be NULL in cpufreq_stats_update()</title>
<updated>2015-01-23T22:06:44Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c960f9b22d63934401949fb20d10ec4e69b535b2'/>
<id>urn:sha1:c960f9b22d63934401949fb20d10ec4e69b535b2</id>
<content type='text'>
'time_in_state' can't be NULL if 'stats' is valid. These are allocated together
and only if time_in_state is allocated successfully, we update policy-&gt;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: create sysfs group once we are ready</title>
<updated>2015-01-23T22:06:44Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a685c6d023c77303ca8700f37bf06eb85ffbf06a'/>
<id>urn:sha1:a685c6d023c77303ca8700f37bf06eb85ffbf06a</id>
<content type='text'>
Userspace is free to read value of any file from cpufreq/stats directory once
they are created. __cpufreq_stats_create_table() is creating the sysfs files
first and then allocating resources for them. Though it would be quite difficult
to trigger the racy situation here, but for the sake of keeping sensible code
lets create sysfs entries only after we are ready to go.

This also does some makeup to the routine to make it look better.

Reviewed-by: Prarit Bhargava &lt;prarit@redhat.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: drop 'cpu' field of struct cpufreq_stats</title>
<updated>2015-01-23T22:06:44Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c92f2125ac5338151bb5c45e371c701e107e3197'/>
<id>urn:sha1:c92f2125ac5338151bb5c45e371c701e107e3197</id>
<content type='text'>
'cpu' field of struct cpufreq_stats isn't used anymore and so can be dropped.
This change makes cpufreq_stats_update_policy_cpu() empty and so that is removed
as well.

Reviewed-by: Prarit Bhargava &lt;prarit@redhat.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: rename 'struct cpufreq_stats' objects as 'stats'</title>
<updated>2015-01-23T22:06:44Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5094160786ede5c08a6901648787a5bf9b0dc2e1'/>
<id>urn:sha1:5094160786ede5c08a6901648787a5bf9b0dc2e1</id>
<content type='text'>
Currently we name objects of 'struct cpufreq_stats' as 'stat' and 'stats'.
Use 'stats' to make it consistent.

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: get rid of per-cpu cpufreq_stats_table</title>
<updated>2015-01-23T22:06:44Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-13T06:04:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a9aaf2915ee265735c28b764551d084e61a694e0'/>
<id>urn:sha1:a9aaf2915ee265735c28b764551d084e61a694e0</id>
<content type='text'>
All CPUs sharing a cpufreq policy share stats too. For this reason,
add a stats pointer to struct cpufreq_policy and drop per-CPU variable
cpufreq_stats_table used for accessing cpufreq stats so as to reduce
code complexity.

Reviewed-by: Prarit Bhargava &lt;prarit@redhat.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: pass 'stat' to cpufreq_stats_update()</title>
<updated>2015-01-23T22:06:44Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2aba0c1bae564a59fc38c407abf7985f9e347cc4'/>
<id>urn:sha1:2aba0c1bae564a59fc38c407abf7985f9e347cc4</id>
<content type='text'>
It is better to pass a struct cpufreq_stats pointer to cpufreq_stats_update()
instead of a CPU number, because that's all it needs.

Even if we pass a cpu number to cpufreq_stats_update(), it reads the per-cpu
variable to get 'stats' out of it. So we are doing these operations
unnecessarily:
- First getting the cpu number to pass to cpufreq_stats_update(), stat-&gt;cpu.
- And then getting stats from the cpu, per_cpu(cpufreq_stats_table, cpu).

Reviewed-by: Prarit Bhargava &lt;prarit@redhat.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: don't check for freq table while freeing stats</title>
<updated>2015-01-23T22:06:43Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-06T15:39:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f93dbbbd108936b18b3230af36d9a36866ce69a7'/>
<id>urn:sha1:f93dbbbd108936b18b3230af36d9a36866ce69a7</id>
<content type='text'>
While we allocate stats, we do need to check if freq-table is present
or not as we need to use it then. But while freeing stats, all we need
to know is if stats holds a valid pointer value. There is no use of
testing if cpufreq table is present or not.

Don't check it.

Reviewed-by: Prarit Bhargava &lt;prarit@redhat.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>
</feed>
