[PATCH] tick/nohz: Optimize check_tick_dependency() with early return
From: Ionut Nechita (Sunlight Linux)
Date: Wed Jan 28 2026 - 02:47:21 EST
Avoid iterating through individual tick dependency bits when the
tick_stop tracepoint is disabled, which is the common case. When
tracing is disabled, we can 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 <tglx@xxxxxxxxxxxxx>
Signed-off-by: Ionut Nechita <ionut_n2001@xxxxxxxxx>
---
kernel/time/tick-sched.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 34b341b66f220..2c1236a1cd364 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -332,6 +332,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;
--
2.52.0