[PATCH 13/28] hazptr: Add waiter-enqueue tracepoint

From: Kunwu Chan

Date: Wed Nov 04 2026 - 12:04:36 EST


Production tracepoint fired when hazptr_synchronize() enqueues a
waiter onto the scan kthread's pending list. Downstream users
include hazptrtorture's staged hot-address scenario, which uses
it to confirm enqueue before running its controls.

Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
---
include/trace/events/hazptr.h | 29 +++++++++++++++++++++++++++++
kernel/hazptr.c | 5 +++++
2 files changed, 34 insertions(+)
create mode 100644 include/trace/events/hazptr.h

diff --git a/include/trace/events/hazptr.h b/include/trace/events/hazptr.h
new file mode 100644
index 000000000000..1eed4c9fd682
--- /dev/null
+++ b/include/trace/events/hazptr.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hazptr
+
+#if !defined(_TRACE_HAZPTR_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_HAZPTR_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(hazptr_waiter_enqueue,
+
+ TP_PROTO(void *addr),
+
+ TP_ARGS(addr),
+
+ TP_STRUCT__entry(
+ __field(void *, addr)
+ ),
+
+ TP_fast_assign(
+ __entry->addr = addr;
+ ),
+
+ TP_printk("addr=%p", __entry->addr)
+);
+
+#endif /* _TRACE_HAZPTR_H */
+
+#include <trace/define_trace.h>
diff --git a/kernel/hazptr.c b/kernel/hazptr.c
index 4784df78be4e..16f6e2acaf87 100644
--- a/kernel/hazptr.c
+++ b/kernel/hazptr.c
@@ -19,6 +19,10 @@
#include <linux/bitops.h>
#include <linux/bitmap.h>

+#define CREATE_TRACE_POINTS
+#include <trace/events/hazptr.h>
+EXPORT_TRACEPOINT_SYMBOL_GPL(hazptr_waiter_enqueue);
+
#define HAZPTR_WILDCARD ((void *) 1UL)

static DEFINE_MUTEX(hazptr_phase_lock); /* Protect the list phase flip. */
@@ -411,6 +415,7 @@ static void hazptr_synchronize_queued(void *addr)

mutex_lock(&hazptr_scan.lock);
list_add_tail(&waiter.node, &hazptr_scan.pending);
+ trace_hazptr_waiter_enqueue(addr);
if (!READ_ONCE(hazptr_scan.wakeup)) {
WRITE_ONCE(hazptr_scan.wakeup, true);
swake_up_one(&hazptr_scan.wq);
--
2.43.0