From: Thomas Gleixner Date: Fri, 7 Feb 2025 21:16:09 +0000 (+0100) Subject: hrtimers: Make hrtimer_update_function() less expensive X-Git-Tag: v6.12.64~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d579cc549298a02ba90b7a6d20a2ba8e160f3f31;p=thirdparty%2Fkernel%2Fstable.git hrtimers: Make hrtimer_update_function() less expensive commit 2ea97b76d6712bfb0408e5b81ffd7bc4551d3153 upstream. The sanity checks in hrtimer_update_function() are expensive for high frequency usage like in the io/uring code due to locking. Hide the sanity checks behind CONFIG_PROVE_LOCKING, which has a decent chance to be enabled on a regular basis for testing. Fixes: 8f02e3563bb5 ("hrtimers: Introduce hrtimer_update_function()") Reported-by: Jens Axboe Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/all/87ikpllali.ffs@tglx Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 39fbeb64a7da8..1e186449dd04f 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -348,6 +348,7 @@ static inline int hrtimer_callback_running(struct hrtimer *timer) static inline void hrtimer_update_function(struct hrtimer *timer, enum hrtimer_restart (*function)(struct hrtimer *)) { +#ifdef CONFIG_PROVE_LOCKING guard(raw_spinlock_irqsave)(&timer->base->cpu_base->lock); if (WARN_ON_ONCE(hrtimer_is_queued(timer))) @@ -355,7 +356,7 @@ static inline void hrtimer_update_function(struct hrtimer *timer, if (WARN_ON_ONCE(!function)) return; - +#endif timer->function = function; }