Power management fixes for 5.14-rc5

Fix a recent regression in the timer events oriented (TEO) cpuidle
 governor causing it to misbehave when idle state 0 is disabled and
 rename two local variables for improved clarity on top of that.
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmENdOgSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRx+rsP/RogPz4EliYXBAazVGaw4PDx/5fokXqW
 P1bCZCnNnfBmUirW6nBBk7C6J77wfCWgir2kCrnoRib133hXLLjCHrS1tW68DEy2
 duQBht2ccfkm0EVF8Zzs/8pjoukOArGw5I5DnGBabgHd7zB2eZheMR5A3JC5VdMv
 jUF4d2S1wRD81yEC+KajyOhVfaUA1Hn/PrcIcTzWhmW+z9jyzCzp3E3EJtaEp42b
 Uyh5GsZjR3Nn1g8lMkYRLSLOOBKaMFdEMTE76ZkQYSphJcj7anFMI00ftc6ash4W
 lnaYRiUH55gGqpwoZ0io9B/whH+C4IXUdq8w1RYwS9q25wdgR1/UxrV7zcqAWPH6
 vnx7gTACuNxrIvN6G3l0AiS3Z6nrFpB4DdlwUABWp3ywk69YFyqOFor3NwVWTnLh
 Dnbommg3KlEGtfUnSTpsdL0QLBeKtGTe/wNm16Oxyd7A0mqOx/1x3Ue4NaxBKwCN
 CeCd//ztZNs7wUw52gZwmCNPotQMgc11ewuRCbM3Hnj5bdiSrAD9/IhK9eJ/K9cV
 O/j282AKUXiYjua4aL1WjMmmqb2ktRQcofeUCsRNhx7kC4JiDTHV5aEahftqlwt3
 sVu1IrfhX1BLU8PTuJMvIRrvJmXcUwLi0fkcDnLjSg0BiQYyTipnB8PT2q6swTM/
 BUb+TU8jeRQw
 =CPqq
 -----END PGP SIGNATURE-----

Merge tag 'pm-5.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
 "Fix a recent regression in the timer events oriented (TEO) cpuidle
  governor causing it to misbehave when idle state 0 is disabled and
  rename two local variables for improved clarity on top of that"

* tag 'pm-5.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  cpuidle: teo: Rename two local variables in teo_select()
  cpuidle: teo: Fix alternative idle state lookup
This commit is contained in:
Linus Torvalds 2021-08-06 12:30:29 -07:00
commit 9917de73b4
1 changed files with 33 additions and 19 deletions

View File

@ -382,8 +382,8 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
alt_intercepts = 2 * idx_intercept_sum > cpu_data->total - idx_hit_sum;
alt_recent = idx_recent_sum > NR_RECENT / 2;
if (alt_recent || alt_intercepts) {
s64 last_enabled_span_ns = duration_ns;
int last_enabled_idx = idx;
s64 first_suitable_span_ns = duration_ns;
int first_suitable_idx = idx;
/*
* Look for the deepest idle state whose target residency had
@ -397,37 +397,51 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
intercept_sum = 0;
recent_sum = 0;
for (i = idx - 1; i >= idx0; i--) {
for (i = idx - 1; i >= 0; i--) {
struct teo_bin *bin = &cpu_data->state_bins[i];
s64 span_ns;
intercept_sum += bin->intercepts;
recent_sum += bin->recent;
if (dev->states_usage[i].disable)
continue;
span_ns = teo_middle_of_bin(i, drv);
if (!teo_time_ok(span_ns)) {
/*
* The current state is too shallow, so select
* the first enabled deeper state.
*/
duration_ns = last_enabled_span_ns;
idx = last_enabled_idx;
break;
}
if ((!alt_recent || 2 * recent_sum > idx_recent_sum) &&
(!alt_intercepts ||
2 * intercept_sum > idx_intercept_sum)) {
idx = i;
duration_ns = span_ns;
if (teo_time_ok(span_ns) &&
!dev->states_usage[i].disable) {
idx = i;
duration_ns = span_ns;
} else {
/*
* The current state is too shallow or
* disabled, so take the first enabled
* deeper state with suitable time span.
*/
idx = first_suitable_idx;
duration_ns = first_suitable_span_ns;
}
break;
}
last_enabled_span_ns = span_ns;
last_enabled_idx = i;
if (dev->states_usage[i].disable)
continue;
if (!teo_time_ok(span_ns)) {
/*
* The current state is too shallow, but if an
* alternative candidate state has been found,
* it may still turn out to be a better choice.
*/
if (first_suitable_idx != idx)
continue;
break;
}
first_suitable_span_ns = span_ns;
first_suitable_idx = i;
}
}