Re: [PATCH -rcu/dev 1/4] hazptrtorture: Release all deferred hazard pointers before stopping

From: Andrea Parri

Date: Tue Nov 03 2026 - 14:23:52 EST


On Mon, Nov 02, 2026 at 08:50:51PM -0800, Paul E. McKenney wrote:

[...]

> How about like this?

Works for me, thanks! With it and patches 2-4 on top, two 3-minute
PREEMPT runs with kthread_do_pending_ms=10000, which hung without a fix,
and a 30-minute PREEMPT run end with "End of test: SUCCESS" and with as
many hazard pointers released as were deferred. In one of the
kthread_do_pending_ms=10000 runs, the writer also stays in ->sync() long
enough for a writer-stall report 31 seconds after boot, and moves on by
46 seconds.

The variant from my previous reply, with the pass right after the
reader's loop, passed the same tests, but there is no need for it with
this version, so I will not send a v2.

A few small things below.

[...]

> hazptr_torture_cleanup() stops the kthreads in random order, which

The order is fixed: do_pending, preempt, the writer, then the readers.

> Therefore, make each reader clean up all deferred hazard pointers,
> which means that after the last reader finishes, there can no
> longer be any deferred hazard pointers, which means that the
> writer can terminate promptly.

With the pass after torture_kthread_stopping(), a reader cleans up only
once hazptr_torture_cleanup() stops it, so this also relies on stopping
the readers before the writer. Maybe worth a sentence here?

> hazard poiners.

s/poiners/pointers/

> from the pending lists as were deferred (reldefer: 983727 relundefer
> 983727).

These numbers come from v1's patch; with this version, the 30-minute
PREEMPT run gives reldefer: 657653 relundefer 657653.

[...]

> + /*
> + * Stop the writer only after do_pending, and do_pending only after
> + * the readers: the writer may be waiting on hazard pointers that
> + * readers deferred, which do_pending releases once they stopped.
> + */

do_pending no longer releases them; the readers do. Perhaps:

/*
* Stop the writer only after the readers: the writer may be
* waiting on hazard pointers that readers deferred, which each
* reader releases once it is stopped.
*/

Also, "hazptrtorture: Nest a second hazard pointer in readers" conflicts
with moving hazptr_torture_do_one_pending() up, as both add a function
after hazptr_torture_defer(); keeping both resolves it.

Thanks,
Andrea