[PATCH 1/2] hazptrtorture: Fix hazptr ownership issue
From: Mathieu Desnoyers
Date: Thu Jul 09 2026 - 14:30:28 EST
hazptr_torture_acquire is invoked from IPI on remote CPUs. It needs to
immediately detach the hazptr from its local task so it can be released
from other tasks.
Without this fix, the hazptrtorture test fails loudly with a OOPS. It
passes with the fix applied.
[ This applies on top of linux-rcu dev branch at
commit e5ee2ea2d00ae5a0ca53ccf9c9100f2357e1bd08 ]
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
---
kernel/rcu/hazptrtorture.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/kernel/rcu/hazptrtorture.c b/kernel/rcu/hazptrtorture.c
index 5e7cb594f9e0..4507d0f09b8c 100644
--- a/kernel/rcu/hazptrtorture.c
+++ b/kernel/rcu/hazptrtorture.c
@@ -370,6 +370,11 @@ static void hazptr_torture_acquire(void *hppp_in)
struct hazptr_pending *hppp = hppp_in;
hppp->hpp_htp = cur_ops->readlock(&hppp->hpp_hc);
+ /*
+ * Acquiring a hazard pointer from a remote CPU.
+ * Detach hazptr from its task so it can be released by another task.
+ */
+ hazptr_detach_from_task(&hppp->hpp_hc);
atomic_long_inc(per_cpu_ptr(&hazptr_torture_acquires_irq, raw_smp_processor_id()));
}
@@ -411,6 +416,10 @@ hazptr_torture_reader_tail(struct hazptr_pending *hppp, struct torture_random_st
preempt_enable();
if (irq_release && !(torture_random(trsp) % irq_release)) {
guard(preempt)();
+ /*
+ * Handling release from a remote CPU.
+ * Detach hazptr from its task so it can be released by another task.
+ */
hazptr_detach_from_task(&hppp->hpp_hc);
cpu = cpumask_next_wrap(smp_processor_id(), cpu_online_mask);
smp_call_function_single(cpu, hazptr_torture_release, hppp, 1);
@@ -428,8 +437,11 @@ static void hazptr_torture_defer(struct hazptr_pending *hppp, struct torture_ran
int cpu = torture_random(trsp) % nr_cpu_ids;
struct llist_head *llhp;
- hazptr_detach_from_task(&hppp->hpp_hc);
guard(preempt)();
+ /*
+ * Handling release from a remote CPU.
+ * Detach hazptr from its task so it can be released by another task.
+ */
hazptr_detach_from_task(&hppp->hpp_hc);
cpu = cpumask_next_wrap(cpu, cpu_online_mask);
llhp = per_cpu_ptr(&hazptr_pending, cpu);
--
2.43.0