Skip to content

Commit 824c833

Browse files
tracing: tprobe-events: Fix to clean up tprobe correctly when module unload
JIRA: https://issues.redhat.com/browse/RHEL-86682 commit 0a8bb68 Author: Masami Hiramatsu (Google) <mhiramat@kernel.org> Date: Mon Mar 10 15:14:09 2025 +0900 tracing: tprobe-events: Fix to clean up tprobe correctly when module unload When unloading module, the tprobe events are not correctly cleaned up. Thus it becomes `fprobe-event` and never be enabled again even if loading the same module again. For example; # cd /sys/kernel/tracing # modprobe trace_events_sample # echo 't:my_tprobe foo_bar' >> dynamic_events # cat dynamic_events t:tracepoints/my_tprobe foo_bar # rmmod trace_events_sample # cat dynamic_events f:tracepoints/my_tprobe foo_bar As you can see, the second time my_tprobe starts with 'f' instead of 't'. This unregisters the fprobe and tracepoint callback when module is unloaded but marks the fprobe-event is tprobe-event. Link: https://lore.kernel.org/all/174158724946.189309.15826571379395619524.stgit@mhiramat.tok.corp.google.com/ Fixes: 57a7e6d ("tracing/fprobe: Support raw tracepoints on future loaded modules") Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
1 parent 11ac9b3 commit 824c833

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

kernel/trace/trace_fprobe.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -977,10 +977,13 @@ static int __tracepoint_probe_module_cb(struct notifier_block *self,
977977
reenable_trace_fprobe(tf);
978978
}
979979
} else if (val == MODULE_STATE_GOING && tp_mod->mod == tf->mod) {
980-
tracepoint_probe_unregister(tf->tpoint,
980+
unregister_fprobe(&tf->fp);
981+
if (trace_fprobe_is_tracepoint(tf)) {
982+
tracepoint_probe_unregister(tf->tpoint,
981983
tf->tpoint->probestub, NULL);
982-
tf->tpoint = NULL;
983-
tf->mod = NULL;
984+
tf->tpoint = TRACEPOINT_STUB;
985+
tf->mod = NULL;
986+
}
984987
}
985988
}
986989
mutex_unlock(&event_mutex);

0 commit comments

Comments
 (0)