mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] timers: Stop hrtimer queue traversal after seq_file overflow
@ 2026-11-03 10:34 Avi Weiss
  2026-11-03 13:34 ` Frederic Weisbecker
  0 siblings, 1 reply; 3+ messages in thread
From: Avi Weiss @ 2026-11-03 10:34 UTC (permalink / raw)
  To: anna-maria, frederic, tglx; +Cc: linux-kernel, Avi Weiss

When /proc/timer_list overflows its seq_file buffer, seq_file retries
formatting with a larger buffer. print_active_timers() nevertheless
continues scanning the remaining hrtimers, restarting its quadratic
traversal even though the overflowing attempt will be discarded.

Stop traversing at next_one when the seq_file has overflowed. Preserve
the SysRq console path, which passes a NULL seq_file pointer.

In a (virtual) two-CPU KVM guest with 2,048 timerfds pinned to one CPU,
median reader CPU time for a complete /proc/timer_list read fell from
51.1 ms to 14.6 ms. Repeated tests showed no material slowdown for
non-overflowing reads (13.7us before versus 13.8 after). Short reads,
seek-to-start, and SysRq-Q tests also look fine.

Fixes: 289f480af87e ("[PATCH] Add debugging feature /proc/timer_list")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
 kernel/time/timer_list.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 0406bf4488e9..84275b6cd2c9 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -64,6 +64,8 @@ static void print_active_timers(struct seq_file *m, struct hrtimer_clock_base *b
 	unsigned long flags;
 
 next_one:
+	if (m && seq_has_overflowed(m))
+		return;
 	i = 0;
 
 	touch_nmi_watchdog();
-- 
2.43.0


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

end of thread, other threads:[~2026-11-03 13:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 10:34 [PATCH] timers: Stop hrtimer queue traversal after seq_file overflow Avi Weiss
2026-11-03 13:34 ` Frederic Weisbecker
2026-11-03 13:40   ` Avi

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®