tracing: Wait for marker writers when copy_trace_marker is cleared
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
Signed-off-by Pengfei Li <[email protected]>
--- kernel/trace/trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace.c +3 -1
@@ -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
Quoted 8 lines · Pengfei Li
Clearing
copy_trace_markerremoves the instance frommarker_copieswithout waiting fortrace_markerwriters 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 LLMSigned-off-by Pengfei Li <[email protected]>
Looks good to me.
Reviewed-by Masami Hiramatsu (Google) <[email protected]>
Thanks,
Quoted 25 lines
--- kernel/trace/trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/trace/trace.c +3
-1@@ -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:
4539944e515183668109bdf4d0c3d7d228383d88Signature · 1 line
2.34.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>