From nobody Sat Feb 7 11:52:37 2026 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95464191F98 for ; Tue, 27 Jan 2026 05:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769492396; cv=none; b=eQsCfHmpU/3xB0KmAuTaby4e0FbqZPBxxHT4+Dz0A1qw+GELlx1JFHHmSYAS0fbYQr2mrKUbhAyGrywpfMI5LZu0qKlRRMx1LOx4dfSJs6K0ntOvbTYd2Q2OGDSmhpuCLj+bQha1NWXmbj4K/fEKKrgC06lptk/BW+ebl81ZL7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769492396; c=relaxed/simple; bh=qfou8ULj+m4l7j190/CEAYVfPTCQPL3uKczrWOPclKA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mNKs2qZ6t8ViZzGIvXZ9g6BUYcP9faaE+Qqo0rrGEH2mLm32FMpo82ztPWmluDUknRQ8PWdYdEa6CEANNKMwIE7hH/PJ5TT+h7Y1oSN90gw1v5DP7IXwpUNU3/IIZC07txJUmu7CtylpFlLG8xiYMiVefYekweDYVv3YuhmeH3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ma6mC5YB; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ma6mC5YB" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1769492382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CRsyKsTEWsn2PzWUB/t8s6VSNDnrUc/YcsOZrnmr/X0=; b=ma6mC5YBkTpH+UQoD0oQsP+tD6wkgB69Fd9HUVJ//+jWt9jZ4fTEYGVCG2bsnjC4ROgAde 9EaHA7zGFV5wWZnxNM3acZ0QHmP62xbA8mfJbmdKRpOr93/Y7HiS0GoXdtvKviMFvHmq5U m729V3TCiTUWXbtwhG4rxHsTv7rUz3k= From: sunliming@linux.dev To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, sunliming Subject: [PATCH v2] tracing: kprobe-event: Return directly when trace kprobes is empty Date: Tue, 27 Jan 2026 13:38:48 +0800 Message-Id: <20260127053848.108473-1-sunliming@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: sunliming 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. Signed-off-by: sunliming --- v2: - wrap the the null check for the dyn_event_list with macro trace_kprobe_li= st_empty --- kernel/trace/trace_kprobe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 9953506370a5..95f2c42603d5 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -82,6 +82,7 @@ static struct trace_kprobe *to_trace_kprobe(struct dyn_ev= ent *ev) #define for_each_trace_kprobe(pos, dpos) \ for_each_dyn_event(dpos) \ if (is_trace_kprobe(dpos) && (pos =3D to_trace_kprobe(dpos))) +#define trace_kprobe_list_empty() list_empty(&dyn_event_list) =20 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; =20 + if (trace_kprobe_list_empty()) + return; + guard(mutex)(&event_mutex); for_each_trace_kprobe(tk, pos) { list_for_each_entry(file, &tr->events, list) --=20 2.25.1