Skip to content

Commit b8121b9

Browse files
sunlimingmhiramat
authored andcommitted
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: sunliming <sunliming@kylinos.cn> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
1 parent f76d1c4 commit b8121b9

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

kernel/trace/trace_kprobe.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static struct trace_kprobe *to_trace_kprobe(struct dyn_event *ev)
8282
#define for_each_trace_kprobe(pos, dpos) \
8383
for_each_dyn_event(dpos) \
8484
if (is_trace_kprobe(dpos) && (pos = to_trace_kprobe(dpos)))
85+
#define trace_kprobe_list_empty() list_empty(&dyn_event_list)
8586

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

1986+
if (trace_kprobe_list_empty())
1987+
return;
1988+
19851989
guard(mutex)(&event_mutex);
19861990
for_each_trace_kprobe(tk, pos) {
19871991
list_for_each_entry(file, &tr->events, list)

0 commit comments

Comments
 (0)