Skip to content

Commit 69b0510

Browse files
Shrikanth Hegdemaddy-kerneldev
authored andcommitted
cpuidle: powerpc: avoid double clear when breaking snooze
snooze_loop is done often in any system which has fair bit of idle time. So it qualifies for even micro-optimizations. When breaking the snooze due to timeout, TIF_POLLING_NRFLAG is cleared twice. Clearing the bit invokes atomics. Avoid double clear and thereby avoid one atomic write. dev->poll_time_limit indicates whether the loop was broken due to timeout. Use that instead of defining a new variable. Fixes: 7ded429 ("cpuidle: powerpc: no memory barrier after break from idle") Cc: stable@vger.kernel.org Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20260311061709.1230440-1-sshegde@linux.ibm.com
1 parent f5b4753 commit 69b0510

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

drivers/cpuidle/cpuidle-powernv.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ static int snooze_loop(struct cpuidle_device *dev,
9595

9696
HMT_medium();
9797
ppc64_runlatch_on();
98-
clear_thread_flag(TIF_POLLING_NRFLAG);
98+
99+
/* Avoid double clear when breaking */
100+
if (!dev->poll_time_limit)
101+
clear_thread_flag(TIF_POLLING_NRFLAG);
99102

100103
local_irq_disable();
101104

drivers/cpuidle/cpuidle-pseries.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ int snooze_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv,
6464
}
6565

6666
HMT_medium();
67-
clear_thread_flag(TIF_POLLING_NRFLAG);
67+
68+
/* Avoid double clear when breaking */
69+
if (!dev->poll_time_limit)
70+
clear_thread_flag(TIF_POLLING_NRFLAG);
6871

6972
raw_local_irq_disable();
7073

0 commit comments

Comments
 (0)