mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Cunlong Li <shenxiaogll@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Boqun Feng <boqun@kernel.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Zqiang <qiang.zhang@linux.dev>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"rcu@vger.kernel.org" <rcu@vger.kernel.org>,
	Cunlong Li <shenxiaogll@gmail.com>
Subject: Re: [PATCH] rcu: Enable runtime reset of the RCU stall panic count
Date: Mon, 5 Oct 2026 12:56:30 +0000	[thread overview]
Message-ID: <00F6D386-FE41-42E3-9B89-07381A49E061@nvidia.com> (raw)
In-Reply-To: <20261004-rcu-v1-1-3799a44367f1@gmail.com>



> On Oct 3, 2026, at 9:14 PM, Cunlong Li <shenxiaogll@gmail.com> wrote:
> 
> The kernel.panic_on_rcu_stall and kernel.max_rcu_stall_to_panic sysctls
> count RCU CPU stalls since system boot, and invoke panic() once
> max_rcu_stall_to_panic stalls have elapsed.  This count is never reset,
> so stalls caused by transient incidents keep consuming the budget of a
> long-running system, and a later unrelated stall can

Please provide examples of specific transient events you ran into, and recovered from?

> immediately
> trigger panic() instead of allowing the intended fresh window of
> stalls.
> 
> This commit therefore introduces the kernel.rcu_stall_panic_count
> sysctl.  Reading this file reports the number of stalls counted so far,
> and writing 0 to it resets the count.  This allows the cumulative stall
> history to be cleared after an incident has been resolved, and also
> allows userspace to clear the count periodically, so that panic() is
> only triggered by a burst of stalls occurring within a short period.

Could you provide details of such an incident that got resolved without requiring a reboot?


> 
> Signed-off-by: Cunlong Li <shenxiaogll@gmail.com>

If the commit is AI assisted, please add an assisted tag.

Thanks,

Joel

> ---
> Documentation/admin-guide/sysctl/kernel.rst | 15 ++++++++++++++-
> kernel/rcu/tree_stall.h                     | 28 ++++++++++++++++++++++++++--
> 2 files changed, 40 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst
> index ffea61d448eb..64fe2985e358 100644
> --- a/Documentation/admin-guide/sysctl/kernel.rst
> +++ b/Documentation/admin-guide/sysctl/kernel.rst
> @@ -959,7 +959,20 @@ max_rcu_stall_to_panic
> When ``panic_on_rcu_stall`` is set to 1, this value determines the
> number of times that RCU can stall before panic() is called.
> 
> -When ``panic_on_rcu_stall`` is set to 0, this value is has no effect.
> +When ``panic_on_rcu_stall`` is set to 0, this value has no effect.
> +
> +rcu_stall_panic_count
> +=====================
> +
> +Indicates the number of RCU CPU stalls that have been counted since
> +system boot or since the counter was reset. When ``panic_on_rcu_stall``
> +is set to 1, this count is compared against ``max_rcu_stall_to_panic``
> +to decide whether panic() should be called.
> +
> +Writing 0 to this file resets the counter to zero, which restarts the
> +``max_rcu_stall_to_panic`` window of stalls. This allows system
> +administrators to clear the cumulative stall count after an incident
> +has been resolved, without requiring a system restart.
> 
> perf_cpu_time_max_percent
> =========================
> diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
> index 091e7850ab6e..a80f03e1c7ea 100644
> --- a/kernel/rcu/tree_stall.h
> +++ b/kernel/rcu/tree_stall.h
> @@ -19,6 +19,20 @@
> /* panic() on RCU Stall sysctl. */
> static int sysctl_panic_on_rcu_stall __read_mostly;
> static int sysctl_max_rcu_stall_to_panic __read_mostly;
> +static unsigned long sysctl_rcu_stall_panic_count;
> +
> +/* Reset the RCU stall panic count when written to. */
> +static int proc_do_rcu_stall_panic_count(const struct ctl_table *table, int write,
> +                     void *buffer, size_t *lenp, loff_t *ppos)
> +{
> +    if (!write)
> +        return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
> +
> +    WRITE_ONCE(sysctl_rcu_stall_panic_count, 0);
> +    *ppos += *lenp;
> +
> +    return 0;
> +}
> 
> static const struct ctl_table rcu_stall_sysctl_table[] = {
>    {
> @@ -39,6 +53,13 @@ static const struct ctl_table rcu_stall_sysctl_table[] = {
>        .extra1        = SYSCTL_ONE,
>        .extra2        = SYSCTL_INT_MAX,
>    },
> +    {
> +        .procname    = "rcu_stall_panic_count",
> +        .data        = &sysctl_rcu_stall_panic_count,
> +        .maxlen        = sizeof(sysctl_rcu_stall_panic_count),
> +        .mode        = 0644,
> +        .proc_handler    = proc_do_rcu_stall_panic_count,
> +    },
> };
> 
> static int __init init_rcu_stall_sysctl(void)
> @@ -161,7 +182,7 @@ early_initcall(check_cpu_stall_init);
> /* If so specified via sysctl, panic, yielding cleaner stall-warning output. */
> static void panic_on_rcu_stall(const struct cpumask *stalled_mask)
> {
> -    static int cpu_stall;
> +    unsigned long count;
> 
>    /*
>     * Attempt to kick out the BPF scheduler if it's installed and defer
> @@ -170,7 +191,10 @@ static void panic_on_rcu_stall(const struct cpumask *stalled_mask)
>    if (scx_rcu_cpu_stall(stalled_mask))
>        return;
> 
> -    if (++cpu_stall < sysctl_max_rcu_stall_to_panic)
> +    /* A lost RMW update only delays the panic by one stall. */
> +    count = READ_ONCE(sysctl_rcu_stall_panic_count) + 1;
> +    WRITE_ONCE(sysctl_rcu_stall_panic_count, count);
> +    if (count < (unsigned long)READ_ONCE(sysctl_max_rcu_stall_to_panic))
>        return;
> 
>    if (sysctl_panic_on_rcu_stall)
> 
> ---
> base-commit: ce1e0223d8ad4211275c82a17ed6d43ab81e13d9
> change-id: 20261003-rcu-375496d7704e
> 
> Best regards,
> --
> Cunlong Li <shenxiaogll@gmail.com>
> 

  parent reply	other threads:[~2026-10-05 12:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-04  1:14 Cunlong Li
2026-10-04 11:04 ` Bradley Morgan
2026-10-05 12:56 ` Joel Fernandes [this message]
2026-10-06 11:54   ` Cunlong Li
2026-10-06 12:21     ` Joel Fernandes
2026-10-06 12:39     ` Joel Fernandes
2026-10-06 13:17       ` Cunlong Li
2026-10-06 21:27         ` Joel Fernandes
2026-10-07  2:56           ` Cunlong Li
2026-10-07 10:46 Joel Fernandes

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=00F6D386-FE41-42E3-9B89-07381A49E061@nvidia.com \
    --to=joelagnelf@nvidia.com \
    --cc=boqun@kernel.org \
    --cc=corbet@lwn.net \
    --cc=frederic@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=qiang.zhang@linux.dev \
    --cc=rcu@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=shenxiaogll@gmail.com \
    --cc=skhan@linuxfoundation.org \
    --cc=urezki@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®