Skip to contentSkip to conversation

tracing: Wait for marker writers when copy_trace_marker is cleared

PATCH In review Pengfei Li 2 participants 2 messages Nov 7 Tracing

lore
Share & tools
lore

Pengfei Li

author
#0 lore raw

PATCH 1/1 tracing: Wait for marker writers when copy_trace_marker is cleared

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
---
 kernel/trace/trace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace.c +3 -1
index 18710c190c92..b0357f1b5a69 100644
@@ -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

Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Pengfei Li

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

Looks good to me.

Thanks,

Quoted 25 lines
---
 kernel/trace/trace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace.c +3 -1
index 18710c190c92..b0357f1b5a69 100644
@@ -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

Signature · 1 line
2.34.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>