mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Bradley Morgan <brads@mainlining.org>,
	"Paul E . McKenney" <paulmck@kernel.org>
Cc: linux-kernel@vger.kernel.org, Boqun Feng <boqun@kernel.org>,
	Gary Guo <gary@garyguo.net>,
	rcu@vger.kernel.org, lkmm@lists.linux.dev
Subject: Re: [PATCH hazptr 0/4] Hazard pointer updates
Date: Sun, 27 Sep 2026 12:45:10 -0400	[thread overview]
Message-ID: <5169602d-c0ac-4b5b-841c-7cc4a3c54274@efficios.com> (raw)
In-Reply-To: <1357947A-5850-4F73-B22E-2AE8B5CAABE2@mainlining.org>

On 2026-09-27 12:33, Bradley Morgan wrote:
> On 27 September 2026 17:27:33 BST, Mathieu Desnoyers
> <mathieu.desnoyers@efficios.com> wrote:
>> On 2026-09-27 12:07, Bradley Morgan wrote:
>>> On 27 September 2026 16:51:27 BST, Mathieu Desnoyers
>>> <mathieu.desnoyers@efficios.com> wrote:
>>>> Hi Paul,
>>>>
>>>> This series applies on top of "hazptr: handle NULL address in
>>>> hazptr_detach" you have in your rcu dev tree.
>>>>
>>>> This first patch addresses a race identified by Boqun Feng in the
>>>> two-phase wildcard scheme.
>>>>
>>>> Patches 2-3 are prerequisites for using ptr_eq() in the 4th patch.
>>>> Those were discussed at length in a prior version of hazard pointer
>>>> patches.
>>>>
>>>> Patch 4 introduces a "try acquire" helper to allow the fast path
>>>> to not rely on wildcards, while keeping the wildcard forward
>>>> progress guarantees in the acquire slow path, used on fast path
>>>> failure.
>>>
>>> Hi, here is a hazptr perf test on powerpc
>>>
>>> REAL kill_fasync(), ns per call, best of 3, 100k calls:
>>> (stock = rwlock walk, conv = hazptr walk, same v3 tree ± the conversion)
>>>
>>>     shape          stock    conv     delta
>>>     1 node,  1 walker     59      59     +0.0%   (singleton: identical)
>>>     16 nodes, 1 walker   539     539     +0.0%   (uncontended: identical)
>>>     16 nodes, 4 walkers  509     134    -73.7%   ← rwlock readers contend
>>>     16 nodes, 8 walkers  313     113    -63.9%   ← same list, 8 cpus
>>>     64 nodes, 1 walker  1979    2039     +3.0%   (pure walk: hazptr tax)
>>>     64 nodes, 4 walkers 1914     509    -73.4%
>>>     64 nodes, 8 walkers 1015     382    -62.4%
>>>
>>> Its SLOWER than rcu, but beats rwlock
>>
>> Two feedback points:
>>
>> 1) The comparison I think Boqun cares mostly about is with expedited
>>    RCU grace periods, this is where we suspect there is a significant
>>    benefit to using hazptr rather than RCU to eliminate those IPIs
>>    on synchronize.
>>
>>    It's good to know that it performs better than rwlock (albeit it's
>>    not surprising).
>>
>> 2) I'm concerned about what looks like a use of hazptr to protect linked
>>    lists elements in your benchmark (did I miss anything ?).
>>
>>    RCU read-side critical sections protect all elements of a linked list
>>    naturally, but hazptr requires more care. See this comment above
>>    hazptr_acquire:
>>
>> * This protection is unconditional, and has limitations similar to
>> * that of unconditional reference-counter acquisition.  In particular,
>> * although holding a hazard pointer prevents a hazard-pointer-protected
>> * object from being freed, it does not prevent that object from being
>> * removed from a linked data structure, and does not prevent other
>> * hazard-pointer-protected objects referenced by this object from being
>> * both removed and freed.  At which point, invoking hazptr_acquire()
>> * on these dangling pointers would be a bug.  On the other hand, use of
>> * hazptr_acquire() is safe for immortal pointers to objects that do not
>> * themselves contain pointers to hazard-pointer-protected objects.
>> * Other (more complex) use cases are also possible.
>>
>> Does the pointer you protect qualify as an "immortal" pointer, or it's
>> a linked list "next" pointer ?
>>
> 
> Hmm. Do you have a idea on what you could metaphorically convert, with a
> core subsystem?
> 
> I'll give anything you want me to do a try
At a high level, I suspect it would be good to start by digging into
users of synchronize_rcu_expedited(), to see if a few of those may be
good candidates.

I would also favor scenarios where RCU (or locking) are used to protect
the existence of an object reachable from a global pointer, and use
hazptr to protect that object. Note that initially this precludes
a hazptr-protected list, because the next pointers would sit in
prior objects which are themselves hazptr-protected, which is not
sufficient to guarantee existence against a hand in hand traversal.

However, if you have a pointer to an object "side-car" structure
(e.g. optional extra metadata), and the object containing the pointer
is guaranteed to exist by another mechanism (e.g. RCU, locking), then
that pointer-to-side-car-object field would be a good candidate for
hazptr (AFAIU).

I'm not saying the linked lists could not be done, but it would require
more care.

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

  reply	other threads:[~2026-09-27 16:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 15:51 Mathieu Desnoyers
2026-09-27 15:51 ` [PATCH hazptr 1/4] hazptr: Fix two-phase hazptr_synchronize race with detach Mathieu Desnoyers
2026-09-27 15:51 ` [PATCH hazptr 2/4] compiler.h: Introduce ptr_eq() to preserve address dependency Mathieu Desnoyers
2026-09-27 15:51 ` [PATCH hazptr 3/4] Documentation: RCU: Refer to ptr_eq() Mathieu Desnoyers
2026-09-27 15:51 ` [PATCH hazptr 4/4] hazptr: Introduce "try acquire" fast path, fallback to overflow list Mathieu Desnoyers
2026-09-27 16:40   ` Boqun Feng
2026-09-27 17:15     ` Mathieu Desnoyers
2026-09-27 17:24       ` Boqun Feng
2026-09-27 17:36         ` Mathieu Desnoyers
2026-09-27 18:16           ` Boqun Feng
2026-09-27 17:26       ` Boqun Feng
2026-09-27 22:39       ` Gary Guo
2026-09-28  9:12         ` Boqun Feng
2026-09-28 11:32           ` Gary Guo
2026-09-28 14:56             ` Bradley Morgan
2026-09-28 15:32             ` Boqun Feng
2026-09-28  9:27     ` Kunwu Chan
2026-09-27 16:07 ` [PATCH hazptr 0/4] Hazard pointer updates Bradley Morgan
2026-09-27 16:27   ` Mathieu Desnoyers
2026-09-27 16:33     ` Bradley Morgan
2026-09-27 16:45       ` Mathieu Desnoyers [this message]
2026-09-27 16:15 ` Boqun Feng
2026-09-27 16:20   ` Mathieu Desnoyers
2026-09-27 16:22     ` Bradley Morgan

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=5169602d-c0ac-4b5b-841c-7cc4a3c54274@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=boqun@kernel.org \
    --cc=brads@mainlining.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkmm@lists.linux.dev \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    /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®