mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: paulmck@kernel.org
Cc: Boqun Feng <boqun@kernel.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] hazptr: Introduce CONFIG_HAZPTR_DEBUG misuse detection
Date: Tue, 14 Jul 2026 15:16:58 -0400	[thread overview]
Message-ID: <b739a1ae-7788-4e0a-a224-527915fbe049@efficios.com> (raw)
In-Reply-To: <1c9cf8b3-19d9-44b5-ab75-e745d6af48c2@paulmck-laptop>

On 2026-07-11 19:55, Paul E. McKenney wrote:
> On Sat, Jul 11, 2026 at 09:48:18AM -0400, Mathieu Desnoyers wrote:
>> On 2026-07-10 15:07, Paul E. McKenney wrote:
>>>>
>>>> We should really rename this given that it detaches the hazptr ctx from
>>>> the execution _context_ (irq handler or thread). Not sure how to name it
>>>> though.
>>>
>>> hazptr_detach_from_context()?
>>>
>>> I am leaving this alone for the moment, easy to change later.
>>
>> I just wonder if that name brings confusion. Is "context" the
>> execution context or the "hazptr ctx" context ? I fear this is
>> really a good opportunity to confuse everyone.
>>
>> [...]
>>
>>>
>>>> Maybe just call it hazptr_detach() ?
>>>
>>> That would be your choice, not mine.  ;-)
>>
>> I find that hazptr_detach is probably better here. It does not
>> state it detaches "what", but at least there is no shortcut
>> confusion with the overloaded "context" wording.
> 
> Fair enough.
> 
> Would you like me to make this change?

Since you're actively working in that area, please go ahead :)

>>> + */
>>>    static inline
>>>    void hazptr_detach_from_task(struct hazptr_ctx *ctx)
>>>    {
>>> @@ -160,12 +182,26 @@ void hazptr_note_context_switch(void)
>>>    	}
>>>    }
>>> -/*
>>> - * hazptr_acquire: Load pointer at address and protect with hazard pointer.
>>> +/**
>>> + * hazptr_acquire - Load pointer at address and protect with hazard pointer.
>>> + *
>>> + * @ctx: The hazard-pointer context to be passed to hazptr_release().
>>> + * @addr_p: Pointer to the pointer that is to be hazard-pointer protected.
>>>     *
>>>     * Load @addr_p, and protect the loaded pointer with hazard pointer.
>>> - * When using hazptr_acquire from interrupt handlers, the acquired slots
>>> - * need to be released before returning from the interrupt handler.
>>> + * This protection is roughly similar to that of a reference counter, and
>>> + * ends with a later call to hazptr_release().
>>
>> Perhaps worthwhile to hint at the vast performance/scalability/memory
>> footprint/cache line footprint difference between hazptr and refcount
>> to justify why both exist here ?
> 
> Like this?
> 
>   * Load @addr_p, and protect the loaded pointer with hazard pointer.
>   * This protection is roughly similar to (but way faster than) that of a
>   * reference counter, and ends with a later call to hazptr_release()

works for me!

> 
>> AFAIU there is partial overlap between refcount, hazptr, and RCU, each
>> with their own strengths and weaknesses. We should prepare a summary
>> table for the end users wondering which is the right tool for their
>> use-case.
> 
> We have lots of such tables of varying sizes and levels of detail in
> numerous C++ Working Papers, to say nothing of Section 9.6 of perfbook.  ;-)
> 
> One short text distinguishing them is: "RCU is a fast and scalable
> replacement for many reader-writer locking use cases, hazard pointers is
> a fast and scalable replacement for many reference-counting use cases,
> reader-writer locking provides mutual exclusion, and reference counting
> provides instant notice when the counter reaches zero."

lgtm

Thanks!

Mathieu

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

  reply	other threads:[~2026-07-14 19:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 18:29 [PATCH 1/2] hazptrtorture: Fix hazptr ownership issue Mathieu Desnoyers
2026-07-09 18:29 ` [PATCH 2/2] hazptr: Introduce CONFIG_HAZPTR_DEBUG misuse detection Mathieu Desnoyers
2026-07-09 18:47   ` Paul E. McKenney
2026-07-09 18:56     ` Mathieu Desnoyers
2026-07-09 20:44       ` Paul E. McKenney
2026-07-09 21:47         ` Mathieu Desnoyers
2026-07-09 23:05           ` Paul E. McKenney
2026-07-09 23:22             ` Mathieu Desnoyers
2026-07-09 23:48               ` Paul E. McKenney
2026-07-10  0:10                 ` Mathieu Desnoyers
2026-07-10 19:07                   ` Paul E. McKenney
2026-07-11 13:48                     ` Mathieu Desnoyers
2026-07-11 23:55                       ` Paul E. McKenney
2026-07-14 19:16                         ` Mathieu Desnoyers [this message]
2026-07-14 20:54                           ` Paul E. McKenney
2026-07-14 21:06                             ` Mathieu Desnoyers
2026-07-14 21:31                               ` Paul E. McKenney
2026-07-09 23:57               ` Boqun Feng
2026-07-10  0:03                 ` Mathieu Desnoyers
2026-07-09 20:45     ` 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=b739a1ae-7788-4e0a-a224-527915fbe049@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=boqun@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@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®