Skip to content

Commit 5653467

Browse files
Ionut Nechita (Sunlight Linux)Thomas Gleixner
authored andcommitted
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 <tglx@linutronix.de> Signed-off-by: Ionut Nechita (Sunlight Linux) <sunlightlinux@gmail.com> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260128074558.15433-3-sunlightlinux@gmail.com
1 parent 3db5306 commit 5653467

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

kernel/time/tick-sched.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ static bool check_tick_dependency(atomic_t *dep)
344344
{
345345
int val = atomic_read(dep);
346346

347+
if (likely(!tracepoint_enabled(tick_stop)))
348+
return !val;
349+
347350
if (val & TICK_DEP_MASK_POSIX_TIMER) {
348351
trace_tick_stop(0, TICK_DEP_MASK_POSIX_TIMER);
349352
return true;

0 commit comments

Comments
 (0)