From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: paulmck@kernel.org
Cc: Boqun Feng <boqun.feng@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v5 1/2] hazptr: Implement Hazard Pointers
Date: Wed, 8 Jul 2026 22:45:23 -0400 [thread overview]
Message-ID: <68bb6ee9-d28b-4a1c-b5fe-578591a5f85d@efficios.com> (raw)
In-Reply-To: <f7c2c3b6-88a2-4e4f-b595-370a3c79b8c8@paulmck-laptop>
On 2026-07-08 18:55, Paul E. McKenney wrote:
[...]
> OK, I did check, and all of the hazptr_torture_do_pending() function's
> hazard pointers have been passed to hazptr_detach_from_task().
>
> But sometimes a given hazard pointer might be passed to
> hazptr_detach_from_task() twice, once just before that llist_add(),
> and again if hazptr_torture_reader_tail() decides to release that hazard
> pointer via smp_call_function_single().
>
> Do I instead need to be careful to avoid detaching a given hazard pointer
> more than once?
That should be OK to call the "detach" more than once, because it checks
if the hazptr is already detached with:
+ if (unlikely(hazptr_slot_is_backup(ctx, slot)))
+ return;
(while under preempt off)
My concern is about this worker thread:
static int hazptr_torture_do_pending(void *arg)
{
int cpu = 0;
DEFINE_TORTURE_RANDOM(rand);
VERBOSE_TOROUT_STRING("hazptr_torture_do_pending task started");
do {
if (stutter_will_wait()) {
for_each_possible_cpu(cpu)
hazptr_torture_do_one_pending(cpu, &rand);
} else {
cpu = cpumask_next_wrap(cpu, cpu_possible_mask);
hazptr_torture_do_one_pending(cpu, &rand);
}
if (torture_must_stop())
torture_hrtimeout_ms(kthread_do_pending_ms, USEC_PER_MSEC, &rand);
// Omit stutter_wait() because this function needs to do cleanup.
} while (!torture_must_stop());
torture_kthread_stopping("hazptr_torture_do_pending");
return 0;
}
which as you will notice happily invoke "do_one_pending" on either
all possible cpus or on a next cpu (non-local), which does:
llhp = per_cpu_ptr(&hazptr_pending, cpu);
llnp = llist_del_all(llhp);
if (!llnp)
return;
llist_for_each_entry_safe(hppp, hppp1, llnp, hpp_node) {
hazptr_torture_reader_tail(hppp, trsp);
atomic_long_inc(per_cpu_ptr(&hazptr_torture_releases_undefer,
raw_smp_processor_id()));
kfree(hppp);
}
And here the reader_tail calls cur_ops->readunlock(hcp, htp); which
does a hazptr_release from the wrong CPU without previously detaching
the hazptr from its associated thread as it should.
Does this line of thinking make sense ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2026-07-09 2:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 20:44 [RFC PATCH v5 0/2] " Mathieu Desnoyers
2026-02-23 20:44 ` [RFC PATCH v5 1/2] hazptr: Implement " Mathieu Desnoyers
2026-06-26 23:06 ` Paul E. McKenney
2026-06-27 3:56 ` Mathieu Desnoyers
2026-06-27 4:14 ` Paul E. McKenney
2026-06-27 12:56 ` Mathieu Desnoyers
2026-06-27 15:21 ` Mathieu Desnoyers
2026-06-27 17:36 ` Paul E. McKenney
2026-07-07 19:40 ` Mathieu Desnoyers
2026-07-07 21:42 ` Paul E. McKenney
2026-07-08 22:55 ` Paul E. McKenney
2026-07-09 2:45 ` Mathieu Desnoyers [this message]
2026-07-09 3:28 ` Paul E. McKenney
2026-07-09 16:02 ` Paul E. McKenney
2026-07-09 16:03 ` Mathieu Desnoyers
2026-07-09 16:06 ` Paul E. McKenney
2026-02-23 20:44 ` [RFC PATCH v5 2/2] hazptr: Add refscale test Mathieu Desnoyers
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=68bb6ee9-d28b-4a1c-b5fe-578591a5f85d@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=boqun.feng@gmail.com \
--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