Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

timers: Get this_cpu once while clearing the idle state

Calling smp_processor_id() on:
- In CONFIG_DEBUG_PREEMPT=y, if preemption/irq is disabled, then it does
not print any warning.
- In CONFIG_DEBUG_PREEMPT=n, it doesn't do anything apart from getting
__smp_processor_id

So with both CONFIG_DEBUG_PREEMPT=y/n, in preemption disabled section it is
better to cache the value. It saves a few cycles. Though tiny, repeated
adds up.

timer_clear_idle() is called with interrupts disabled. So cache the value
once.

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Link: https://patch.msgid.link/20260323193630.640311-5-sshegde@linux.ibm.com

authored by

Shrikanth Hegde and committed by
Thomas Gleixner
551e49be f6472b17

+3 -2
+3 -2
kernel/time/timer.c
··· 2319 2319 */ 2320 2320 void timer_clear_idle(void) 2321 2321 { 2322 + int this_cpu = smp_processor_id(); 2322 2323 /* 2323 2324 * We do this unlocked. The worst outcome is a remote pinned timer 2324 2325 * enqueue sending a pointless IPI, but taking the lock would just ··· 2328 2327 * path. Required for BASE_LOCAL only. 2329 2328 */ 2330 2329 __this_cpu_write(timer_bases[BASE_LOCAL].is_idle, false); 2331 - if (tick_nohz_full_cpu(smp_processor_id())) 2330 + if (tick_nohz_full_cpu(this_cpu)) 2332 2331 __this_cpu_write(timer_bases[BASE_GLOBAL].is_idle, false); 2333 - trace_timer_base_idle(false, smp_processor_id()); 2332 + trace_timer_base_idle(false, this_cpu); 2334 2333 2335 2334 /* Activate without holding the timer_base->lock */ 2336 2335 tmigr_cpu_activate();