[PATCH] tracing: Wait for marker writers when copy_trace_marker is cleared
From: Pengfei Li
Date: Sat Nov 07 2026 - 06:17:36 EST
Clearing copy_trace_marker removes the instance from marker_copies
without waiting for trace_marker writers still walking the list. If the
option is set again right away, a writer on that entry can revisit
instances and write the same marker twice.
Fixes: 7b382efd5e8a ("tracing: Allow the top level trace_marker to write into another instances")
Assisted-by: LLM
Signed-off-by: Pengfei Li <lipengfei28@xxxxxxxxxx>
---
kernel/trace/trace.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 18710c190c92..b0357f1b5a69 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4016,7 +4016,9 @@ int set_tracer_flag(struct trace_array *tr, u64 mask, int enabled)
break;
case TRACE_ITER(COPY_MARKER):
- update_marker_trace(tr, enabled);
+ /* Writers of the top level trace_marker may still be on this instance */
+ if (update_marker_trace(tr, enabled) && !enabled)
+ synchronize_rcu();
/* update_marker_trace updates the tr->trace_flags */
return 0;
}
base-commit: 4539944e515183668109bdf4d0c3d7d228383d88
--
2.34.1