From: Avi Weiss <thnkslprpt@gmail.com>
To: anna-maria@linutronix.de, frederic@kernel.org, tglx@kernel.org
Cc: linux-kernel@vger.kernel.org, Avi Weiss <thnkslprpt@gmail.com>
Subject: [PATCH] timers: Stop hrtimer queue traversal after seq_file overflow
Date: Tue, 3 Nov 2026 12:34:39 +0200 [thread overview]
Message-ID: <20261103103438.2154751-2-thnkslprpt@gmail.com> (raw)
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
next reply other threads:[~2026-11-03 10:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 10:34 Avi Weiss [this message]
2026-11-03 13:34 ` Frederic Weisbecker
2026-11-03 13:40 ` Avi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103103438.2154751-2-thnkslprpt@gmail.com \
--to=thnkslprpt@gmail.com \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®