<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/cpufreq.h, branch v4.9.140</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.9.140</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.9.140'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2016-10-20T14:35:50Z</updated>
<entry>
<title>cpufreq: fix overflow in cpufreq_table_find_index_dl()</title>
<updated>2016-10-20T14:35:50Z</updated>
<author>
<name>Sergey Senozhatsky</name>
<email>sergey.senozhatsky@gmail.com</email>
</author>
<published>2016-10-17T15:41:12Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c6fe46a79ecd79606bb96fada4515f6b23f87b62'/>
<id>urn:sha1:c6fe46a79ecd79606bb96fada4515f6b23f87b62</id>
<content type='text'>
'best' is always less or equals to 'pos', so `best - pos' returns
a negative value which is then getting casted to `unsigned int'
and passed to __cpufreq_driver_target()-&gt;acpi_cpufreq_target()
for policy-&gt;freq_table selection. This results in

 BUG: unable to handle kernel paging request at ffff881019b469f8
 IP: [&lt;ffffffffa00356c1&gt;] acpi_cpufreq_target+0x4f/0x190 [acpi_cpufreq]
 PGD 267f067
 PUD 0

 Oops: 0000 [#1] PREEMPT SMP
 CPU: 6 PID: 70 Comm: kworker/6:1 Not tainted 4.9.0-rc1-next-20161017-dbg-dirty
 Workqueue: events dbs_work_handler
 task: ffff88041b808000 task.stack: ffff88041b810000
 RIP: 0010:[&lt;ffffffffa00356c1&gt;]  [&lt;ffffffffa00356c1&gt;] acpi_cpufreq_target+0x4f/0x190 [acpi_cpufreq]
 RSP: 0018:ffff88041b813c60  EFLAGS: 00010282
 RAX: ffff880419b46a00 RBX: ffff88041b848400 RCX: ffff880419b20f80
 RDX: 00000000001dff38 RSI: 00000000ffffffff RDI: ffff88041b848400
 RBP: ffff88041b813cb0 R08: 0000000000000006 R09: 0000000000000040
 R10: ffffffff8207f9e0 R11: ffffffff8173595b R12: 0000000000000000
 R13: ffff88041f1dff38 R14: 0000000000262900 R15: 0000000bfffffff4
 FS:  0000000000000000(0000) GS:ffff88041f000000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: ffff881019b469f8 CR3: 000000041a2d3000 CR4: 00000000001406e0
 Stack:
  ffff88041b813cb0 ffffffff813347f9 ffff88041b813ca0 ffffffff81334663
  ffff88041f1d4bc0 ffff88041b848400 0000000000000000 0000000000000000
  0000000000262900 0000000000000000 ffff88041b813d00 ffffffff813355dc
 Call Trace:
  [&lt;ffffffff813347f9&gt;] ? cpufreq_freq_transition_begin+0xf1/0xfc
  [&lt;ffffffff81334663&gt;] ? get_cpu_idle_time+0x97/0xa6
  [&lt;ffffffff813355dc&gt;] __cpufreq_driver_target+0x3b6/0x44e
  [&lt;ffffffff81336ca3&gt;] cs_dbs_timer+0x11a/0x135
  [&lt;ffffffff81336fda&gt;] dbs_work_handler+0x39/0x62
  [&lt;ffffffff81057823&gt;] process_one_work+0x280/0x4a5
  [&lt;ffffffff81058719&gt;] worker_thread+0x24f/0x397
  [&lt;ffffffff810584ca&gt;] ? rescuer_thread+0x30b/0x30b
  [&lt;ffffffff81418380&gt;] ? nl80211_get_key+0x29/0x36a
  [&lt;ffffffff8105d2b7&gt;] kthread+0xfc/0x104
  [&lt;ffffffff8107ceea&gt;] ? put_lock_stats.isra.9+0xe/0x20
  [&lt;ffffffff8105d1bb&gt;] ? kthread_create_on_node+0x3f/0x3f
  [&lt;ffffffff814b2092&gt;] ret_from_fork+0x22/0x30
 Code: 56 4d 6b ff 0c 41 55 41 54 53 48 83 ec 28 48 8b 15 ad 1e 00 00 44 8b 41
 08 48 8b 87 c8 00 00 00 49 89 d5 4e 03 2c c5 80 b2 78 81 &lt;46&gt; 8b 74 38 04 45
 3b 75 00 75 11 31 c0 83 39 00 0f 84 1c 01 00
 RIP  [&lt;ffffffffa00356c1&gt;] acpi_cpufreq_target+0x4f/0x190 [acpi_cpufreq]
  RSP &lt;ffff88041b813c60&gt;
 CR2: ffff881019b469f8
 ---[ end trace 16d9fc7a17897d37 ]---

[ rjw: In some cases this bug may also cause incorrect frequencies to
  be selected by cpufreq governors. ]

Fixes: 899bb6642f2a (cpufreq: skip invalid entries when searching the frequency)
Link: http://marc.info/?l=linux-kernel&amp;m=147672030714331&amp;w=2
Reported-and-tested-by: Sedat Dilek &lt;sedat.dilek@gmail.com&gt;
Reported-and-tested-by: Jörg Otte &lt;jrg.otte@gmail.com&gt;
Signed-off-by: Sergey Senozhatsky &lt;sergey.senozhatsky@gmail.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Cc: 4.8+ &lt;stable@vger.kernel.org&gt; # 4.8+
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: skip invalid entries when searching the frequency</title>
<updated>2016-10-12T19:01:18Z</updated>
<author>
<name>Aaro Koskinen</name>
<email>aaro.koskinen@iki.fi</email>
</author>
<published>2016-10-12T03:15:05Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=899bb6642f2a2f2cd3f77abd6c5a14550e3b37e6'/>
<id>urn:sha1:899bb6642f2a2f2cd3f77abd6c5a14550e3b37e6</id>
<content type='text'>
Skip invalid entries when searching the frequency. This fixes cpufreq
at least on loongson2 MIPS board.

Fixes: da0c6dc00c69 (cpufreq: Handle sorted frequency tables more efficiently)
Signed-off-by: Aaro Koskinen &lt;aaro.koskinen@iki.fi&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Cc: 4.8+ &lt;stable@vger.kernel.org&gt; # 4.8+
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: add cpufreq_driver_resolve_freq()</title>
<updated>2016-07-21T12:46:08Z</updated>
<author>
<name>Steve Muckle</name>
<email>steve.muckle@linaro.org</email>
</author>
<published>2016-07-13T20:25:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e3c06236087051d5c62d60d0668588c370fda887'/>
<id>urn:sha1:e3c06236087051d5c62d60d0668588c370fda887</id>
<content type='text'>
Cpufreq governors may need to know what a particular target frequency
maps to in the driver without necessarily wanting to set the frequency.
Support this operation via a new cpufreq API,
cpufreq_driver_resolve_freq(). This API returns the lowest driver
frequency equal or greater than the target frequency
(CPUFREQ_RELATION_L), subject to any policy (min/max) or driver
limitations. The mapping is also cached in the policy so that a
subsequent fast_switch operation can avoid repeating the same lookup.

The API will call a new cpufreq driver callback, resolve_freq(), if it
has been registered by the driver. Otherwise the frequency is resolved
via cpufreq_frequency_table_target(). Rather than require -&gt;target()
style drivers to provide a resolve_freq() callback it is left to the
caller to ensure that the driver implements this callback if necessary
to use cpufreq_driver_resolve_freq().

Suggested-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Signed-off-by: Steve Muckle &lt;smuckle@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: Handle sorted frequency tables more efficiently</title>
<updated>2016-07-06T22:13:20Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2016-06-27T10:34:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=da0c6dc00c69d0adaae99c3b3d2ea0c869a3fb35'/>
<id>urn:sha1:da0c6dc00c69d0adaae99c3b3d2ea0c869a3fb35</id>
<content type='text'>
cpufreq drivers aren't required to provide a sorted frequency table
today, and even the ones which provide a sorted table aren't handled
efficiently by cpufreq core.

This patch adds infrastructure to verify if the freq-table provided by
the drivers is sorted or not, and use efficient helpers if they are
sorted.

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: Return index from cpufreq_frequency_table_target()</title>
<updated>2016-06-08T22:58:06Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2016-06-03T05:28:51Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d218ed773915a2b762d132be6bb765637338c360'/>
<id>urn:sha1:d218ed773915a2b762d132be6bb765637338c360</id>
<content type='text'>
This routine can't fail unless the frequency table is invalid and
doesn't contain any valid entries.

Make it return the index and WARN() in case it is used for an invalid
table.

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: Drop freq-table param to cpufreq_frequency_table_target()</title>
<updated>2016-06-08T22:58:06Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2016-06-03T05:28:49Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7ab4aabbaa98fbf9f8967fd93162d675439337e1'/>
<id>urn:sha1:7ab4aabbaa98fbf9f8967fd93162d675439337e1</id>
<content type='text'>
The policy already has this pointer set, use it instead.

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: Remove cpufreq_frequency_get_table()</title>
<updated>2016-06-08T22:58:05Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2016-06-03T05:28:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f8bfc116cacbdf7e0e655d8a798a242087ed70a5'/>
<id>urn:sha1:f8bfc116cacbdf7e0e655d8a798a242087ed70a5</id>
<content type='text'>
Most of the callers of cpufreq_frequency_get_table() already have the
pointer to a valid 'policy' structure and they don't really need to go
through the per-cpu variable first and then a check to validate the
frequency, in order to find the freq-table for the policy.

Directly use the policy-&gt;freq_table field instead for them.

Only one user of that API is left after above changes, cpu_cooling.c and
it accesses the freq_table in a racy way as the policy can get freed in
between.

Fix it by using cpufreq_cpu_get() properly.

Since there are no more users of cpufreq_frequency_get_table() left, get
rid of it.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Acked-by: Javi Merino &lt;javi.merino@arm.com&gt; (cpu_cooling.c)
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: stats: Make the stats code non-modular</title>
<updated>2016-06-02T21:24:41Z</updated>
<author>
<name>Rafael J. Wysocki</name>
<email>rafael.j.wysocki@intel.com</email>
</author>
<published>2016-05-31T20:14:44Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1aefc75b2449eb68a6fc3ca932e2a4ee353b748d'/>
<id>urn:sha1:1aefc75b2449eb68a6fc3ca932e2a4ee353b748d</id>
<content type='text'>
The modularity of cpufreq_stats is quite problematic.

First off, the usage of policy notifiers for the initialization
and cleanup in the cpufreq_stats module is inherently racy with
respect to CPU offline/online and the initialization and cleanup
of the cpufreq driver.

Second, fast frequency switching (used by the schedutil governor)
cannot be enabled if any transition notifiers are registered, so
if the cpufreq_stats module (that registers a transition notifier
for updating transition statistics) is loaded, the schedutil governor
cannot use fast frequency switching.

On the other hand, allowing cpufreq_stats to be built as a module
doesn't really add much value.  Arguably, there's not much reason
for that code to be modular at all.

For the above reasons, make the cpufreq stats code non-modular,
modify the core to invoke functions provided by that code directly
and drop the notifiers from it.

Make the stats sysfs attributes appear empty if fast frequency
switching is enabled as the statistics will not be updated in that
case anyway (and returning -EBUSY from those attributes breaks
powertop).

While at it, clean up Kconfig help for the CPU_FREQ_STAT and
CPU_FREQ_STAT_DETAILS options.

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: Drop the 'initialized' field from struct cpufreq_governor</title>
<updated>2016-06-02T21:24:39Z</updated>
<author>
<name>Rafael J. Wysocki</name>
<email>rafael.j.wysocki@intel.com</email>
</author>
<published>2016-05-18T20:59:49Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9a15fb2c797a15524e63eacb10bd6cd68a99e830'/>
<id>urn:sha1:9a15fb2c797a15524e63eacb10bd6cd68a99e830</id>
<content type='text'>
The 'initialized' field in struct cpufreq_governor is only used by
the conservative governor (as a usage counter) and the way that
happens is far from straightforward and arguably incorrect.

Namely, the value of 'initialized' is checked by
cpufreq_dbs_governor_init() and cpufreq_dbs_governor_exit() and
the results of those checks are passed (as the second argument) to
the -&gt;init() and -&gt;exit() callbacks in struct dbs_governor.  Those
callbacks are only implemented by the ondemand and conservative
governors and ondemand doesn't use their second argument at all.
In turn, the conservative governor uses it to decide whether or not
to either register or unregister a transition notifier.

That whole mechanism is not only unnecessarily convoluted, but also
racy, because the 'initialized' field of struct cpufreq_governor is
updated in cpufreq_init_governor() and cpufreq_exit_governor() under
policy-&gt;rwsem which doesn't help if one of these functions is run
twice in parallel for different policies (which isn't impossible in
principle), for example.

Instead of it, add a proper usage counter to the conservative
governor and update it from cs_init() and cs_exit() which is
guaranteed to be non-racy, as those functions are only called
under gov_dbs_data_mutex which is global.

With that in place, drop the 'initialized' field from struct
cpufreq_governor as it is not used any more.

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: governor: Create cpufreq_policy_apply_limits()</title>
<updated>2016-06-02T21:24:39Z</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2016-05-18T12:25:31Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bf2be2de8493dd5f86d6e0f0d4eecb5810ad035b'/>
<id>urn:sha1:bf2be2de8493dd5f86d6e0f0d4eecb5810ad035b</id>
<content type='text'>
Create a new helper to avoid code duplication across governors.

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>
