mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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: Fri, 23 Oct 2026 14:07:54 +0200	[thread overview]
Message-ID: <20261023120755.2463384-1-parri.andrea@gmail.com> (raw)
In-Reply-To: <579683e2-ee2a-46e8-8bf3-f7ecc5547581@paulmck-laptop>

On Thu, Oct 22, 2026 at 03:55:44PM -0700, Paul E. McKenney wrote:
> On Thu, Oct 22, 2026 at 02:55:55PM +0200, Andrea Parri wrote:

[...]

> Then let's please keep the torture_must_stop() check.  Yes, there is
> still a window between the return from torture_must_stop() and the
> call to torture_hrtimeout_ms(), but maybe that is something to take
> care of later on.

Will do.

[...]

> Yes, agreed, almost:
>
> o	Keep the hazptr_torture_do_pending() do-while loop as it
> 	is, but add the for_each_possible_cpu() after loop exit.
>
> o	Stop the readers first, stop hazptr_torture_do_pending()
> 	to flush out anything left from the readers, then stop
> 	the writer.
>
> However, for the "almost", note that the "while (!torture_must_stop())"
> needs to become "while (!kthread_should_stop())".  If this change is
> not made, then hazptr_torture_do_pending() will exit its do-while loop
> as soon as hazptr_torture_cleanup() calls torture_cleanup_begin().
> This will of course defeat the reordering.
>
> Does that work, or am I still missing something?

do_pending does leave the loop then, but the final pass goes after
torture_kthread_stopping(), not right after the loop:

	} while (!torture_must_stop());
	torture_kthread_stopping("hazptr_torture_do_pending");
	/* The readers have stopped, so nothing new can be deferred. */
	for_each_possible_cpu(cpu)
		hazptr_torture_do_one_pending(cpu, &rand);
	return 0;

torture_kthread_stopping() sleeps HZ/20 at a time until
kthread_should_stop(), so the pass runs only once
hazptr_torture_cleanup() stops do_pending, after the readers.

With "while (!kthread_should_stop())" and the torture_must_stop()
check before the sleep, do_pending would instead spin without sleeping
from torture_cleanup_begin() until it is stopped.

> Alternatively, you could keep the current do-while condition and place
> a loop around your post-do-while code like this:
>
> 	while (!kthread_should_stop())
> 		for_each_possible_cpu(cpu)
> 			hazptr_torture_do_one_pending(cpu, &rand);
>
> But changing the do-while condition looks cleaner to me.

That loop would spin too.

> This code will also need adjustment when something like a call_hazptr()
> is added, presumably along with a hazptr_barrier(), but we can worry
> about that when it happens.

Agreed.

I have been running this version locally, with the rest of v1: a
30-minute PREEMPT run, and a 30-minute NOPREEMPT run with
torture_type=hazptr, pass.  With kthread_do_pending_ms=10000, the
shutdown still takes less than 150ms.  If it works for you, v1 will
have it.

Thanks,
  Andrea

      reply	other threads:[~2026-10-23 12:08 UTC|newest]

Thread overview: 11+ 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
2026-10-22 22:55         ` Paul E. McKenney
2026-10-23 12:07           ` Andrea Parri [this message]

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=20261023120755.2463384-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®