<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/cpufreq/cpufreq_conservative.c, branch linux-5.0.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.0.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.0.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-10-16T10:34:45Z</updated>
<entry>
<title>cpufreq: conservative: Take limits changes into account properly</title>
<updated>2018-10-16T10:34:45Z</updated>
<author>
<name>Rafael J. Wysocki</name>
</author>
<published>2018-10-15T21:21:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=da5e79bc70b84971d2b3a55fb252e34e51d81d48'/>
<id>urn:sha1:da5e79bc70b84971d2b3a55fb252e34e51d81d48</id>
<content type='text'>
If the policy limits change between invocations of cs_dbs_update(),
the requested frequency value stored in dbs_info may not be updated
and the function may use a stale value of it next time.  Moreover, if
idle periods are takem into account by cs_dbs_update(), the requested
frequency value stored in dbs_info may be below the min policy limit,
which is incorrect.

To fix these problems, always update the requested frequency value
in dbs_info along with the local copy of it when the previous
requested frequency is beyond the policy limits and avoid decreasing
the requested frequency below the min policy limit when taking
idle periods into account.

Fixes: abb6627910a1 (cpufreq: conservative: Fix next frequency selection)
Fixes: 00bfe05889e9 (cpufreq: conservative: Decrease frequency faster for deferred updates)
Reported-by: Waldemar Rymarkiewicz &lt;waldemarx.rymarkiewicz@intel.com&gt;
Cc: All applicable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Acked-by: Waldemar Rymarkiewicz &lt;waldemarx.rymarkiewicz@intel.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
</content>
</entry>
<entry>
<title>cpufreq: governor: Drop min_sampling_rate</title>
<updated>2017-07-22T00:25:20Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2017-07-19T10:12:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2d045036322c29b69c22f06530f1130338d06373'/>
<id>urn:sha1:2d045036322c29b69c22f06530f1130338d06373</id>
<content type='text'>
The cpufreq core and governors aren't supposed to set a limit on how
fast we want to try changing the frequency. This is currently done for
the legacy governors with help of min_sampling_rate.

At worst, we may end up setting the sampling rate to a value lower than
the rate at which frequency can be changed and then one of the CPUs in
the policy will be only changing frequency for ever.

But that is something for the user to decide and there is no need to
have special handling for such cases in the core. Leave it for the user
to figure out.

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: conservative: Allow down_threshold to take values from 1 to 10</title>
<updated>2017-06-12T12:28:07Z</updated>
<author>
<name>Tomasz Wilczyński</name>
</author>
<published>2017-06-11T08:28:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b8e11f7d2791bd9320be1c6e772a60b2aa093e45'/>
<id>urn:sha1:b8e11f7d2791bd9320be1c6e772a60b2aa093e45</id>
<content type='text'>
Commit 27ed3cd2ebf4 (cpufreq: conservative: Fix the logic in frequency
decrease checking) removed the 10 point substraction when comparing the
load against down_threshold but did not remove the related limit for the
down_threshold value.  As a result, down_threshold lower than 11 is not
allowed even though values from 1 to 10 do work correctly too. The
comment ("cannot be lower than 11 otherwise freq will not fall") also
does not apply after removing the substraction.

For this reason, allow down_threshold to take any value from 1 to 99
and fix the related comment.

Fixes: 27ed3cd2ebf4 (cpufreq: conservative: Fix the logic in frequency decrease checking)
Signed-off-by: Tomasz Wilczyński &lt;twilczynski@naver.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Cc: 3.10+ &lt;stable@vger.kernel.org&gt; # 3.10+
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: conservative: Fix comment explaining frequency updates</title>
<updated>2016-11-16T22:15:56Z</updated>
<author>
<name>Stratos Karafotis</name>
</author>
<published>2016-11-16T19:27:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=42d951c851f1d08bb12430a7e2e9f4657f7c395c'/>
<id>urn:sha1:42d951c851f1d08bb12430a7e2e9f4657f7c395c</id>
<content type='text'>
The original comment about the frequency increase to maximum is wrong.

Both increase and decrease happen at steps.

Signed-off-by: Stratos Karafotis &lt;stratosk@semaphore.gr&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: conservative: Decrease frequency faster for deferred updates</title>
<updated>2016-11-16T22:15:56Z</updated>
<author>
<name>Stratos Karafotis</name>
</author>
<published>2016-11-16T17:26:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=00bfe05889e91b5112893b001e4a47b0a0f8bdd7'/>
<id>urn:sha1:00bfe05889e91b5112893b001e4a47b0a0f8bdd7</id>
<content type='text'>
Conservative governor changes the CPU frequency in steps.
That means that if a CPU runs at max frequency, it will need several
sampling periods to return to min frequency when the workload
is finished.

If the update function that calculates the load and target frequency
is deferred, the governor might need even more time to decrease the
frequency.

This may have impact to power consumption and after all conservative
should decrease the frequency if there is no workload at every sampling
rate.

To resolve the above issue calculate the number of sampling periods
that the update is deferred. Considering that for each sampling period
conservative should drop the frequency by a freq_step because the
CPU was idle apply the proper subtraction to requested frequency.

Below, the kernel trace with and without this patch. First an
intensive workload is applied on a specific CPU. Then the workload
is removed and the CPU goes to idle.

WITHOUT

     &lt;idle&gt;-0     [007] dN..   620.329153: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   620.350857: cpu_frequency: state=1700000 cpu_id=7
kworker/7:2-556   [007] ....   620.370856: cpu_frequency: state=1900000 cpu_id=7
kworker/7:2-556   [007] ....   620.390854: cpu_frequency: state=2100000 cpu_id=7
kworker/7:2-556   [007] ....   620.411853: cpu_frequency: state=2200000 cpu_id=7
kworker/7:2-556   [007] ....   620.432854: cpu_frequency: state=2400000 cpu_id=7
kworker/7:2-556   [007] ....   620.453854: cpu_frequency: state=2600000 cpu_id=7
kworker/7:2-556   [007] ....   620.494856: cpu_frequency: state=2900000 cpu_id=7
kworker/7:2-556   [007] ....   620.515856: cpu_frequency: state=3100000 cpu_id=7
kworker/7:2-556   [007] ....   620.536858: cpu_frequency: state=3300000 cpu_id=7
kworker/7:2-556   [007] ....   620.557857: cpu_frequency: state=3401000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   669.591363: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   669.591939: cpu_idle: state=4294967295 cpu_id=7
     &lt;idle&gt;-0     [007] d...   669.591980: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] dN..   669.591989: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...   670.201224: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   670.221975: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   670.222016: cpu_frequency: state=3300000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   670.222026: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   670.234964: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...   670.801251: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.236046: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   671.236073: cpu_frequency: state=3100000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.236112: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.393437: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...   671.401277: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.404083: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   671.404111: cpu_frequency: state=2900000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.404125: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.404974: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...   671.501180: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.995414: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   671.995459: cpu_frequency: state=2800000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.995469: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   671.996287: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...   672.001305: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.078374: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   672.078410: cpu_frequency: state=2600000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.078419: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.158020: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   672.158040: cpu_frequency: state=2400000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.158044: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.160038: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...   672.234557: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.237121: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   672.237174: cpu_frequency: state=2100000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.237186: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.237778: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...   672.267902: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.269860: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   672.269906: cpu_frequency: state=1900000 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.269914: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.271902: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...   672.751342: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...   672.823056: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-556   [007] ....   672.823095: cpu_frequency: state=1600000 cpu_id=7

WITH

     &lt;idle&gt;-0     [007] dN..  4380.928009: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-399   [007] ....  4380.949767: cpu_frequency: state=2000000 cpu_id=7
kworker/7:2-399   [007] ....  4380.969765: cpu_frequency: state=2200000 cpu_id=7
kworker/7:2-399   [007] ....  4381.009766: cpu_frequency: state=2500000 cpu_id=7
kworker/7:2-399   [007] ....  4381.029767: cpu_frequency: state=2600000 cpu_id=7
kworker/7:2-399   [007] ....  4381.049769: cpu_frequency: state=2800000 cpu_id=7
kworker/7:2-399   [007] ....  4381.069769: cpu_frequency: state=3000000 cpu_id=7
kworker/7:2-399   [007] ....  4381.089771: cpu_frequency: state=3100000 cpu_id=7
kworker/7:2-399   [007] ....  4381.109772: cpu_frequency: state=3400000 cpu_id=7
kworker/7:2-399   [007] ....  4381.129773: cpu_frequency: state=3401000 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.226159: cpu_idle: state=1 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.226176: cpu_idle: state=4294967295 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.226181: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.227177: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...  4428.551640: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.649239: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-399   [007] ....  4428.649268: cpu_frequency: state=2800000 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.649278: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.689856: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...  4428.799542: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.801683: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-399   [007] ....  4428.801748: cpu_frequency: state=1700000 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.801761: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4428.806545: cpu_idle: state=4294967295 cpu_id=7
...
     &lt;idle&gt;-0     [007] d...  4429.051880: cpu_idle: state=4 cpu_id=7
     &lt;idle&gt;-0     [007] d...  4429.086240: cpu_idle: state=4294967295 cpu_id=7
kworker/7:2-399   [007] ....  4429.086293: cpu_frequency: state=1600000 cpu_id=7

Without the patch the CPU dropped to min frequency after 3.2s
With the patch applied the CPU dropped to min frequency after 0.86s

Signed-off-by: Stratos Karafotis &lt;stratosk@semaphore.gr&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: conservative: Rename get_freq_target() to get_freq_step()</title>
<updated>2016-11-14T20:34:52Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2016-11-14T07:00:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d5f905a93c321929ad8609c2478c1a5cd00aefdf'/>
<id>urn:sha1:d5f905a93c321929ad8609c2478c1a5cd00aefdf</id>
<content type='text'>
What's returned from this function is the delta by which the frequency
must be increased or decreased and not the final frequency that should
be selected.

Name it properly to match its purpose. Also update the variables used to
store that value.

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: governor: Don't use 'timer' keyword</title>
<updated>2016-11-11T00:48:33Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2016-11-08T05:36:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=26f0dbc9ab158afe86bac5ece2fcaf873d6bd8ad'/>
<id>urn:sha1:26f0dbc9ab158afe86bac5ece2fcaf873d6bd8ad</id>
<content type='text'>
The earlier implementation of governors used background timers and so
functions, mutex, etc had 'timer' keyword in their names.

But that's not true anymore. Replace 'timer' with 'update', as those
functions, variables are based around updates to frequency.

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: conservative: Fix next frequency selection</title>
<updated>2016-10-13T12:42:06Z</updated>
<author>
<name>Rafael J. Wysocki</name>
</author>
<published>2016-10-12T19:47:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=abb6627910a1e783c8e034b35b7c80e5e7f98f41'/>
<id>urn:sha1:abb6627910a1e783c8e034b35b7c80e5e7f98f41</id>
<content type='text'>
Commit d352cf47d93e (cpufreq: conservative: Do not use transition
notifications) overlooked the case when the "frequency step" used
by the conservative governor is small relative to the distances
between the available frequencies and broke the algorithm by
using policy-&gt;cur instead of the previously requested frequency
when computing the next one.

As a result, the governor may not be able to go outside of a narrow
range between two consecutive available frequencies.

Fix the problem by making the governor save the previously requested
frequency and select the next one relative that value (unless it is
out of range, in which case policy-&gt;cur will be used instead).

Fixes: d352cf47d93e (cpufreq: conservative: Do not use transition notifications)
Link: https://bugzilla.kernel.org/show_bug.cgi?id=177171
Reported-and-tested-by: Aleksey Rybalkin &lt;aleksey@rybalkin.org&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: conservative: Do not use transition notifications</title>
<updated>2016-06-13T21:33:49Z</updated>
<author>
<name>Rafael J. Wysocki</name>
</author>
<published>2016-06-13T21:33:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d352cf47d93e39494b44b792cca8d35a3a0bd9b3'/>
<id>urn:sha1:d352cf47d93e39494b44b792cca8d35a3a0bd9b3</id>
<content type='text'>
The conservative governor registers a transition notifier so it
can update its internal requested_freq value if it falls out of the
policy-&gt;min...policy-&gt;max range, but requested_freq is not really
necessary.

That value is used to track the frequency requested by the governor
previously, but policy-&gt;cur can be used instead of it and then the
governor will not have to worry about updating the tracked value when
the current frequency changes independently (for example, as a result
of min or max changes).

Accodringly, drop requested_freq from struct cs_policy_dbs_info
and modify cs_dbs_timer() to use policy-&gt;cur instead of it.
While at it, notice that __cpufreq_driver_target() clamps its
target_freq argument between policy-&gt;min and policy-&gt;max, so
the callers of it don't have to do that and make additional
changes in cs_dbs_timer() in accordance with that.

After these changes the transition notifier used by the conservative
governor is not necessary any more, so drop it, which also makes it
possible to drop the struct cs_governor definition and simplify the
code accordingly.

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>
</author>
<published>2016-05-18T20:59:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.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>
</feed>
