On Sat, 03 Dec 2022 12:20:15 +0100 <gregkh@xxxxxxxxxxxxxxxxxxx> wrote: > The patch below does not apply to the 4.19-stable tree. > If someone wants it applied there, or to any other stable or longterm > tree, then please email the backport, including the original git commit > id to <stable@xxxxxxxxxxxxxxx>. > > Possible dependencies: > > 4313e5a61304 ("tracing: Free buffers when a used dynamic event is removed") Hmm, isn't the above the patch that failed to apply? > 5448d44c3855 ("tracing: Add unified dynamic event framework") And this is mentioned below. [..] > If any dynamic event that is being removed was enabled, then make sure the > buffers they were enabled in are now cleared. > > Link: https://lkml.kernel.org/r/20221123171434.545706e3@xxxxxxxxxxxxxxxxxx > Link: https://lore.kernel.org/all/20221110020319.1259291-1-zhengyejian1@xxxxxxxxxx/ > > Cc: stable@xxxxxxxxxxxxxxx > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Depends-on: e18eb8783ec49 ("tracing: Add tracing_reset_all_online_cpus_unlocked() function") > Depends-on: 5448d44c38557 ("tracing: Add unified dynamic event framework") ^^^ -- Steve > Depends-on: 6212dd29683ee ("tracing/kprobes: Use dyn_event framework for kprobe events") > Depends-on: 065e63f951432 ("tracing: Only have rmmod clear buffers that its events were active in") > Depends-on: 575380da8b469 ("tracing: Only clear trace buffer on module unload if event was traced") > Fixes: 77b44d1b7c283 ("tracing/kprobes: Rename Kprobe-tracer to kprobe-event") > Reported-by: Zheng Yejian <zhengyejian1@xxxxxxxxxx> > Reported-by: Yujie Liu <yujie.liu@xxxxxxxxx> > Reported-by: kernel test robot <yujie.liu@xxxxxxxxx> > Acked-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> > Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> > > diff --git a/kernel/trace/trace_dynevent.c b/kernel/trace/trace_dynevent.c > index 154996684fb5..4376887e0d8a 100644 > --- a/kernel/trace/trace_dynevent.c > +++ b/kernel/trace/trace_dynevent.c > @@ -118,6 +118,7 @@ int dyn_event_release(const char *raw_command, struct dyn_event_operations *type > if (ret) > break; > } > + tracing_reset_all_online_cpus(); > mutex_unlock(&event_mutex); > out: > argv_free(argv); > @@ -214,6 +215,7 @@ int dyn_events_release_all(struct dyn_event_operations *type) > break; > } > out: > + tracing_reset_all_online_cpus(); > mutex_unlock(&event_mutex); > > return ret; > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c > index 78cd19e31dba..f71ea6e79b3c 100644 > --- a/kernel/trace/trace_events.c > +++ b/kernel/trace/trace_events.c > @@ -2880,7 +2880,10 @@ static int probe_remove_event_call(struct trace_event_call *call) > * TRACE_REG_UNREGISTER. > */ > if (file->flags & EVENT_FILE_FL_ENABLED) > - return -EBUSY; > + goto busy; > + > + if (file->flags & EVENT_FILE_FL_WAS_ENABLED) > + tr->clear_trace = true; > /* > * The do_for_each_event_file_safe() is > * a double loop. After finding the call for this > @@ -2893,6 +2896,12 @@ static int probe_remove_event_call(struct trace_event_call *call) > __trace_remove_event_call(call); > > return 0; > + busy: > + /* No need to clear the trace now */ > + list_for_each_entry(tr, &ftrace_trace_arrays, list) { > + tr->clear_trace = false; > + } > + return -EBUSY; > } > > /* Remove an event_call */