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: Thu, 9 Jul 2026 14:56:15 -0400 [thread overview]
Message-ID: <55079bd3-b049-4e0f-9225-ad41e3562500@efficios.com> (raw)
In-Reply-To: <2402b90a-7f26-4ef8-b5ff-b3c92d1be9d0@paulmck-laptop>
On 2026-07-09 14:47, Paul E. McKenney wrote:
> On Thu, Jul 09, 2026 at 02:29:33PM -0400, Mathieu Desnoyers wrote:
>> Introduce Hazard Pointers debug assert, which detects misuse of hazard
>> pointers, namely failure to detach the hazard pointer from its owner
>> thread before releasing it from a different thread.
>>
>> Prints the following to the console when a failure is detected:
>
> Thank you, Mathieu!
>
> I am testing this one first to verify the debugging, and then I will
> test the patch 1/2 hazptrtorture.c changes to verify the fix.
>
> We are going to need to carefully document the hazard-pointer handling
> rules! ;-)
Good point!
So the general rule for the hazptr API is that the hazptr context
is attached to the task that does the hazptr acquire.
The scheduler integration is responsible for ensuring that the
hazptr context is moved to a backup slot in case of context switch,
which takes care of handling task migrations without user intervention.
The case for which the user needs to explicitly invoke "detach from
task" is when the hazptr context is handed off to a _different_ task.
In that case the scheduler really cannot help, so it needs to be
done explicitly.
The debug code I proposed here discovers two scenarios:
- Release vs acquire are done on different tasks without explicit detach
from task (user error),
- Release vs acquire are done on different CPUs, without scheduler
context switch in between. This could happen if the user has
a confused hazptr context ownership model.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2026-07-09 18:56 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 [this message]
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
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=55079bd3-b049-4e0f-9225-ad41e3562500@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®