mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tick/nohz: Remove redundant IRQ save/restore
@ 2026-09-16 14:15 Usama Arif
  2026-09-16 14:49 ` Frederic Weisbecker
  2026-09-29 18:59 ` [tip: timers/nohz] tick/nohz: Remove redundant local_irq_save()/restore() tip-bot2 for Usama Arif
  0 siblings, 2 replies; 3+ messages in thread
From: Usama Arif @ 2026-09-16 14:15 UTC (permalink / raw)
  To: tglx, anna-maria, frederic, linux-kernel, mingo
  Cc: hannes, shakeel.butt, riel, kernel-team, Usama Arif

tick_nohz_update_jiffies() is only reached through tick_irq_enter() from
hard interrupt entry, where local interrupts are already disabled.

tick_do_update_jiffies64() requires interrupts to be disabled. The
local_irq_save()/local_irq_restore() pair around it therefore provides no
additional interrupt exclusion.

Remove it and assert the caller invariant instead.

On x86-64, this avoids the redundant RFLAGS save, CLI, saved-IF test and
conditional branch on the tick-stopped path.

On a 252-CPU host running a Thrift RPC service, tick_irq_enter() ran
165,116 times/s out of 212-244k interrupts/s. Only calls with
TS_FLAG_STOPPED reach the optimized path, so this is an upper bound on
its execution rate.

Signed-off-by: Usama Arif <usama.arif@linux.dev>
---
 kernel/time/tick-sched.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 6c3fea3867139..c8f2c4a503b08 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -738,14 +738,11 @@ bool tick_nohz_tick_stopped_cpu(int cpu)
  */
 static void tick_nohz_update_jiffies(ktime_t now)
 {
-	unsigned long flags;
+	/* Reached only from irq_enter_rcu(), i.e. hard interrupt entry. */
+	lockdep_assert_irqs_disabled();
 
 	__this_cpu_write(tick_cpu_sched.idle_waketime, now);
-
-	local_irq_save(flags);
 	tick_do_update_jiffies64(now);
-	local_irq_restore(flags);
-
 	touch_softlockup_watchdog_sched();
 }
 
-- 
2.53.0-Meta


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

* Re: [PATCH] tick/nohz: Remove redundant IRQ save/restore
  2026-09-16 14:15 [PATCH] tick/nohz: Remove redundant IRQ save/restore Usama Arif
@ 2026-09-16 14:49 ` Frederic Weisbecker
  2026-09-29 18:59 ` [tip: timers/nohz] tick/nohz: Remove redundant local_irq_save()/restore() tip-bot2 for Usama Arif
  1 sibling, 0 replies; 3+ messages in thread
From: Frederic Weisbecker @ 2026-09-16 14:49 UTC (permalink / raw)
  To: Usama Arif
  Cc: tglx, anna-maria, linux-kernel, mingo, hannes, shakeel.butt,
	riel, kernel-team

Le Wed, Sep 16, 2026 at 07:15:30AM -0700, Usama Arif a écrit :
> tick_nohz_update_jiffies() is only reached through tick_irq_enter() from
> hard interrupt entry, where local interrupts are already disabled.
> 
> tick_do_update_jiffies64() requires interrupts to be disabled. The
> local_irq_save()/local_irq_restore() pair around it therefore provides no
> additional interrupt exclusion.
> 
> Remove it and assert the caller invariant instead.
> 
> On x86-64, this avoids the redundant RFLAGS save, CLI, saved-IF test and
> conditional branch on the tick-stopped path.
> 
> On a 252-CPU host running a Thrift RPC service, tick_irq_enter() ran
> 165,116 times/s out of 212-244k interrupts/s. Only calls with
> TS_FLAG_STOPPED reach the optimized path, so this is an upper bound on
> its execution rate.
> 
> Signed-off-by: Usama Arif <usama.arif@linux.dev>

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>

-- 
Frederic Weisbecker
SUSE Labs

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

* [tip: timers/nohz] tick/nohz: Remove redundant local_irq_save()/restore()
  2026-09-16 14:15 [PATCH] tick/nohz: Remove redundant IRQ save/restore Usama Arif
  2026-09-16 14:49 ` Frederic Weisbecker
@ 2026-09-29 18:59 ` tip-bot2 for Usama Arif
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Usama Arif @ 2026-09-29 18:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Usama Arif, Thomas Gleixner, Frederic Weisbecker, x86, linux-kernel

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

Commit-ID:     75990fb534e858ac61ae7651c4695e0905a04443
Gitweb:        https://git.kernel.org/tip/75990fb534e858ac61ae7651c4695e0905a04443
Author:        Usama Arif <usama.arif@linux.dev>
AuthorDate:    Wed, 16 Sep 2026 07:15:30 -07:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 29 Sep 2026 20:55:51 +02:00

tick/nohz: Remove redundant local_irq_save()/restore()

tick_nohz_update_jiffies() is only reached through tick_irq_enter() from
hard interrupt entry, where local interrupts are already disabled.

tick_do_update_jiffies64() requires interrupts to be disabled. The
local_irq_save()/local_irq_restore() pair around it therefore provides no
additional interrupt exclusion.

Remove it and assert the caller invariant instead.

On x86-64, this avoids the redundant RFLAGS save, CLI, saved-IF test and
conditional branch on the tick-stopped path.

On a 252-CPU host running a Thrift RPC service, tick_irq_enter() ran
165,116 times/s out of 212-244k interrupts/s. Only calls with
TS_FLAG_STOPPED reach the optimized path, so this is an upper bound on
its execution rate.

Signed-off-by: Usama Arif <usama.arif@linux.dev>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://patch.msgid.link/20260916141530.3423310-1-usama.arif@linux.dev
---
 kernel/time/tick-sched.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 6c3fea3..c8f2c4a 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -738,14 +738,11 @@ bool tick_nohz_tick_stopped_cpu(int cpu)
  */
 static void tick_nohz_update_jiffies(ktime_t now)
 {
-	unsigned long flags;
+	/* Reached only from irq_enter_rcu(), i.e. hard interrupt entry. */
+	lockdep_assert_irqs_disabled();
 
 	__this_cpu_write(tick_cpu_sched.idle_waketime, now);
-
-	local_irq_save(flags);
 	tick_do_update_jiffies64(now);
-	local_irq_restore(flags);
-
 	touch_softlockup_watchdog_sched();
 }
 

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

end of thread, other threads:[~2026-09-29 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 14:15 [PATCH] tick/nohz: Remove redundant IRQ save/restore Usama Arif
2026-09-16 14:49 ` Frederic Weisbecker
2026-09-29 18:59 ` [tip: timers/nohz] tick/nohz: Remove redundant local_irq_save()/restore() tip-bot2 for Usama Arif

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®