From: Ionut Nechita (Sunlight Linux) Date: Wed, 28 Jan 2026 07:45:43 +0000 (+0200) Subject: tick/nohz: Optimize check_tick_dependency() with early return X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56534673cea7f00d96a64deb58057298fe9f192e;p=thirdparty%2Fkernel%2Flinux.git tick/nohz: Optimize check_tick_dependency() with early return There is no point in iterating through individual tick dependency bits when the tick_stop tracepoint is disabled, which is the common case. When the trace point is disabled, return immediately based on the atomic value being zero or non-zero, skipping the per-bit evaluation. This optimization improves the hot path performance of tick dependency checks across all contexts (idle and non-idle), not just nohz_full CPUs. Suggested-by: Thomas Gleixner Signed-off-by: Ionut Nechita (Sunlight Linux) Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260128074558.15433-3-sunlightlinux@gmail.com --- diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 8ddf74e705d35..fd928d374cfce 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -344,6 +344,9 @@ static bool check_tick_dependency(atomic_t *dep) { int val = atomic_read(dep); + if (likely(!tracepoint_enabled(tick_stop))) + return !val; + if (val & TICK_DEP_MASK_POSIX_TIMER) { trace_tick_stop(0, TICK_DEP_MASK_POSIX_TIMER); return true;