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.

hrtimer: Prepare stubs for deferred rearming

The hrtimer interrupt expires timers and at the end of the interrupt it
rearms the clockevent device for the next expiring timer.

That's obviously correct, but in the case that a expired timer set
NEED_RESCHED the return from interrupt ends up in schedule(). If HRTICK is
enabled then schedule() will modify the hrtick timer, which causes another
reprogramming of the hardware.

That can be avoided by deferring the rearming to the return from interrupt
path and if the return results in a immediate schedule() invocation then it
can be deferred until the end of schedule().

To make this correct the affected code parts need to be made aware of this.

Provide empty stubs for the deferred rearming mechanism, so that the
relevant code changes for entry, softirq and scheduler can be split up into
separate changes independent of the actual enablement in the hrtimer code.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260224163431.000891171@kernel.org

+26
+1
include/linux/hrtimer.h
··· 13 13 #define _LINUX_HRTIMER_H 14 14 15 15 #include <linux/hrtimer_defs.h> 16 + #include <linux/hrtimer_rearm.h> 16 17 #include <linux/hrtimer_types.h> 17 18 #include <linux/init.h> 18 19 #include <linux/list.h>
+21
include/linux/hrtimer_rearm.h
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #ifndef _LINUX_HRTIMER_REARM_H 3 + #define _LINUX_HRTIMER_REARM_H 4 + 5 + #ifdef CONFIG_HRTIMER_REARM_DEFERRED 6 + static __always_inline void __hrtimer_rearm_deferred(void) { } 7 + static __always_inline void hrtimer_rearm_deferred(void) { } 8 + static __always_inline void hrtimer_rearm_deferred_tif(unsigned long tif_work) { } 9 + static __always_inline bool 10 + hrtimer_rearm_deferred_user_irq(unsigned long *tif_work, const unsigned long tif_mask) { return false; } 11 + static __always_inline bool hrtimer_test_and_clear_rearm_deferred(void) { return false; } 12 + #else /* CONFIG_HRTIMER_REARM_DEFERRED */ 13 + static __always_inline void __hrtimer_rearm_deferred(void) { } 14 + static __always_inline void hrtimer_rearm_deferred(void) { } 15 + static __always_inline void hrtimer_rearm_deferred_tif(unsigned long tif_work) { } 16 + static __always_inline bool 17 + hrtimer_rearm_deferred_user_irq(unsigned long *tif_work, const unsigned long tif_mask) { return false; } 18 + static __always_inline bool hrtimer_test_and_clear_rearm_deferred(void) { return false; } 19 + #endif /* !CONFIG_HRTIMER_REARM_DEFERRED */ 20 + 21 + #endif
+4
kernel/time/Kconfig
··· 58 58 config GENERIC_CMOS_UPDATE 59 59 bool 60 60 61 + # Deferred rearming of the hrtimer interrupt 62 + config HRTIMER_REARM_DEFERRED 63 + def_bool n 64 + 61 65 # Select to handle posix CPU timers from task_work 62 66 # and not from the timer interrupt context 63 67 config HAVE_POSIX_CPU_TIMERS_TASK_WORK