All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tick/nohz: Optimize check_tick_dependency() with early return
@ 2026-01-28  7:45 Ionut Nechita (Sunlight Linux)
  2026-01-30  9:03 ` [tip: timers/core] " tip-bot2 for Ionut Nechita (Sunlight Linux)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ionut Nechita (Sunlight Linux) @ 2026-01-28  7:45 UTC (permalink / raw)
  To: Thomas Gleixner, Frederic Weisbecker
  Cc: Ionut Nechita, Ingo Molnar, Anna-Maria Behnsen, Ionut Nechita,
	linux-kernel

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@linutronix.de>
Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip: timers/core] tick/nohz: Optimize check_tick_dependency() with early return
  2026-01-28  7:45 [PATCH] tick/nohz: Optimize check_tick_dependency() with early return Ionut Nechita (Sunlight Linux)
@ 2026-01-30  9:03 ` tip-bot2 for Ionut Nechita (Sunlight Linux)
  2026-01-30 16:28 ` tip-bot2 for Ionut Nechita (Sunlight Linux)
  2026-01-30 21:47 ` tip-bot2 for Ionut Nechita (Sunlight Linux)
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Ionut Nechita (Sunlight Linux) @ 2026-01-30  9:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Thomas Gleixner, Ionut Nechita, Thomas Gleixner, x86,
	linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     8f9e1849402b34744cf3e4c8174b1907d1f99fe3
Gitweb:        https://git.kernel.org/tip/8f9e1849402b34744cf3e4c8174b1907d1f99fe3
Author:        Ionut Nechita (Sunlight Linux) <sunlightlinux@gmail.com>
AuthorDate:    Wed, 28 Jan 2026 09:45:43 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Fri, 30 Jan 2026 09:59:34 +01:00

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 <ionut_n2001@yahoo.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260128074558.15433-3-sunlightlinux@gmail.com
---
 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 8ddf74e..fd928d3 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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip: timers/core] tick/nohz: Optimize check_tick_dependency() with early return
  2026-01-28  7:45 [PATCH] tick/nohz: Optimize check_tick_dependency() with early return Ionut Nechita (Sunlight Linux)
  2026-01-30  9:03 ` [tip: timers/core] " tip-bot2 for Ionut Nechita (Sunlight Linux)
@ 2026-01-30 16:28 ` tip-bot2 for Ionut Nechita (Sunlight Linux)
  2026-01-30 21:47 ` tip-bot2 for Ionut Nechita (Sunlight Linux)
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Ionut Nechita (Sunlight Linux) @ 2026-01-30 16:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Thomas Gleixner, Ionut Nechita (Sunlight Linux), Thomas Gleixner,
	x86, linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     9328c0960f22e2499319e4e894abb98aa0f9d222
Gitweb:        https://git.kernel.org/tip/9328c0960f22e2499319e4e894abb98aa0f9d222
Author:        Ionut Nechita (Sunlight Linux) <sunlightlinux@gmail.com>
AuthorDate:    Wed, 28 Jan 2026 09:45:43 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Fri, 30 Jan 2026 17:24:31 +01:00

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
---
 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 8ddf74e..fd928d3 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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip: timers/core] tick/nohz: Optimize check_tick_dependency() with early return
  2026-01-28  7:45 [PATCH] tick/nohz: Optimize check_tick_dependency() with early return Ionut Nechita (Sunlight Linux)
  2026-01-30  9:03 ` [tip: timers/core] " tip-bot2 for Ionut Nechita (Sunlight Linux)
  2026-01-30 16:28 ` tip-bot2 for Ionut Nechita (Sunlight Linux)
@ 2026-01-30 21:47 ` tip-bot2 for Ionut Nechita (Sunlight Linux)
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Ionut Nechita (Sunlight Linux) @ 2026-01-30 21:47 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Thomas Gleixner, Ionut Nechita (Sunlight Linux), Thomas Gleixner,
	x86, linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     56534673cea7f00d96a64deb58057298fe9f192e
Gitweb:        https://git.kernel.org/tip/56534673cea7f00d96a64deb58057298fe9f192e
Author:        Ionut Nechita (Sunlight Linux) <sunlightlinux@gmail.com>
AuthorDate:    Wed, 28 Jan 2026 09:45:43 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Fri, 30 Jan 2026 22:13:13 +01:00

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
---
 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 8ddf74e..fd928d3 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;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-30 21:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28  7:45 [PATCH] tick/nohz: Optimize check_tick_dependency() with early return Ionut Nechita (Sunlight Linux)
2026-01-30  9:03 ` [tip: timers/core] " tip-bot2 for Ionut Nechita (Sunlight Linux)
2026-01-30 16:28 ` tip-bot2 for Ionut Nechita (Sunlight Linux)
2026-01-30 21:47 ` tip-bot2 for Ionut Nechita (Sunlight Linux)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.