]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpuidle: powerpc: avoid double clear when breaking snooze
authorShrikanth Hegde <sshegde@linux.ibm.com>
Wed, 11 Mar 2026 06:17:09 +0000 (11:47 +0530)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Wed, 1 Apr 2026 03:51:06 +0000 (09:21 +0530)
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: 7ded429152e8 ("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
drivers/cpuidle/cpuidle-powernv.c
drivers/cpuidle/cpuidle-pseries.c

index 9ebedd972df0bb8ebd139fde57597f47e6055da6..b89e7111e7b8c6f6f43150a1ce3b69bbc8ec5c1b 100644 (file)
@@ -95,7 +95,10 @@ static int snooze_loop(struct cpuidle_device *dev,
 
        HMT_medium();
        ppc64_runlatch_on();
-       clear_thread_flag(TIF_POLLING_NRFLAG);
+
+       /* Avoid double clear when breaking */
+       if (!dev->poll_time_limit)
+               clear_thread_flag(TIF_POLLING_NRFLAG);
 
        local_irq_disable();
 
index f68c65f1d023f2bba947b892bda2d68cbb534152..864dd5d6e627b6a5b2345c70f9f4911860a65851 100644 (file)
@@ -64,7 +64,10 @@ int snooze_loop(struct cpuidle_device *dev, struct cpuidle_driver *drv,
        }
 
        HMT_medium();
-       clear_thread_flag(TIF_POLLING_NRFLAG);
+
+       /* Avoid double clear when breaking */
+       if (!dev->poll_time_limit)
+               clear_thread_flag(TIF_POLLING_NRFLAG);
 
        raw_local_irq_disable();