From: Frederic Weisbecker <frederic@kernel.org>
To: Avi Weiss <thnkslprpt@gmail.com>
Cc: anna-maria@linutronix.de, tglx@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] timers: Stop hrtimer queue traversal after seq_file overflow
Date: Tue, 3 Nov 2026 14:34:42 +0100 [thread overview]
Message-ID: <auni8vp1hOge-G9I@localhost.localdomain> (raw)
In-Reply-To: <20261103103438.2154751-2-thnkslprpt@gmail.com>
Le Tue, Nov 03, 2026 at 12:34:39PM +0200, Avi Weiss a écrit :
> 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;
But it's harmless, right? I mean the bad outcome is just to spend useless cycles
seeking and storing?
Still probably makes sense though.
> i = 0;
>
> touch_nmi_watchdog();
> --
> 2.43.0
>
--
Frederic Weisbecker
SUSE Labs
next prev parent reply other threads:[~2026-11-03 13:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 10:34 Avi Weiss
2026-11-03 13:34 ` Frederic Weisbecker [this message]
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=auni8vp1hOge-G9I@localhost.localdomain \
--to=frederic@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=thnkslprpt@gmail.com \
/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®