mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpuidle: menu: Optimize bucket assignment when next_timer_ns equals KTIME_MAX
@ 2025-04-03  9:28 Zhongqiu Han
  2025-04-03  9:34 ` Christian Loehle
  0 siblings, 1 reply; 5+ messages in thread
From: Zhongqiu Han @ 2025-04-03  9:28 UTC (permalink / raw)
  To: rafael, daniel.lezcano, christian.loehle
  Cc: linux-pm, linux-kernel, quic_zhonhan

Directly assign the last bucket value instead of calling which_bucket()
when next_timer_ns equals KTIME_MAX, the largest possible value that
always falls into the last bucket. This avoids unnecessary calculations
and enhances performance.

Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
---
 drivers/cpuidle/governors/menu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 39aa0aea61c6..8fc7fbed0052 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -255,7 +255,12 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
 		 */
 		data->next_timer_ns = KTIME_MAX;
 		delta_tick = TICK_NSEC / 2;
-		data->bucket = which_bucket(KTIME_MAX);
+		/*
+		 * Assign the last bucket value directly instead of calling
+		 * which_bucket(), since KTIME_MAX is the largest possible
+		 * value that always falls into the last bucket.
+		 */
+		data->bucket = BUCKETS - 1;
 	}
 
 	if (unlikely(drv->state_count <= 1 || latency_req == 0) ||
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-03 10:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-03  9:28 [PATCH] cpuidle: menu: Optimize bucket assignment when next_timer_ns equals KTIME_MAX Zhongqiu Han
2025-04-03  9:34 ` Christian Loehle
2025-04-03 10:01   ` Zhongqiu Han
2025-04-03 10:06     ` Christian Loehle
2025-04-03 10:30       ` Zhongqiu Han

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®