Commit b8121b9c authored by sunliming's avatar sunliming Committed by Masami Hiramatsu (Google)
Browse files

tracing: kprobe-event: Return directly when trace kprobes is empty

In enable_boot_kprobe_events(), it returns directly when trace kprobes is
empty, thereby reducing the function's execution time. This function may
otherwise wait for the event_mutex lock for tens of milliseconds on certain
machines, which is unnecessary when trace kprobes is empty.

Link: https://lore.kernel.org/all/20260127053848.108473-1-sunliming@linux.dev/



Signed-off-by: default avatarsunliming <sunliming@kylinos.cn>
Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
parent f76d1c41
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ static struct trace_kprobe *to_trace_kprobe(struct dyn_event *ev)
#define for_each_trace_kprobe(pos, dpos)	\
	for_each_dyn_event(dpos)		\
		if (is_trace_kprobe(dpos) && (pos = to_trace_kprobe(dpos)))
#define trace_kprobe_list_empty() list_empty(&dyn_event_list)

static nokprobe_inline bool trace_kprobe_is_return(struct trace_kprobe *tk)
{
@@ -1982,6 +1983,9 @@ static __init void enable_boot_kprobe_events(void)
	struct trace_kprobe *tk;
	struct dyn_event *pos;

	if (trace_kprobe_list_empty())
		return;

	guard(mutex)(&event_mutex);
	for_each_trace_kprobe(tk, pos) {
		list_for_each_entry(file, &tr->events, list)