From: Andrea Parri <parri.andrea@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Andrea Parri <parri.andrea@gmail.com>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
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>,
Bradley Morgan <brads@mainlining.org>,
Kunwu Chan <kunwu.chan@gmail.com>,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC -rcu/dev] hazptrtorture: Release all deferred hazard pointers before stopping
Date: Thu, 22 Oct 2026 14:55:55 +0200 [thread overview]
Message-ID: <20261022125556.3559773-1-parri.andrea@gmail.com> (raw)
In-Reply-To: <45a6159e-1bcd-45d4-af25-baddf729ac54@paulmck-laptop>
On Wed, Oct 21, 2026 at 09:50:11AM -0700, Paul E. McKenney wrote:
> On Wed, Oct 21, 2026 at 11:06:51AM +0200, Andrea Parri wrote:
[...]
> > - If kthread_stop() has already happened, i.e., it comes between
> > the kthread_should_stop() check and set_current_state(), the
> > wakeup is lost, but KTHREAD_SHOULD_STOP stays set: do_pending
> > sleeps for one full period and the loop then exits. That is
> > kthread_do_pending_ms plus up to 1ms of fuzz, so 3-4ms by
> > default.
>
> Very good. Except that if someone sets a very long sleep time, that
> could result in excessive delay for kthread exit, right? Or am I missing
> a turn in there somewhere?
You are not missing anything: in that case, do_pending sleeps for one
full kthread_do_pending_ms period, however long it is.
> > For comparison, without this patch do_pending leaves its loop at
> > torture_must_stop() and waits in torture_kthread_stopping(), which
> > sleeps in TASK_UNINTERRUPTIBLE for HZ/20 at a time, so it has the
> > same lost-wakeup window with a 50ms bound instead.
>
> But that is a fixed wait, without the possibility of a user extending
> it, correct?
Correct, torture_kthread_stopping() always sleeps for HZ/20 at a time.
[...]
> Should we stop the writer before stopping the readers? Or would that
> open up some other issue?
hazptr_torture_cleanup() already stops the writer before the readers,
and that order is what lets the writer wait on hazard pointers that
readers defer while it is being stopped. If you mean the other way
around, stopping the readers first, I believe that works:
- Stop the readers, then do_pending, then the writer.
- Keep the do_pending loop as it is in -rcu/dev, including the
torture_must_stop() check before the sleep, and move this patch's
final all-CPU pass after torture_kthread_stopping(), so that it
runs once the readers have stopped.
The writer can then still wait in ->sync() on a deferred hazard
pointer, but only until that final pass, and nothing waits on the
writer. The readers do not need the writer to stop: they leave their
loop at torture_must_stop(), after at most one stutter_wait().
With that order, the long sleep above can still happen, but only if
do_pending passed its torture_must_stop() check before the test began
stopping, and had not yet gone to sleep when kthread_stop() came,
after all the readers had stopped.
Would you prefer that? If so, I will rework this patch along those
lines for v1, and rerun the tests.
Thanks,
Andrea
next prev parent reply other threads:[~2026-10-22 12:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 16:20 Andrea Parri
2026-10-19 16:22 ` Bradley Morgan
2026-10-19 17:32 ` Andrea Parri
2026-10-20 18:36 ` Paul E. McKenney
2026-10-20 18:40 ` Bradley Morgan
2026-10-20 18:49 ` Paul E. McKenney
2026-10-21 9:06 ` Andrea Parri
2026-10-21 16:50 ` Paul E. McKenney
2026-10-22 12:55 ` Andrea Parri [this message]
2026-10-22 22:55 ` Paul E. McKenney
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=20261022125556.3559773-1-parri.andrea@gmail.com \
--to=parri.andrea@gmail.com \
--cc=boqun@kernel.org \
--cc=brads@mainlining.org \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=kunwu.chan@gmail.com \
--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=rostedt@goodmis.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®