From nobody Tue Sep 29 02:02:25 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 74DCE47AF42; Thu, 13 Aug 2026 14:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630048; cv=none; b=llKjdKUznlDSkuo1tKmqj7fF9wQ/o3V63zcFgtIdvJkQYFIIPINNfvV7HzMmF6KlLpml2BH5gKI7z4+I1KB30ig/hwZ2CLgoMEJ2Xra7X5sIb4xmvb6ErlEk/BJ8PLBzAW5S6qq/dBSzkSTAg3MKZjwI3iv99Ef3I0d7la5rzZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630048; c=relaxed/simple; bh=Fqn7isJpEy0tNbhyXRMm4QBjNlNd33jIQfGv6bPhvm0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fn+C7i8yGsIViWRuwURcp4Uycfvlzw3fbeJ28zdfcv+h0zrg28Ff9r98Kkauno3HG8OGFBggKBsZZGX4o3bKlD+usp1KpYPPZkp12iheVYyK5Nvfa6EdPWxlM5/PIVqQ4kphXGSFcPqFPQ8WfcCDzWl599S0sSk4DX2GkStLKWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4vIVPM7y; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=23F0YiM+; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4vIVPM7y"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="23F0YiM+" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786630045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RYsiGRJ5VRa0CWly24xrYp0uLMoS4M867617Q5RPOd8=; b=4vIVPM7y+jTmy+v5FdOb9VUTZD3X9/rQHQTDm+YaDc0Bn6iUGZ6dGqZo7EmTkSbU06y9w5 bFverpNxVgzPA6Gdk5jxFsIhUVSqkvEt/ijLOYazmej4K+zoIyhmtLbHDBwEzw4qBnjdpl R/mYaCSm4l0S/vhaOqaORZu9BcG7CP0Ko0cBrhKxY3pTYQb5M9fJOtvXZvFYVGMeD0gNUK fmyVjNkruxN/O04/76sjwHvqtOhFxKitMJfJY7HMNZg8I0Nb5NeO9Ehq8t86j5FJiR7Kyb mB0WRkDd6l1gkVVQlNOhViBD49X5nnpzX/g8Pi6qYHkg/MBWmb7m7AT+Wtolsw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786630045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RYsiGRJ5VRa0CWly24xrYp0uLMoS4M867617Q5RPOd8=; b=23F0YiM+UFGTWMqvDts1olu8gPZXmm76ToYd7IU9GBV/qIEZyd0K0pXhuGrLcljsvItmSQ 308RHgJJle0f1SAg== Date: Thu, 13 Aug 2026 16:07:14 +0200 Subject: [PATCH RFC 1/7] tracing: Restore :mod: trailer after parsing in ftrace_set_clr_event() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-tracing-cli-event-filter-v1-1-57c4e8029c86@linutronix.de> References: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> In-Reply-To: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , stable@vger.kernel.org X-Developer-Signature: v=1; a=ed25519-sha256; t=1786630039; l=1066; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=Fqn7isJpEy0tNbhyXRMm4QBjNlNd33jIQfGv6bPhvm0=; b=ocotHqo+/4aGWH5NW3+sM15QLvSJ+cCd81EjxJ8OoNYbtGGedksbIlce2OljiWY/kf3tFF2TZ TQJ/3nzfg3VAMqOoHxY7WgWQhGiYBFdRLZ5Z06n93+Q41HEOjGATQut X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= While ftrace_set_clr_event() modifies its input buffer during parsing, before returning to the caller the buffer is supposed to be restored to its original state. This works correctly for the colon between the subsystem and event but not the colon at the beginning of :mod:. Restore the colon, so the :mod: trailer is not stripped after ftrace_set_clr_event(). Fixes: 4c86bc531e60 ("tracing: Add :mod: command to enabled module events") Cc: stable@vger.kernel.org Signed-off-by: Thomas Wei=C3=9Fschuh --- kernel/trace/trace_events.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index c46e623e7e0d..6aa32c492280 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1460,6 +1460,8 @@ int ftrace_set_clr_event(struct trace_array *tr, char= *buf, int set) /* Put back the colon to allow this to be called again */ if (buf) *(buf - 1) =3D ':'; + if (mod) + *(mod - 5) =3D ':'; =20 return ret; } --=20 2.55.0 From nobody Tue Sep 29 02:02:25 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 227A4481250; Thu, 13 Aug 2026 14:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630049; cv=none; b=p9dsCFQAma6VIv+KfkKbqdGT/DjuhUGcAOr32ohr8Eu89U4k2ehcJY6lvFhIYDcXAvAznvs94JPwD5rMfSfA+tuQhbb8L5IZTnS/7129B/ZdompDF4+lVlvMLY0ErKJKlVAWsIRHgxCWtnlqsr71IcVtZ4HQjL+AJeuxCtx0a7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630049; c=relaxed/simple; bh=gl06iMv/syv71dRvrhZvxHtAduITqKwKiPntPXMOHnU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dFcGOExWzgxni9NVcBZzewVct0uZb97zLw5LPXSQHx/pv/0tgek6dJprE0Va/3qjHgoevcIfVbuiOlyf2GxgAVNp3nrxeyXAZ2CAcQ4A7uarVLuoByc9Pkc2LLD/dT6F14sOfYmIsPlV1SkBwGCi6e568ORqN6qJoI5Fdrz2KDw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gGF6I9hr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0t7wj4Y9; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gGF6I9hr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0t7wj4Y9" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786630046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V0KBUZ+fAIZp+Clpmtkqz5bk9loQYOgO5ZwoXQ3pL5g=; b=gGF6I9hrWu5BNWfkJ11BqEksDaFNqZmRcPQi96pv27KaZ2jMTPm/KSJ/NAoO+V+bpPDiUS sh0Lx1d5f2HsR7NNbL5cuSFV2EZzuUTcDoMC95lzbRjp1m1YPh7/g1VkLlbwiG3rGht+fx HD9Ve0MUBP+DYbpnaBelXcKxcD8V+3/H5tVu7xkbhvRfcOjg0nEOoCPgp2bTVQtby5yK+e XUVkouSiUEEocF639CYdyJhEO2NL7eVtDYlOhj9LmgaZD/iF3XuYZ3ECWj0JqXtS/HiCLx lZDPeXh+l9L2twvATBcZtlJCgmQUAezEhsNu/WioEgDKidNtECj5xa+ywF5WRQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786630046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V0KBUZ+fAIZp+Clpmtkqz5bk9loQYOgO5ZwoXQ3pL5g=; b=0t7wj4Y9PN1im/UPjc2pxsYHsniesW/x0+PDaB4HBzLFLz9nXQtKhcjYcK3zqRxS/Kbzw6 RTiOVftv6LrNAaCw== Date: Thu, 13 Aug 2026 16:07:15 +0200 Subject: [PATCH RFC 2/7] tracing: Remove duplicate declaration of ftrace_set_clr_event() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-tracing-cli-event-filter-v1-2-57c4e8029c86@linutronix.de> References: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> In-Reply-To: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1786630039; l=977; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=gl06iMv/syv71dRvrhZvxHtAduITqKwKiPntPXMOHnU=; b=oc+qIawThcHhN4cok3NM6zwD5W2eb2rT1BPiRscQpQvmyFwwaJo7H9fq1tj2TN2UwZ+U9VU/Y tq6H9tLGpVzDYEPFgsRAC9eCr/EthhMfb9U2I9vjgQ/NfYXrnY0DLqc X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The function is also declared in include/linux/trace_events.h which is even included from kernel/trace/trace.h. Having two declarations creates churn when changing the signature. Remove the unnecessary, duplicate declaration. Signed-off-by: Thomas Wei=C3=9Fschuh --- kernel/trace/trace.h | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 80fe152af1dd..c00e4741f815 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -2286,7 +2286,6 @@ static inline const char *get_syscall_name(int syscal= l) void trace_event_init(void); void trace_event_update_all(struct trace_eval_map **map, int len); /* Used from boot time tracer */ -extern int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set= ); extern int trigger_process_regex(struct trace_event_file *file, char *buff= ); #else static inline void __init trace_event_init(void) { } --=20 2.55.0 From nobody Tue Sep 29 02:02:25 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 697D648164A; Thu, 13 Aug 2026 14:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630049; cv=none; b=JioueP2PZLF5B+KywWUgibAnMDJ26hQlpAwLXfJJhgIrY6jlpCKJEzHLodtzjCdubKEqGfp1pWwwfIaj/nl7VCzYe5kyZR+f3Binkfwm/JA5vNW3IfDHxCAmdutWgIJRFaJRzziXsVO4xJXx0W88c2WYOripC05lS54bEnF/rQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630049; c=relaxed/simple; bh=uXB+u6Ra4h7qC+KVwAhXukZfPI/hERKowQT5GJBGtus=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ryAhwj/wCQoEEvJe2WrLP9Pbwyco3okXdwkFvqkZwWUvAs/HFw8rfClV+cpkJHSUSdz5psZHe4Hv35dVHZox1EQTFODPbu+oqnVeU66MozaKWXD9xzXZjScqsxM3jnJIN6FdtFnZImqcbaJzyhyUWYeskNUVn7qSe4TzMJSxjW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=GKZRQ7Fe; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tIJ5UySd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="GKZRQ7Fe"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tIJ5UySd" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786630047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qWBx/ls/TBxQ4uDqt98nJYBm/ZaABlStWuteh9J8+/A=; b=GKZRQ7Fe3BNap1XsJLke1T3tl01CE9WmllGts3MR/xcTD0LNobQe+Bfkyuwx8o2I7LWZV/ eOFmJuVPub2lMOv9KRuJMd2N8OvgdMj4a1IKCuSdNolK2cUoUoTx11xVd859dDxfCTG/Jp aCwlML4H45s7FPLiU+9P1I6ON9uiyvKxEUsE53qXMIrAkzbyMUPDFw5OBmMKAdZ5ZUemVK n5KLAssaiv59yvC4DPZGVjagqZYYk+O99woJPMrpYdXyDste7c3k9jfcl9cMryBEjY3ymQ dSusPXHllsVX5vn+Ylm780czAnCH5XMNmp0BZsxIuD0nA/QCx1G/dbW4zB4/XA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786630047; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qWBx/ls/TBxQ4uDqt98nJYBm/ZaABlStWuteh9J8+/A=; b=tIJ5UySdm/9mK1lrJl9h21ytjFAuO2I6X5Xqbrqfv4rhojDQYM/U9gWIB3w9A1Rkk1/Rdo p2vsUi9V0Zzg1KAw== Date: Thu, 13 Aug 2026 16:07:16 +0200 Subject: [PATCH RFC 3/7] tracing: Stop modifying the input buffer in ftrace_set_clr_event() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-tracing-cli-event-filter-v1-3-57c4e8029c86@linutronix.de> References: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> In-Reply-To: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1786630039; l=2529; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=uXB+u6Ra4h7qC+KVwAhXukZfPI/hERKowQT5GJBGtus=; b=mfbUNbUFvj87OWc1TgGUKcAypi8cdkYPiLnU07IQ5atB+PlKoPMaK+Nnh6utd2xi46Ev8QrH7 izG5KviIK1sCArn7dur0YIQnWsupyAW0c2fZA4CZcIRzMerXhdTpTA9 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= ftrace_set_clr_event() modifies its input buffer during parsing. Before returning to the caller these modifications are undone. This is restoration is error prone and was forgotten before. Upcoming changes will also make it more complicated. Copy the input argument and modify that copy and drop the restoration logic. Also mark the input argument as const. Signed-off-by: Thomas Wei=C3=9Fschuh --- include/linux/trace_events.h | 2 +- kernel/trace/trace_events.c | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 308c76b57d13..460d820fe7a4 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -873,7 +873,7 @@ extern int trace_add_event_call(struct trace_event_call= *call); extern int trace_remove_event_call(struct trace_event_call *call); extern int trace_event_get_offsets(struct trace_event_call *call); =20 -int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set); +int ftrace_set_clr_event(struct trace_array *tr, const char *buf, int set); int trace_set_clr_event(const char *system, const char *event, int set); int trace_array_set_clr_event(struct trace_array *tr, const char *system, const char *event, bool enable); diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 6aa32c492280..c75a7f5b55de 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1411,14 +1411,17 @@ static int __ftrace_set_clr_event(struct trace_arra= y *tr, const char *match, return ret; } =20 -int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set) +int ftrace_set_clr_event(struct trace_array *tr, const char *_buf, int set) { char *event =3D NULL, *sub =3D NULL, *match, *mod; - int ret; =20 if (!tr) return -ENOENT; =20 + char *buf __free(kfree) =3D kstrdup(_buf, GFP_KERNEL); + if (!buf) + return -ENOMEM; + /* Modules events can be appended with :mod: */ mod =3D strstr(buf, ":mod:"); if (mod) { @@ -1455,15 +1458,7 @@ int ftrace_set_clr_event(struct trace_array *tr, cha= r *buf, int set) match =3D NULL; } =20 - ret =3D __ftrace_set_clr_event(tr, match, sub, event, set, mod); - - /* Put back the colon to allow this to be called again */ - if (buf) - *(buf - 1) =3D ':'; - if (mod) - *(mod - 5) =3D ':'; - - return ret; + return __ftrace_set_clr_event(tr, match, sub, event, set, mod); } =20 /** --=20 2.55.0 From nobody Tue Sep 29 02:02:25 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 A11DB481ABB; Thu, 13 Aug 2026 14:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630051; cv=none; b=FKPm7hXFpH/U6HRHaBCGAdVt+CbFq4/xVkBNjDlCWPzGlTpfp04RVfnfF15hFSle1ERmqtE6pY2Rs9jxwb6C3eAS1U5JLePNn8H7uk3VahRfj/TFt2ZFLRet2KMjpzEz5s0zD8ist3FOkK2h3PW/xT+cayuQkgXMIeHR9tAmnME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630051; c=relaxed/simple; bh=rbW8w1n/9aEhBtK951U9QqR5KAHNtwNsTPHLF5qTGsA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=inB80HfUKVsT8rSYUk1oV0IA8RzoFq8s6FvekNk3Hw6iFyJzKhV+dfpK9IKbMk3ho2GOUO1ZWraGoIPmzuRoO15iOC/O7+XJV35nWkj0fe10Gyrox8AlxD+mnVbiY2NzxCPolwwEIepE4KAdjjCZwU41Lw/POljNDkkAzlubpKY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fClo/U/i; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sTB/fVOt; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fClo/U/i"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sTB/fVOt" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786630048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2fefSdkEdocoKGKpBduzl2pv9NZDc0Uh/2oLAQRIks8=; b=fClo/U/iBfQ5o3+zw4So4K+uDuKmdsMEsIyEI7Ikbj0QV6hXhMZThuaYs1nXGCV1w6UmlT Q+Gj8UgJrC405uRWvNK/NOdttPfmBBkkJol6oJcPIsIWfSxDHAfFVdzb4V3Q0H5hEHiCTM jGOOo8rD7l3eBzPj/o7qJoERFXZaCzrwDIkP30pFGnjoG2k4UOdUkHcrE3K9x0pDSODayy uRX4+Ds29XXCcJd547Z6aSVz/vFphaYFOnQN/d3+Fyk+lGj0zRWxNKNQlrJ07yv4DcGgtn gB6aDsHFfJoA0+nsMhmO/YP9pL+d1LHjClGWNlXPcY0KRWRAl2bd4NlquU589w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786630048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2fefSdkEdocoKGKpBduzl2pv9NZDc0Uh/2oLAQRIks8=; b=sTB/fVOtO33axD44gV4KkPhnu4kTnhuy0NcsKLduk3J5As2sLEKDT2uL+xgEcVnwUzT0e0 iFUtFnHj+/czVZDw== Date: Thu, 13 Aug 2026 16:07:17 +0200 Subject: [PATCH RFC 4/7] tracing: Split the event string parsing logic into a dedicated function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-tracing-cli-event-filter-v1-4-57c4e8029c86@linutronix.de> References: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> In-Reply-To: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1786630039; l=2569; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=rbW8w1n/9aEhBtK951U9QqR5KAHNtwNsTPHLF5qTGsA=; b=WxUc36gb35O0YVdUC0/KTbmO04ACZhkGqSpdbHVPnhlAEmGhvyTGx6Y6Uwm5v5Ve/zMyDhpwK 90Xw/omnI9YBneH6jA2bPZtb+wZ1KcUxliAhyK3kj0BlpeiaYI5sTQI X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= That new function can be tested with a KUnit test to prevent regressions when adding new fields to the format. Signed-off-by: Thomas Wei=C3=9Fschuh --- kernel/trace/trace_events.c | 59 ++++++++++++++++++++++++++---------------= ---- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index c75a7f5b55de..4ff3f9214894 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1411,23 +1411,18 @@ static int __ftrace_set_clr_event(struct trace_arra= y *tr, const char *match, return ret; } =20 -int ftrace_set_clr_event(struct trace_array *tr, const char *_buf, int set) +static void +ftrace_parse_event_string(char *buf, char **match, char **sub, char **even= t, char **mod) { - char *event =3D NULL, *sub =3D NULL, *match, *mod; - - if (!tr) - return -ENOENT; - - char *buf __free(kfree) =3D kstrdup(_buf, GFP_KERNEL); - if (!buf) - return -ENOMEM; + *event =3D NULL; + *sub =3D NULL; =20 /* Modules events can be appended with :mod: */ - mod =3D strstr(buf, ":mod:"); - if (mod) { - *mod =3D '\0'; + *mod =3D strstr(buf, ":mod:"); + if (*mod) { + **mod =3D '\0'; /* move to the module name */ - mod +=3D 5; + *mod +=3D 5; } =20 /* @@ -1442,21 +1437,35 @@ int ftrace_set_clr_event(struct trace_array *tr, co= nst char *_buf, int set) * the name or any event that matches */ =20 - match =3D strsep(&buf, ":"); + *match =3D strsep(&buf, ":"); if (buf) { - sub =3D match; - event =3D buf; - match =3D NULL; - - if (!strlen(sub) || strcmp(sub, "*") =3D=3D 0) - sub =3D NULL; - if (!strlen(event) || strcmp(event, "*") =3D=3D 0) - event =3D NULL; - } else if (mod) { + *sub =3D *match; + *event =3D buf; + *match =3D NULL; + + if (!strlen(*sub) || strcmp(*sub, "*") =3D=3D 0) + *sub =3D NULL; + if (!strlen(*event) || strcmp(*event, "*") =3D=3D 0) + *event =3D NULL; + } else if (*mod) { /* Allow wildcard for no length or star */ - if (!strlen(match) || strcmp(match, "*") =3D=3D 0) - match =3D NULL; + if (!strlen(*match) || strcmp(*match, "*") =3D=3D 0) + *match =3D NULL; } +} + +int ftrace_set_clr_event(struct trace_array *tr, const char *_buf, int set) +{ + char *event, *sub, *match, *mod; + + if (!tr) + return -ENOENT; + + char *buf __free(kfree) =3D kstrdup(_buf, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + ftrace_parse_event_string(buf, &match, &sub, &event, &mod); =20 return __ftrace_set_clr_event(tr, match, sub, event, set, mod); } --=20 2.55.0 From nobody Tue Sep 29 02:02:25 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 91493483BD3; Thu, 13 Aug 2026 14:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630053; cv=none; b=LfILiuqOjqY6sUi7eWYVsPPru08GXOH1od11RuTUCsq7rLuvQf8C5Pam3c4qYa3seMSUX1dIGYAdFRFXE7ZZmsWtj6vvDafVUanBCzO7I76Ahg2Xaj9GkAUp+An85VMJtaR/dvmoi3nFWfIiuDubrkIGc+KEOw8hOOamhuxM1GE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630053; c=relaxed/simple; bh=4YSg6q5BnaYywr3fPl6vkuJOqPpAkW0f05ia6cMS4vs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H+3MSQc0aKDQe/YX2xjc4gjuSb/wONumRLiYTZyCHm84SoHbsy3OyrsEyAh3XwIqK9xKZzH8uTFTrffNeBG0HhC4FR3CyhhHuBSaG6UbI4JTRaDFKGGPzOqXY6v6ekgvnbYUKr7YUMEizCVARc4iouZZNjuB/YMmaorDSwVYORM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gpMFFvRC; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=o697awFc; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gpMFFvRC"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="o697awFc" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786630049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BUBV4UfNe6DT8kodPBUPI5rVvc0/aAmNySrxh4n/hBY=; b=gpMFFvRCzk8omLjRJkoLMRqhqu1yNvU5qkDZRlosvjzLYNpgjJ6pucSio+K3mKIzTLF8GB D7jCB5FbXiHjCIIVele0IY+LYdcKlDbdlxO1S4rZN4sknrOGslq1ADScRjBTyUmar+e9Ko ULx/DG3Z3lylS76hagGUQDJ1zzn0H2odANn1mcZQN12P+mnHQSbXh2oTtmRAxB6fI/vLWl pW2+ptUcsWKr7hFrDt2WGZgQU02WQ4sCX/fjiqe31fPJ5EgFcSFQXp7Tke+1NeRwL/CaYN JSFLpUxqT4qMN4RX0Nho80KPjS26IAgMQ6eugd2wQ5/8z8X8cfOVIXKqTLrkjQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786630049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BUBV4UfNe6DT8kodPBUPI5rVvc0/aAmNySrxh4n/hBY=; b=o697awFcZf9eHmjFIdCNKE5rtAxBEmtUeG5i6VpKZzgD4pcQeG7C/qYjw9/7pVuNFFWBmG uAV4+WKu6nbTIyDg== Date: Thu, 13 Aug 2026 16:07:18 +0200 Subject: [PATCH RFC 5/7] tracing: Add a test for ftrace_parse_event_string() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-tracing-cli-event-filter-v1-5-57c4e8029c86@linutronix.de> References: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> In-Reply-To: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1786630039; l=5237; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=4YSg6q5BnaYywr3fPl6vkuJOqPpAkW0f05ia6cMS4vs=; b=yrP9gshAK6xc5yLgyO/KDsWObN8FfwV4KsOOkIqs21aetqzaY7hT83jqOeuf654xCxxP6z2GX rnxOKhx9DNAD0+ev2nXlKjKkgqsWoQpKGPU13McDgAyoeVDAmns7Gxf X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The parsing logic is a bit complicated and about to become more so. Add a unit test to avoid regressions. Signed-off-by: Thomas Wei=C3=9Fschuh --- kernel/trace/Kconfig | 8 ++++ kernel/trace/Makefile | 1 + kernel/trace/trace.h | 4 ++ kernel/trace/trace_events.c | 5 +- kernel/trace/trace_events_test.c | 101 +++++++++++++++++++++++++++++++++++= ++++ 5 files changed, 118 insertions(+), 1 deletion(-) diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 084f34dc6c9f..e5eb26780abf 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -151,6 +151,14 @@ config EVENT_TRACING select GLOB bool =20 +config EVENT_TRACING_TEST + tristate "Test for event tracing" if !KUNIT_ALL_TESTS + depends on EVENT_TRACING + depends on KUNIT + default KUNIT_ALL_TESTS + help + KUnit test for the event tracing implementation. + config CONTEXT_SWITCH_TRACER bool =20 diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index f934ff586bd4..7bef5a84ce47 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -96,6 +96,7 @@ obj-$(CONFIG_EVENT_TRACING) +=3D blktrace.o endif obj-$(CONFIG_EVENT_TRACING) +=3D trace_events.o obj-$(CONFIG_EVENT_TRACING) +=3D trace_export.o +obj-$(CONFIG_EVENT_TRACING_TEST) +=3D trace_events_test.o obj-$(CONFIG_FTRACE_SYSCALLS) +=3D trace_syscalls.o ifeq ($(CONFIG_PERF_EVENTS),y) obj-$(CONFIG_EVENT_TRACING) +=3D trace_event_perf.o diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index c00e4741f815..6bf4f031efa8 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -2505,3 +2505,7 @@ static inline int rv_init_interface(void) }) =20 #endif /* _LINUX_KERNEL_TRACE_H */ + +#if IS_ENABLED(CONFIG_KUNIT) +void ftrace_parse_event_string(char *buf, char **match, char **sub, char *= *event, char **mod); +#endif diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 4ff3f9214894..098a5aee5ec7 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -23,6 +23,8 @@ #include #include =20 +#include + #include #include =20 @@ -1411,7 +1413,7 @@ static int __ftrace_set_clr_event(struct trace_array = *tr, const char *match, return ret; } =20 -static void +VISIBLE_IF_KUNIT void ftrace_parse_event_string(char *buf, char **match, char **sub, char **even= t, char **mod) { *event =3D NULL; @@ -1453,6 +1455,7 @@ ftrace_parse_event_string(char *buf, char **match, ch= ar **sub, char **event, cha *match =3D NULL; } } +EXPORT_SYMBOL_IF_KUNIT(ftrace_parse_event_string); =20 int ftrace_set_clr_event(struct trace_array *tr, const char *_buf, int set) { diff --git a/kernel/trace/trace_events_test.c b/kernel/trace/trace_events_t= est.c new file mode 100644 index 000000000000..e090a699b8d5 --- /dev/null +++ b/kernel/trace/trace_events_test.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +#include + +#include "trace.h" + +struct parse_event_test_case { + const char *input; + + const char *match, *sub, *event, *mod; +}; + +static const struct parse_event_test_case parse_event_test_cases[] =3D { + { + "", + .match =3D "", + }, + { + "*:event", + .event =3D "event", + }, + { + ":event", + .event =3D "event", + }, + { + "sub:*", + .sub =3D "sub", + }, + { + "sub:", + .sub =3D "sub", + }, + { + "sub:event", + .sub =3D "sub", + .event =3D "event", + }, + { + "match", + .match =3D "match", + }, + { + ":mod:module", + .mod =3D "module", + }, + { + "sub:event:mod:module", + .sub =3D "sub", + .event =3D "event", + .mod =3D "module", + }, +}; + +static void parse_event_test_desc(const struct parse_event_test_case *para= ms, char *desc) +{ + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "'%s'", params->input); +} + +KUNIT_ARRAY_PARAM(parse_event, parse_event_test_cases, parse_event_test_de= sc); + +#define EXPECT_NULL_OR_STR_EQ(test, left, right) \ +({ \ + if ((left) !=3D NULL) \ + KUNIT_EXPECT_STREQ(test, (left), (right)); \ + else \ + KUNIT_EXPECT_NULL(test, (right)); \ +}) + +static void parse_event(struct kunit *test) +{ + const struct parse_event_test_case *params =3D test->param_value; + char *input, *match, *sub, *event, *mod; + + input =3D kunit_kstrdup(test, params->input, GFP_KERNEL); + if (!input) + kunit_skip(test, "ENOMEM"); + + ftrace_parse_event_string(input, &match, &sub, &event, &mod); + + EXPECT_NULL_OR_STR_EQ(test, match, params->match); + EXPECT_NULL_OR_STR_EQ(test, sub, params->sub); + EXPECT_NULL_OR_STR_EQ(test, event, params->event); + EXPECT_NULL_OR_STR_EQ(test, mod, params->mod); +} + +static struct kunit_case trace_events_test_cases[] =3D { + KUNIT_CASE_PARAM(parse_event, parse_event_gen_params), + {} +}; + +static struct kunit_suite trace_events_test_suite =3D { + .name =3D "trace-events", + .test_cases =3D trace_events_test_cases, +}; +kunit_test_suite(trace_events_test_suite); + + +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); --=20 2.55.0 From nobody Tue Sep 29 02:02:25 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 5C864484257; Thu, 13 Aug 2026 14:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630054; cv=none; b=E8h6E+hWoTpxn2qSyMDUGXMw9rgFYTv1V1GNgp7Fy9cu3kZnERVup9KT+/gTy+L2VhnZexGu9xY5A763wOPINzAFhs6M9LI14f0hdInyHR2YzVFvJ4UHzI63x0hmrBrXTSxBePCEWedhRnmGS2nJ8dtQounXk2oI/FGDcyZOGcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630054; c=relaxed/simple; bh=YWFW1zcn9gtEa9Lz/HYzGgMoaHvPxdat3XRJHNgLzZI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vk9d01sP3z6dMmvEXOeP7M/9jm+e+dfQa1CPRLHcfnuMnuvo8o29XyV6Mcfph3KrFCPjXs3+6S4YZA13wW2pAb9UnHkVFEpMGXg9l3f7AjcQi2jsyJF4wNPDe2Z3fIM/3lnyF37/A0H1ttEW4LFdZOd/LYbRCaAelpz0n0ymeJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ByRyLMrz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PHSMyvLj; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ByRyLMrz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PHSMyvLj" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786630050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iKbiUJ/lxCgVioUyVAAFZc/QFm1LoDhCJCkL6YyTbWY=; b=ByRyLMrzB5bRHhSU/aHtVObFi0xnByBp3Gvg3QEtr29oKV7VSf1DwvYyIJXJATzAXqN8EY graXGlKUtUCcULfE9s+c4wqIM0lgmENVqyZqRVXEcelXr/sBFBrutJyiSVqcaqXZ0nHkHP oJE2DXOgjpLi2C+nRNJ6b1I03xo6Ms3lt+zB9VSMx8lTaIrwFy0zhP9FTLAAn7HGUGydMz 18RRlhNzQpGkUlgY5/Gn01EZf6zZgcsyuzEkBkzYDxwONImm6+9hSxe83wzIWisNvqQDmN 27szZczdFi3qFoH2hbiOqz+CfQ7U+TwlBS2zTceh4MYK/5JMjefjSiXLMnrjrA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786630050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iKbiUJ/lxCgVioUyVAAFZc/QFm1LoDhCJCkL6YyTbWY=; b=PHSMyvLjqisPnVkzC7vCp+61t/VuRuIT5iExn3wr3EnM+DP/uJncnyS3ep6jg/71J24JJq joA5JkSsfe9Lo9BA== Date: Thu, 13 Aug 2026 16:07:19 +0200 Subject: [PATCH RFC 6/7] tracing: Add a filter argument to __ftrace_set_clr_event() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-tracing-cli-event-filter-v1-6-57c4e8029c86@linutronix.de> References: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> In-Reply-To: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1786630039; l=7315; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=YWFW1zcn9gtEa9Lz/HYzGgMoaHvPxdat3XRJHNgLzZI=; b=u9b4SIM0bhn9zRwXDzWU2xTvX6gwjR6dfkL46w5pPjKBpD8fl9Hj5vyxp06pr5Q6Zj5M/z6A9 SCLBeIog9iDDJXxTk1heap8cokRJINO/3jOGCE2sjvbgU3waSkNf3fl X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Make it possible to directly enable a filter when enabling an event. For now this is unused, an upcoming patch will wire it up. Signed-off-by: Thomas Wei=C3=9Fschuh --- kernel/trace/trace_events.c | 47 +++++++++++++++++++++++++++++------------= ---- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 098a5aee5ec7..c24929d003dd 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -916,6 +916,7 @@ struct event_mod_load { char *match; char *system; char *event; + char *filter; }; =20 static void free_event_mod(struct event_mod_load *event_mod) @@ -925,6 +926,7 @@ static void free_event_mod(struct event_mod_load *event= _mod) kfree(event_mod->match); kfree(event_mod->system); kfree(event_mod->event); + kfree(event_mod->filter); kfree(event_mod); } =20 @@ -966,7 +968,7 @@ static int remove_cache_mod(struct trace_array *tr, con= st char *mod, } =20 static int cache_mod(struct trace_array *tr, const char *mod, int set, - const char *match, const char *system, const char *event) + const char *match, const char *system, const char *event, const cha= r *filter) { struct event_mod_load *event_mod; =20 @@ -1005,6 +1007,12 @@ static int cache_mod(struct trace_array *tr, const c= har *mod, int set, goto out_free; } =20 + if (filter) { + event_mod->filter =3D kstrdup(filter, GFP_KERNEL); + if (!event_mod->filter) + goto out_free; + } + list_add(&event_mod->list, &tr->mod_events); =20 return 0; @@ -1017,7 +1025,7 @@ static int cache_mod(struct trace_array *tr, const ch= ar *mod, int set, #else /* CONFIG_MODULES */ static inline void clear_mod_events(struct trace_array *tr) { } static int cache_mod(struct trace_array *tr, const char *mod, int set, - const char *match, const char *system, const char *event) + const char *match, const char *system, const char *event, const cha= r *filter) { return -EINVAL; } @@ -1326,7 +1334,7 @@ static void remove_event_file_dir(struct trace_event_= file *file) static int __ftrace_set_clr_event_nolock(struct trace_array *tr, const char *match, const char *sub, const char *event, int set, - const char *mod) + const char *mod, char *filter) { struct trace_event_file *file; struct trace_event_call *call; @@ -1374,7 +1382,11 @@ __ftrace_set_clr_event_nolock(struct trace_array *tr= , const char *match, if (event && strcmp(event, name) !=3D 0) continue; =20 - ret =3D ftrace_event_enable_disable(file, set); + if (filter) + ret =3D apply_event_filter(file, filter); + + if (!filter || !ret) + ret =3D ftrace_event_enable_disable(file, set); =20 /* * Save the first error and return that. Some events @@ -1392,14 +1404,14 @@ __ftrace_set_clr_event_nolock(struct trace_array *t= r, const char *match, * check if the module was loaded. If it wasn't cache it. */ if (module && ret =3D=3D -EINVAL && !eret) - ret =3D cache_mod(tr, module, set, match, sub, event); + ret =3D cache_mod(tr, module, set, match, sub, event, filter); =20 return ret; } =20 static int __ftrace_set_clr_event(struct trace_array *tr, const char *matc= h, const char *sub, const char *event, int set, - const char *mod) + const char *mod, char *filter) { int ret; =20 @@ -1407,7 +1419,7 @@ static int __ftrace_set_clr_event(struct trace_array = *tr, const char *match, return -EACCES; =20 mutex_lock(&event_mutex); - ret =3D __ftrace_set_clr_event_nolock(tr, match, sub, event, set, mod); + ret =3D __ftrace_set_clr_event_nolock(tr, match, sub, event, set, mod, fi= lter); mutex_unlock(&event_mutex); =20 return ret; @@ -1470,7 +1482,7 @@ int ftrace_set_clr_event(struct trace_array *tr, cons= t char *_buf, int set) =20 ftrace_parse_event_string(buf, &match, &sub, &event, &mod); =20 - return __ftrace_set_clr_event(tr, match, sub, event, set, mod); + return __ftrace_set_clr_event(tr, match, sub, event, set, mod, NULL); } =20 /** @@ -1492,7 +1504,7 @@ int trace_set_clr_event(const char *system, const cha= r *event, int set) if (!tr) return -ENODEV; =20 - return __ftrace_set_clr_event(tr, NULL, system, event, set, NULL); + return __ftrace_set_clr_event(tr, NULL, system, event, set, NULL, NULL); } EXPORT_SYMBOL_GPL(trace_set_clr_event); =20 @@ -1518,7 +1530,7 @@ int trace_array_set_clr_event(struct trace_array *tr,= const char *system, return -ENOENT; =20 set =3D (enable =3D=3D true) ? 1 : 0; - return __ftrace_set_clr_event(tr, NULL, system, event, set, NULL); + return __ftrace_set_clr_event(tr, NULL, system, event, set, NULL, NULL); } EXPORT_SYMBOL_GPL(trace_array_set_clr_event); =20 @@ -2038,7 +2050,7 @@ system_enable_write(struct file *filp, const char __u= ser *ubuf, size_t cnt, if (system) name =3D system->name; =20 - ret =3D __ftrace_set_clr_event(dir->tr, NULL, name, NULL, val, NULL); + ret =3D __ftrace_set_clr_event(dir->tr, NULL, name, NULL, val, NULL, NULL= ); if (ret) goto out; =20 @@ -3909,7 +3921,8 @@ static void update_mod_cache(struct trace_array *tr, = struct module *mod) =20 __ftrace_set_clr_event_nolock(tr, event_mod->match, event_mod->system, - event_mod->event, 1, mod->name); + event_mod->event, 1, mod->name, + event_mod->filter); free_event_mod(event_mod); } } @@ -4676,7 +4689,7 @@ int event_trace_del_tracer(struct trace_array *tr) __ftrace_clear_event_pids(tr, TRACE_PIDS | TRACE_NO_PIDS); =20 /* Disable any running events */ - __ftrace_set_clr_event_nolock(tr, NULL, NULL, NULL, 0, NULL); + __ftrace_set_clr_event_nolock(tr, NULL, NULL, NULL, 0, NULL, NULL); =20 /* Make sure no more events are being executed */ tracepoint_synchronize_unregister(); @@ -4982,7 +4995,7 @@ static __init void event_trace_self_tests(void) =20 pr_info("Testing event system %s: ", system->name); =20 - ret =3D __ftrace_set_clr_event(tr, NULL, system->name, NULL, 1, NULL); + ret =3D __ftrace_set_clr_event(tr, NULL, system->name, NULL, 1, NULL, NU= LL); if (WARN_ON_ONCE(ret)) { pr_warn("error enabling system %s\n", system->name); @@ -4991,7 +5004,7 @@ static __init void event_trace_self_tests(void) =20 event_test_stuff(); =20 - ret =3D __ftrace_set_clr_event(tr, NULL, system->name, NULL, 0, NULL); + ret =3D __ftrace_set_clr_event(tr, NULL, system->name, NULL, 0, NULL, NU= LL); if (WARN_ON_ONCE(ret)) { pr_warn("error disabling system %s\n", system->name); @@ -5006,7 +5019,7 @@ static __init void event_trace_self_tests(void) pr_info("Running tests on all trace events:\n"); pr_info("Testing all events: "); =20 - ret =3D __ftrace_set_clr_event(tr, NULL, NULL, NULL, 1, NULL); + ret =3D __ftrace_set_clr_event(tr, NULL, NULL, NULL, 1, NULL, NULL); if (WARN_ON_ONCE(ret)) { pr_warn("error enabling all events\n"); return; @@ -5015,7 +5028,7 @@ static __init void event_trace_self_tests(void) event_test_stuff(); =20 /* reset sysname */ - ret =3D __ftrace_set_clr_event(tr, NULL, NULL, NULL, 0, NULL); + ret =3D __ftrace_set_clr_event(tr, NULL, NULL, NULL, 0, NULL, NULL); if (WARN_ON_ONCE(ret)) { pr_warn("error disabling all events\n"); return; --=20 2.55.0 From nobody Tue Sep 29 02:02:25 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8A01B481AA1; Thu, 13 Aug 2026 14:07:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630055; cv=none; b=N+WInSJ/fJqf5AydfGMbAEnef1ZBADM9khFC2qEZTw4S2C1FWZrOZYg9O9MzVNWrUk/jzw36EfBT99SL0hgCM9+yjPoKDHeYszaogBQdLKCGr/ML4diFUCh7uioQW+ENrNqRvbm7U+nkyHTZruytBmuYGYnFn6qpSJtfRC49h6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786630055; c=relaxed/simple; bh=5KG9ggG+sYH747V2TG/SWjV6KFhlj6kNDRk9COW7rC0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MleN7+3oK7qHcf76B0ozObGppK9uOfeGnqEm99ZwIhIrlHR1I71zQfYwzbCF0s0WkRJLbZmaMkbRZAWCUj1hhQTAbRh4YQ3FXzZnMzyufGcUdv0aNWlwnCNSzhHXzMvGtk2T5PqptgLInqsNRNIdAJe5tZibSIr7NmwOupZx/CA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=WO3cQm3H; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=o4ygpNKO; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WO3cQm3H"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="o4ygpNKO" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786630051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4KRVQFkVkY8fZPaA3svHgY48lpnccVnCvT09HtZ4RHI=; b=WO3cQm3HTwoMAUQdxst+HA+AgOQUBzhiIjBcfkqCN/pj0816LtVtfFdSL6xJP2S9bOkFzi 0yBEuewHqRjOIi2W7egjCMJRyBUAhKjWo21wU2VWmLwQPuOu5Q0YDSvt8WxO1cRAC+7cAh rxebNJiaF0HXtM8Vf7PSzG1WmbbG8kLYdK6cI0YWvsesHY0AnQEMJrEMeEWQBZJA8Q3kBA 0PhiH5ZrvlHFrDBJydLpWGja//CREijwYiIOiqYo7avle2KstxVFGgkl6x4rBTFyxHiBWj 2zxo0AAnggjxilTNPm9Xpk6q+p55V2WCtxHVu6dOr7QRQTSi07Z0GAsnn/bKzQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786630051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4KRVQFkVkY8fZPaA3svHgY48lpnccVnCvT09HtZ4RHI=; b=o4ygpNKOebJ2MeA2lrYuosXxTuNCykcZjat0pnIG0/oMLt9t2ONL42kIbFyx5q8sU/VM/m ayaPGkSYBLOz/kCw== Date: Thu, 13 Aug 2026 16:07:20 +0200 Subject: [PATCH RFC 7/7] tracing: Parse filter from event string Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260813-tracing-cli-event-filter-v1-7-57c4e8029c86@linutronix.de> References: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> In-Reply-To: <20260813-tracing-cli-event-filter-v1-0-57c4e8029c86@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1786630039; l=4633; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=5KG9ggG+sYH747V2TG/SWjV6KFhlj6kNDRk9COW7rC0=; b=jC3xvgAwcx3f14HmFhF3FSLbFY6slRVpsxcQypzq0E5GRJSU59R779RB5tJExh1XDkO+KhF0P BHDfUGPT9ndB+5WiEbtO/4f2oyTyvJGurBjwRfSPS9uiKwuxT+Y63Gd X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= Make it possible to specify a trace event filter from the kernel command line. Signed-off-by: Thomas Wei=C3=9Fschuh --- For the non-RFC patch this should probably be limited to only apply to the cmdline path. --- kernel/trace/trace.h | 3 ++- kernel/trace/trace_events.c | 13 +++++++++---- kernel/trace/trace_events_test.c | 20 +++++++++++++++++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 6bf4f031efa8..9102bf0a45a9 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -2507,5 +2507,6 @@ static inline int rv_init_interface(void) #endif /* _LINUX_KERNEL_TRACE_H */ =20 #if IS_ENABLED(CONFIG_KUNIT) -void ftrace_parse_event_string(char *buf, char **match, char **sub, char *= *event, char **mod); +void ftrace_parse_event_string(char *buf, char **match, char **sub, char *= *event, char **mod, + char **filter); #endif diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index c24929d003dd..d4c46b24c382 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1426,10 +1426,12 @@ static int __ftrace_set_clr_event(struct trace_arra= y *tr, const char *match, } =20 VISIBLE_IF_KUNIT void -ftrace_parse_event_string(char *buf, char **match, char **sub, char **even= t, char **mod) +ftrace_parse_event_string(char *buf, char **match, char **sub, char **even= t, char **mod, + char **filter) { *event =3D NULL; *sub =3D NULL; + *filter =3D NULL; =20 /* Modules events can be appended with :mod: */ *mod =3D strstr(buf, ":mod:"); @@ -1453,6 +1455,9 @@ ftrace_parse_event_string(char *buf, char **match, ch= ar **sub, char **event, cha =20 *match =3D strsep(&buf, ":"); if (buf) { + *filter =3D buf; + strsep(filter, ":"); + *sub =3D *match; *event =3D buf; *match =3D NULL; @@ -1471,7 +1476,7 @@ EXPORT_SYMBOL_IF_KUNIT(ftrace_parse_event_string); =20 int ftrace_set_clr_event(struct trace_array *tr, const char *_buf, int set) { - char *event, *sub, *match, *mod; + char *event, *sub, *match, *mod, *filter; =20 if (!tr) return -ENOENT; @@ -1480,9 +1485,9 @@ int ftrace_set_clr_event(struct trace_array *tr, cons= t char *_buf, int set) if (!buf) return -ENOMEM; =20 - ftrace_parse_event_string(buf, &match, &sub, &event, &mod); + ftrace_parse_event_string(buf, &match, &sub, &event, &mod, &filter); =20 - return __ftrace_set_clr_event(tr, match, sub, event, set, mod, NULL); + return __ftrace_set_clr_event(tr, match, sub, event, set, mod, filter); } =20 /** diff --git a/kernel/trace/trace_events_test.c b/kernel/trace/trace_events_t= est.c index e090a699b8d5..fd54eb03b58f 100644 --- a/kernel/trace/trace_events_test.c +++ b/kernel/trace/trace_events_test.c @@ -8,7 +8,7 @@ struct parse_event_test_case { const char *input; =20 - const char *match, *sub, *event, *mod; + const char *match, *sub, *event, *mod, *filter; }; =20 static const struct parse_event_test_case parse_event_test_cases[] =3D { @@ -37,6 +37,12 @@ static const struct parse_event_test_case parse_event_te= st_cases[] =3D { .sub =3D "sub", .event =3D "event", }, + { + "sub:event:filter", + .sub =3D "sub", + .event =3D "event", + .filter =3D "filter", + }, { "match", .match =3D "match", @@ -51,6 +57,13 @@ static const struct parse_event_test_case parse_event_te= st_cases[] =3D { .event =3D "event", .mod =3D "module", }, + { + "sub:event:filter:mod:module", + .sub =3D "sub", + .event =3D "event", + .mod =3D "module", + .filter =3D "filter", + }, }; =20 static void parse_event_test_desc(const struct parse_event_test_case *para= ms, char *desc) @@ -71,18 +84,19 @@ KUNIT_ARRAY_PARAM(parse_event, parse_event_test_cases, = parse_event_test_desc); static void parse_event(struct kunit *test) { const struct parse_event_test_case *params =3D test->param_value; - char *input, *match, *sub, *event, *mod; + char *input, *match, *sub, *event, *mod, *filter; =20 input =3D kunit_kstrdup(test, params->input, GFP_KERNEL); if (!input) kunit_skip(test, "ENOMEM"); =20 - ftrace_parse_event_string(input, &match, &sub, &event, &mod); + ftrace_parse_event_string(input, &match, &sub, &event, &mod, &filter); =20 EXPECT_NULL_OR_STR_EQ(test, match, params->match); EXPECT_NULL_OR_STR_EQ(test, sub, params->sub); EXPECT_NULL_OR_STR_EQ(test, event, params->event); EXPECT_NULL_OR_STR_EQ(test, mod, params->mod); + EXPECT_NULL_OR_STR_EQ(test, filter, params->filter); } =20 static struct kunit_case trace_events_test_cases[] =3D { --=20 2.55.0