FAILED: patch "[PATCH] cpuidle: governors: menu: Select polling state in some more" failed to apply to 6.12-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x db86f55bf81a3a297be05ee8775ae9a8c6e3a599
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025110244-overstuff-scallop-d38a@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From db86f55bf81a3a297be05ee8775ae9a8c6e3a599 Mon Sep 17 00:00:00 2001
From: "Rafael J. Wysocki" <[email protected]>
Date: Thu, 23 Oct 2025 19:12:57 +0200
Subject: [PATCH] cpuidle: governors: menu: Select polling state in some more
cases
A throughput regression of 11% introduced by commit 779b1a1cb13a ("cpuidle:
governors: menu: Avoid selecting states with too much latency") has been reported and it is related to the case when the menu governor checks if selecting a proper idle state instead of a polling one makes sense.
In particular, it is questionable to do so if the exit latency of the idle state in question exceeds the predicted idle duration, so add a check for that, which is sufficient to make the reported regression go away, and update the related code comment accordingly.
drivers/cpuidle/governors/menu.c +5 -2
@@ -318,10 +318,13 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,/* * Use a physical idle state, not busy polling, unless a timer -* is going to trigger soon enough. +* is going to trigger soon enough or the exit latency of the +* idle state in question is greater than the predicted idle +* duration. */ if ((drv->states[idx].flags &CPUIDLE_FLAG_POLLING ) && - s->target_residency_ns <= data->next_timer_ns) { + s->target_residency_ns <= data->next_timer_ns && + s->exit_latency_ns <= predicted_ns) { predicted_ns = s->target_residency_ns; idx = i;break ;
Sasha Levin
maintainerPATCH 1/2 cpuidle: governors: menu: Rearrange main loop in menu_select()
From: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit 17224c1d2574d29668c4879e1fbf36d6f68cd22b ]
Reduce the indentation level in the main loop of menu_select() by rearranging some checks and assignments in it.
No intentional functional impact.
Stable-dep-of: db86f55bf81a ("cpuidle: governors: menu: Select polling state in some more cases")
--- drivers/cpuidle/governors/menu.c | 70 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 34 deletions(-)
drivers/cpuidle/governors/menu.c +36 -34
@@ -317,45 +317,47 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,if (s->exit_latency_ns > latency_req)break ; -if (s->target_residency_ns > predicted_ns) { -/* -* Use a physical idle state, not busy polling, unless -* a timer is going to trigger soon enough. -*/ -if ((drv->states[idx].flags &CPUIDLE_FLAG_POLLING ) && - s->target_residency_ns <= data->next_timer_ns) { - predicted_ns = s->target_residency_ns; - idx = i; -break ; - } -if (predicted_ns <TICK_NSEC ) -break ; - -if (!tick_nohz_tick_stopped ()) { -/* -* If the state selected so far is shallow, -* waking up early won't hurt, so retain the -* tick in that case and let the governor run -* again in the next iteration of the loop. -*/ - predicted_ns = drv->states[idx].target_residency_ns; -break ; - } +if (s->target_residency_ns <= predicted_ns) { + idx = i; +continue ; + } + +/* +* Use a physical idle state, not busy polling, unless a timer +* is going to trigger soon enough. +*/ +if ((drv->states[idx].flags &CPUIDLE_FLAG_POLLING ) && + s->target_residency_ns <= data->next_timer_ns) { + predicted_ns = s->target_residency_ns; + idx = i; +break ; + } +if (predicted_ns <TICK_NSEC ) +break ; + +if (!tick_nohz_tick_stopped ()) {/* -* If the state selected so far is shallow and this -* state's target residency matches the time till the -* closest timer event, select this one to avoid getting -* stuck in the shallow one for too long. +* If the state selected so far is shallow, waking up +* early won't hurt, so retain the tick in that case and +* let the governor run again in the next iteration of +* the idle loop. */ -if (drv->states[idx].target_residency_ns <TICK_NSEC && - s->target_residency_ns <= delta_tick) - idx = i; - -return idx; + predicted_ns = drv->states[idx].target_residency_ns; +break ; } - idx = i; +/* +* If the state selected so far is shallow and this state's +* target residency matches the time till the closest timer +* event, select this one to avoid getting stuck in the shallow +* one for too long. +*/ +if (drv->states[idx].target_residency_ns <TICK_NSEC && + s->target_residency_ns <= delta_tick) + idx = i; + +return idx; }if (idx ==-1 )
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/2 cpuidle: governors: menu: Select polling state in some more cases
From: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit db86f55bf81a3a297be05ee8775ae9a8c6e3a599 ]
A throughput regression of 11% introduced by commit 779b1a1cb13a ("cpuidle:
governors: menu: Avoid selecting states with too much latency") has been reported and it is related to the case when the menu governor checks if selecting a proper idle state instead of a polling one makes sense.
In particular, it is questionable to do so if the exit latency of the idle state in question exceeds the predicted idle duration, so add a check for that, which is sufficient to make the reported regression go away, and update the related code comment accordingly.
--- drivers/cpuidle/governors/menu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpuidle/governors/menu.c +5 -2
@@ -324,10 +324,13 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,/* * Use a physical idle state, not busy polling, unless a timer -* is going to trigger soon enough. +* is going to trigger soon enough or the exit latency of the +* idle state in question is greater than the predicted idle +* duration. */ if ((drv->states[idx].flags &CPUIDLE_FLAG_POLLING ) && - s->target_residency_ns <= data->next_timer_ns) { + s->target_residency_ns <= data->next_timer_ns && + s->exit_latency_ns <= predicted_ns) { predicted_ns = s->target_residency_ns; idx = i;break ;
Signature · 1 line
2.51.0