Re: [PATCH hazptr 4/4] hazptr: Introduce "try acquire" fast path, fallback to overflow list

From: Gary Guo

Date: Tue Oct 06 2026 - 04:05:01 EST


On Sun Sep 27, 2026 at 5:51 PM CEST, Mathieu Desnoyers wrote:
> Introduce a "try acquire" hazard pointer fast path, which performs an
> early load of the address to store it into the hazard pointer slot, and
> then re-loads that address after a barrier to check whether it has
> changed meanwhile.
>
> On comparison failure, rather than re-try, guarantee forward progress by
> falling back to the __hazptr_acquire slow path on failure.
>
> The acquire slow path attempts a try-acquire for any available per-CPU
> slot. If that fails, it chains the backup slot into the overflow list,
> therefore guaranteeing forward progress for both hazard pointer
> read-side and synchronize:
>
> - Readers set the wildcard, and then proceed to set the more
> specific address to replace the wildcard.
>
> - One synchronize alternates between two overflow list periods,
> scanning each one while readers are added to the other period,
> thus preventing a steady flow of readers from preventing
> synchronize forward progress.
>
> With this change, the scan on per-CPU slots don't need to expect a
> wildcard anymore, because none can be produced by readers. Wildcards are
> only expected within overflow lists.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

Suggested-by: Gary Guo <gary@xxxxxxxxxxx>
Link: https://lore.kernel.org/lkmm/DLK9MW1N86KD.2GRWUAD2NX4FU@xxxxxxxxxxx/
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>

> Cc: Paul E. McKenney <paulmck@xxxxxxxxxx>
> Cc: Boqun Feng <boqun@xxxxxxxxxx>
> Cc: Bradley Morgan <brads@xxxxxxxxxxxxxx>
> Cc: Gary Guo <gary@xxxxxxxxxxx>
> Cc: <rcu@xxxxxxxxxxxxxxx>
> Cc: <lkmm@xxxxxxxxxxxxxxx>
> ---
> include/linux/hazptr.h | 47 +++++++++++--------
> kernel/hazptr.c | 103 ++++++++++++++++++++---------------------
> 2 files changed, 76 insertions(+), 74 deletions(-)