From nobody Fri Sep 25 22:19:31 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 8F611380FC4; Tue, 8 Sep 2026 06:22:19 +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=1788848541; cv=none; b=Y57PLwQa3w8H9Yv7tI7dLPVeppVLwhGYWU0FQCWob1FM5vjZm9Z+0Ow0afKVHbiShD+HyNwShMIPNacWah/iD8ZLfZPCP7xH2C4B/Od7fuMUaEGUOBwORGyTMzCFTKHBUnt94eZfeKpNXvSKvbtXARZAKjjojsYhxJsxLCcYvBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788848541; c=relaxed/simple; bh=vGSo4rgCHvujEd/avZtZt+hZGhZ1NSkjuonFug/7/iI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B0nugW4kHhdb2zw2y3K7JDwFmy4OGFWy9vMHIlfKsT1zteF3GCZ/Wnpaxgsiv9xBkJcnjP7gkyz93Pqa6Njw0VUIlAOzbkPGSJ+puxmDJqJ8HO48MuMwUcEu4ijNEl9fzAnh9RkhxBG6pXw2VSwYfikX0xiy8fgbrMyDf5pdIlA= 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=0vZuNQoG; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=WyQ67PrH; 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="0vZuNQoG"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="WyQ67PrH" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788848537; 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=+di0ouvNWAnbViwKCuPDa4ryAiesqddSgYVkDMYu7D0=; b=0vZuNQoGk8RiwqT4uAabP268dEOWvJsagSOSMMCeOYwMymJ1RiGwOR/tK8H5+2dbBo3RRz HPtk9ulQahaxc3+unXpCaHPnyCvLcKuXWT5DDW3xQPIYmBf23JlQAkTGPHALrn7p2ghehM Zh0sqAoP4L9dZQVijk7AYK0HzPoGugTZcmxCyUcXn63vGOyta+W9KQyjfGbznoHxgY5C6+ 80GdwZ/csy8/08g5Z7vAvncX5DlZRAoLt/YKgvZZjxL5r492OpWK5AwKFD7RVeRLuWGY9m eRK/AJwqR+SHhexjN2QYZbYDZL0hOpoZmIFHNJ6FPrQ8i/5TxUaxenq7b7BIwQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788848537; 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=+di0ouvNWAnbViwKCuPDa4ryAiesqddSgYVkDMYu7D0=; b=WyQ67PrH0X8f+QPFihJ94Owuz2RYegBmXxA9cTqQljgTizESaBvfUkGvtzj8mrdAQ98xeS mgKD/KfCeaM+y5BA== Date: Tue, 08 Sep 2026 08:22:15 +0200 Subject: [PATCH v2 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: <20260908-tracing-cli-event-filter-v2-1-05396a3fb663@linutronix.de> References: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> In-Reply-To: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: linux-doc@vger.kernel.org, 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=1788848535; l=1066; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=vGSo4rgCHvujEd/avZtZt+hZGhZ1NSkjuonFug/7/iI=; b=qukLrjVKaixpHmMaHhPbATFtaVZi+XrojLdyjrFTn9QGq4BtAe+2FBtCw2Fqs71ItAhxeeHvJ Kxy7HdrQmMBCnjlu8aw9YeL2RPihfTlykQ1abHOmf2csJtV+iP4tEgh 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 1d39eaf6a0f7..eab653cb3540 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1489,6 +1489,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 Fri Sep 25 22:19:31 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 8F6A7380FC8; Tue, 8 Sep 2026 06:22:19 +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=1788848541; cv=none; b=OuMbniWf2MJPghgpZf5LBTRB4pov1m1zC2A2Et9mx/JHpNgaWoobh+Do5ipUKYYDKoZM8V+8F9WcNiXvR0OnA5LhU+/sI/8DSZaSNH2R3jW+JD5LdqF7k3yF+OJkn5JqTbxwWBnYg6LxZ8Mg1ojcpIXfwbTHE/Ss1fo4lSBympg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788848541; c=relaxed/simple; bh=zAT6OkKCvliEPOEq8U2CAdfNT8wiBntFtwUDghsPOXU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LJDPrFriqQhkHaNJk/eXyKpALbBlomTsbd5feDkBBDzdTrXlR7mXWwROkkz/iXj9jWJpgsWxWM2vgGi2WhImd3z0+YEAlM/A6+Le4tPPdOYbkgRd3I2WiC8mE96U3J1N/CzasP9BbBqEslEG+XmnRFdWoB0Stu4tP11go0ks7hU= 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=WntViQ9H; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+zL0EzqV; 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="WntViQ9H"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+zL0EzqV" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788848538; 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=zbOwDumNVEBBo2G/MbKcD830SEh1cuRXMj/EZAUQybI=; b=WntViQ9HWLvPHEgDDdiUyJaOeV++b5JmfUAmKICsbEbhBOaOt7c9N2+Rr7QH3GiBoN+1pa Nro9t9YrZ1OvJ7cAIM7rnkm09mWTxz4cdFlHstgd1R/nZbNRKjE9tpX24mFpRFctiIqOaV O20u2ZL2ecYAjLn2iG0sKTbwS81L+DlQ8SKdGueRNv7vGiLmVo9D84ndBSWhBLSVI0lQGr Bu84VXea1fV/5+wlAfK+2F5mcXoAJys3Rj8x8UXIX/Np09jGYMXkIvq/dWP6MordzL+Y3s /q1o9lLx/Cx8OTjZyb0B5J8ae1v7f6N7x7WWN5yDmML5TI8vhik2f+kvmt2QeA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788848538; 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=zbOwDumNVEBBo2G/MbKcD830SEh1cuRXMj/EZAUQybI=; b=+zL0EzqVcB1KK6VW/UviOJEPDubjtC2AFmxksJ/jlrDg2JYkzXiNOT19rLXmB0UWOdGcZq rCtKUjQM8DN4HwCQ== Date: Tue, 08 Sep 2026 08:22:16 +0200 Subject: [PATCH v2 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: <20260908-tracing-cli-event-filter-v2-2-05396a3fb663@linutronix.de> References: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> In-Reply-To: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: linux-doc@vger.kernel.org, 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=1788848535; l=997; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=zAT6OkKCvliEPOEq8U2CAdfNT8wiBntFtwUDghsPOXU=; b=CTpL1yD3pw2tlYs0VWTlmBlJfP8ra1haxBhX0G92utVffCqWScbjjm4HCkt4orNAT9+0/N+aZ 8yw6BuRQ0+zC+nffW4qNzujzdaO1B/5z0nviVsbqe3lfIv5HLqwSR9W 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 74a7a50d1e78..8fffd10fad53 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -2287,7 +2287,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, struct m= odule *mod); /* 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 Fri Sep 25 22:19:31 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 37444380FCA; Tue, 8 Sep 2026 06:22:20 +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=1788848542; cv=none; b=iTwJgR/jLmDz0dMSsaFCVmpXBXCrcxiHiNrfWUq0uPCcQ1GlWgVPqmuCQ3Sf55PKhLgBwtyVzeyCr27Yq6fNaG/qwyO+OHmoI/lfoUjkS8mbsoMV6nAca8zuWZlLWH5YzF5KVDkdf9j2o6uephUj/AotlCv0a87IZpcIdZwZUR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788848542; c=relaxed/simple; bh=YY8c5L301iU3Aayfxj+VeR0xYVp0bNX5uug0M0tmkPA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KAWtVqrLx3QVRJHiyPp34gbLbOzyMgBam9lXyd+IV8uVu+Rm5sS4h2DsUyxX37nOXIppCSnTSQR69NxMmcB70qRZwyAW03SAWzijifWx/JtBwwVuwbS6/yvm4w6QOU0JJpSFW2uCTSLXeu+xB2MJeWSzF+ej4/UG0ZmjHbZFZZQ= 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=PZA3hP+B; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8GPU4oEK; 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="PZA3hP+B"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8GPU4oEK" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788848538; 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=h4sb6DZUE6ul1j4WR3dQwjkCoT7uBWyIVb1ZDOo3GtE=; b=PZA3hP+BoZEvlI/7rmXEzaghU6f63FSWBtHDFke4s1200ex9xzUzL5Tp2bj2/RE11WVDtO LU4SUQyudl1L1PxrS0PBcQk0MJwAzKDWV32M3VtXK1iDEgRlX37i/uqqMS7ukTiDMVQs6L ba6pv3N3aM8ia7maRfLJT4qwCJiXx+uIjevQ1FaV9oWSl5P68X8u4dKVPbnDnIqxzoH550 AJ0absyOjpMmwvevKk0Fztms0UDVr5yWpYOU8kHqJyClSPPj/Q5bsF/vkswWzI1kntzptC 0DSzXLj1QbvuAAXdHCguNKkgQAXUSGZq4uH3mw1XYv64WKxu+Hf9hm2nZfFPhg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788848538; 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=h4sb6DZUE6ul1j4WR3dQwjkCoT7uBWyIVb1ZDOo3GtE=; b=8GPU4oEKmBfWzXi1YtETNeyXdIFJt6Z8XVNFKBFR8jNPht32y3QP3BZ+g6YVgkHlyADRci IQXuWkpktHBSOTAg== Date: Tue, 08 Sep 2026 08:22:17 +0200 Subject: [PATCH v2 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: <20260908-tracing-cli-event-filter-v2-3-05396a3fb663@linutronix.de> References: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> In-Reply-To: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: linux-doc@vger.kernel.org, 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=1788848535; l=2586; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=YY8c5L301iU3Aayfxj+VeR0xYVp0bNX5uug0M0tmkPA=; b=UDLTuP+8J3xIvaFAlm+a/H34vae8oA4XS/l+ZVgUG8PXR8eDaUXLvSnQ751ZdMAcNBeJBnx3/ cUfPVBHzgEHAh2FzN7Sg5kW2o3JxT1TAto5PjvVwz9jZFDVSZ9s9Jmn 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 | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 5cbd09c8be8d..af46614bc75d 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -882,7 +882,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 eab653cb3540..88d0212ff2ca 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1440,14 +1440,19 @@ 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 *arg_buf, int = set) { char *event =3D NULL, *sub =3D NULL, *match, *mod; - int ret; + char *buf; =20 if (!tr) return -ENOENT; =20 + char *dupped_buf __free(kfree) =3D kstrdup(arg_buf, GFP_KERNEL); + if (!dupped_buf) + return -ENOMEM; + buf =3D dupped_buf; + /* Modules events can be appended with :mod: */ mod =3D strstr(buf, ":mod:"); if (mod) { @@ -1484,15 +1489,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 Fri Sep 25 22:19:31 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 9B81F381B1C; Tue, 8 Sep 2026 06:22:20 +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=1788848542; cv=none; b=Ey6rSM8RYQB9wtqMR6cLxKOdrr6Bg2JVgPjpjXL6Elg1ox4BiitUnVUzi6i6YPccWgYGvaRwt4sV0vBxE4HSDvQEjMaLeSff7s5ezetnjvjuy3luDxpCpFuWb081mfihWVxRezNXc22uvzrI5C+VRRSYjWGQVo91e2+SZ55NSrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788848542; c=relaxed/simple; bh=P9LZhluCeKIiFGbzqM6fDqg9P1GLsLImceM6YfjlBnw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mbjw1FLptqaQixl3oTte/ta4D3IaMECVH8lcfEFd3F7B1+hsmwg5S79mSqvtefjPHOXQ5CNJEmSmGVSkIibBGou04Boinbes5HhWopaVhZiSengUzQawu35b5adWjL4N6DvQq+HrfIvxfz8zFmJrykUM5xz2YqgPKi4gvTc6BfQ= 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=NzhIBJSb; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ogFoxsqT; 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="NzhIBJSb"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ogFoxsqT" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788848539; 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=oX47QCWixFRW8/1LS0ex98egxk9iLYoJ1TPMm4yBGpM=; b=NzhIBJSbZVdeGzlmN1b3vBCUHFalGC5LFS0HdJKbS7UVaJGwUMTSNAJL6uXHjEQ5V9qnt2 nkhDvdOlZ/tfLSpWFRwO4y5DhkIcGNGYnRXOJnph7cgIBEDdXc8yjO9/ko2nO0auWlsEGI gLhZehcOg+7Fbz1dylrLz4sQ6VS5VK/RdLbNvokI4H7jwCU7xaJupRJ7lJkocrnGfOd4j7 OytqmzT9G7g6FyNdpAFAC3ff8DUI+sIwXF2KvCZT8aDvrIBye5omDexErGOlpyvpVpsvd6 upWUrB9f2vaJAy2jnuTuaRjhVGm2vtJ8uQQT1LjAqOE9hSpQYWjeCHHeDiB02g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788848539; 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=oX47QCWixFRW8/1LS0ex98egxk9iLYoJ1TPMm4yBGpM=; b=ogFoxsqT8ZGb068zJP+4TDh+jVIizXq1RnfhKW9cCCinm5jrvW1FUV5xgGLEAj8YkPNOH4 qrsL8ebbIr8JBaBw== Date: Tue, 08 Sep 2026 08:22:18 +0200 Subject: [PATCH v2 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: <20260908-tracing-cli-event-filter-v2-4-05396a3fb663@linutronix.de> References: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> In-Reply-To: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: linux-doc@vger.kernel.org, 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=1788848535; l=2654; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=P9LZhluCeKIiFGbzqM6fDqg9P1GLsLImceM6YfjlBnw=; b=tQsR2sk46GODRSRUQzEKLqp58NIGourYVB2yN50mx6J+VN7y7FVUNxY3UYS3km9CNEK1ulwOn GfthvLioSQgDxJw2ULhumhCr7Qr+fmJoR3RVVX8f5iL69qkmUVNQY5j X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= This 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 | 61 +++++++++++++++++++++++++----------------= ---- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 88d0212ff2ca..4104ccbebf4a 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1440,25 +1440,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 *arg_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; - char *buf; - - if (!tr) - return -ENOENT; - - char *dupped_buf __free(kfree) =3D kstrdup(arg_buf, GFP_KERNEL); - if (!dupped_buf) - return -ENOMEM; - buf =3D dupped_buf; + *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 /* @@ -1473,21 +1466,35 @@ int ftrace_set_clr_event(struct trace_array *tr, co= nst char *arg_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 *arg_buf, int = set) +{ + char *event, *sub, *match, *mod; + + if (!tr) + return -ENOENT; + + char *dupped_buf __free(kfree) =3D kstrdup(arg_buf, GFP_KERNEL); + if (!dupped_buf) + return -ENOMEM; + + ftrace_parse_event_string(dupped_buf, &match, &sub, &event, &mod); =20 return __ftrace_set_clr_event(tr, match, sub, event, set, mod); } --=20 2.55.0 From nobody Fri Sep 25 22:19:31 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 1316F37FF68; Tue, 8 Sep 2026 06:22:21 +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=1788848544; cv=none; b=I5ByP2HkUakZ2vG1YaTD86UORidEFnK+MA1jQouHIeTpfE7AwwuwyZ+i59tO4F5gZ7iAyZjrYm5N06T6bwyef5i2DVHEkQJ0b0E1uYQsMP7eqbVbzgVTOxdkuJ6ZXJ55j3kD7G/lNtzuGOaIzKAyNy0cdIGzVdpCrgFna6ZB8bM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788848544; c=relaxed/simple; bh=5TVCsUrOMQYcESAbQ2G221/u2D2fA8NDkNdqUy0yaik=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Tsce8K/mYbF5cNWV0Tx7Mwhgk36/1bJaO2lgWiQgbPqKuznoYfY6esuvWSu+dUQQ6Z9Tbegq++RTtDWp4QQLQaMADoQJPU8md1sqFzoklqwDd0xL75AB7WSWnjUl/WTDk2EY3kcaVK0bHdDEHxALP0FNx4bKFz785bjhZsx3Z0I= 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=FIFX0nRK; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=lDHG4kqU; 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="FIFX0nRK"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lDHG4kqU" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788848539; 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=GssFXxtIHVdcg58tXsfZzX4oarFl2s1/f6rlQWfF6kw=; b=FIFX0nRKEOqyfGBvwZEnKZv/pSbmM4nnmEc+tk4d6FZcGE/DGZ73p+H71P8ztj9+YdThEX p2PEIO7FBNadsIy5+QWyKFldmk0fAnvcr0TEpCj5B7UfyRe2/K1iIskNtOjXULC4qvfDAX xTygW0X9FSKN84FfnEWwq9axoUcoJDP4nD/bmfAyU5vuuq7ARoxpFrel9AAUtL16ZRQhB0 HJifPrexdb3ENncM2i0ZGOmpOpsymFMk6QcFsUx1ZH86Tq9xmNCZyUtdSKMw5qkeLjkVDn 5P1P1W+VPLE1/ggzfWVtFKaY5eoQuus8zVGWj5bg0V2SQ+a9qnfVWC6rW6YRBw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788848539; 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=GssFXxtIHVdcg58tXsfZzX4oarFl2s1/f6rlQWfF6kw=; b=lDHG4kqUfaccOcS1bkxJ4aFh+2aMx6dHCCiKLP0o5q87aoTn2F9ZtwXyvoZoSF2v28zF4m sQKp8AgqlHT5KVAQ== Date: Tue, 08 Sep 2026 08:22:19 +0200 Subject: [PATCH v2 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: <20260908-tracing-cli-event-filter-v2-5-05396a3fb663@linutronix.de> References: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> In-Reply-To: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: linux-doc@vger.kernel.org, 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=1788848535; l=5394; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=5TVCsUrOMQYcESAbQ2G221/u2D2fA8NDkNdqUy0yaik=; b=LHAy7qOyB8OR6mKqYLGIpugvedEnjZGGDFS3oaGfppyyeQatQnzZ6caa0Xiq38BnD8PJyIjYG l9m0aGM+KkrA1HFNj/cu+Of1Xp1lyfKweD24NomCm/ETF1sfNa5PO8h 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 | 102 +++++++++++++++++++++++++++++++++++= ++++ 5 files changed, 119 insertions(+), 1 deletion(-) diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 0ab5916575a9..430a4152095e 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 8fffd10fad53..35f619a1655e 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -2506,3 +2506,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 4104ccbebf4a..7a491dbe6e81 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -25,6 +25,8 @@ #include #include =20 +#include + #include #include =20 @@ -1440,7 +1442,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; @@ -1482,6 +1484,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 *arg_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..515d2e668c31 --- /dev/null +++ b/kernel/trace/trace_events_test.c @@ -0,0 +1,102 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +#include + +#include "trace.h" + +struct parse_event_string_test_case { + const char *input; + + const char *match, *sub, *event, *mod; +}; + +static const struct parse_event_string_test_case parse_event_string_test_c= ases[] =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_string_test_desc(const struct parse_event_string_test_case *pa= rams, char *desc) +{ + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "'%s'", params->input); +} + +KUNIT_ARRAY_PARAM(parse_event_string, parse_event_string_test_cases, parse= _event_string_test_desc); + +#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_string(struct kunit *test) +{ + const struct parse_event_string_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_string, parse_event_string_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_DESCRIPTION("KUnit test for the event tracing implementation"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); --=20 2.55.0 From nobody Fri Sep 25 22:19:31 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 134EF3812DE; Tue, 8 Sep 2026 06:22:21 +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=1788848544; cv=none; b=pBJFqEOqL5J9pBk8mDlTLX/5iQgmX4Iz5LfoAiRo3rj7mIsOf6WYG/wInTsUqstGzq4Lh+JPSPtEZQWXjbwqnTm0rWZ1wCWjP3L3w4cjU1vCD7l6VtfPnMhCUi36B3Tz3OFsSPNewJm9YP+D3BVwNkKQlPTrvuBl4RHnaAA9vU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788848544; c=relaxed/simple; bh=WBf+zqJbBvN5xIbqWxhQ23l3IDDtZTVTqQvNQhY7iZs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XzzlwZUSNI7WHBa8ZUumLPnKWZHGDReacFK+LbYM1QV1zAqxrxNDDGt7p12AhkGqiovTGvSBkXq5FMT7x6P7/n6khqNQ14lROZ4itprmeS8/zUqTTNocAyZ0tU+C3AXqhqmUbZWpw0N2Hvlyex3wtBq/cGS7wUaKJUGe9XnJc9c= 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=qowH2sEU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=I/hPtNVQ; 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="qowH2sEU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="I/hPtNVQ" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788848539; 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=OpkTnovo4vbK9Ryr8abdG64TmDgSw2P4cKEhNt7uqj4=; b=qowH2sEUHDhHacv0cANwY6hAlOzn8Yeb6uEuD7+rCRh7Rf8EDoFRDSdnWJfaKWzLqzQsf3 mdRFtXpyBpLBVkauKDDgMdvCD7dX/oZT9sxb4QPj84wU6BGC8JNj/y6b5q1GVEIzGryMRU K9M0G2n65ztysmBY7YYO2aUKpJ/SqlOJpRKSDC+BnTWL69ElZnf+1DwcGr/GfPqEVCxuzM hwjT+in7cYouB/LbhClx6h+4QeWh1xAHarWpx0XWyGSXnV6Kh7mAxxB9UXwWAzjCcQR3aZ e/jS+4qWpX/CYrsotiIsla1z0TRQn+r3Bq6leu3tdgmQXuC/YeNkizL/YmUzIQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788848540; 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=OpkTnovo4vbK9Ryr8abdG64TmDgSw2P4cKEhNt7uqj4=; b=I/hPtNVQ1lBMdgH7XzoEZ2C2Nhp1R78xLeg9hzuZNMoMVwihvTmaOibDpy1sKeCXTY9sJ6 Te0o7UzwWFgcrLBw== Date: Tue, 08 Sep 2026 08:22:20 +0200 Subject: [PATCH v2 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: <20260908-tracing-cli-event-filter-v2-6-05396a3fb663@linutronix.de> References: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> In-Reply-To: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: linux-doc@vger.kernel.org, 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=1788848535; l=7325; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=WBf+zqJbBvN5xIbqWxhQ23l3IDDtZTVTqQvNQhY7iZs=; b=0UCIuq0xExQO0QrcwJ+GtXvc1nwzWMr7UdNTcq1peF2v8FCkzSFKXN6WTDrG2/fDU8wFR6Cjh tb4usoSk1sLB5jWAKxXwsIZ1TfMdVzWJXLKU1ELAFvohVTXWs87T8Ya 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 7a491dbe6e81..f8881a9d3c7a 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -943,6 +943,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) @@ -952,6 +953,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 @@ -993,7 +995,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 @@ -1032,6 +1034,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; @@ -1044,7 +1052,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; } @@ -1353,7 +1361,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; @@ -1403,7 +1411,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 @@ -1421,14 +1433,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 @@ -1436,7 +1448,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; @@ -1499,7 +1511,7 @@ int ftrace_set_clr_event(struct trace_array *tr, cons= t char *arg_buf, int set) =20 ftrace_parse_event_string(dupped_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 /** @@ -1521,7 +1533,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 @@ -1547,7 +1559,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 @@ -2067,7 +2079,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 @@ -4022,7 +4034,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); } } @@ -4796,7 +4809,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(); @@ -5106,7 +5119,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); @@ -5115,7 +5128,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); @@ -5130,7 +5143,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; @@ -5139,7 +5152,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 Fri Sep 25 22:19:31 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 BFCA6382F23; Tue, 8 Sep 2026 06:22:22 +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=1788848544; cv=none; b=T2hKuzneAhcDwdlPfDvdtldOfrqkevUy70K5KAsVNhPeQuJCarmICYyUHwC9CIetOMUKhwvxZIitrhzcX1LkOutmrH+yHRkrY/CyP06JK/saIeSx+kFAMUuR98oc59tz49sYndXseqwSNyDsSiVKEU4a6N3OwmJA27Z0Qq2ffKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788848544; c=relaxed/simple; bh=frgMevK5TVhiaL5RJpv209UOvEFNyDdYVbihdVW1tJ8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pyko8ew2DUOK7wDmBJ7GWT1nsnubMDTo2IcVJNdd0WwDwpFIht14SHcxHvIiA1AhZh517w26AzfYBASqC7FA7cfjamdOEYNhOhYmybLnMBEWVNhVXfhta8Hmp+IybG6eMJTh+mBiAMCSzEaQaA1nkgPZfOhw7s0VCel4WDXN+jQ= 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=rs5rvv9b; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=iEIntkcz; 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="rs5rvv9b"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iEIntkcz" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1788848540; 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=FbKyjWw5mfZHH0FX6Zh5pd3WFdFK8W+TfufQoK8ZQGQ=; b=rs5rvv9b8g4M4Cfyl39TyfZ+IMCKWKkLj5j/HDCUHviGL7lAIp8OxSezqolC7B0SqRffdP 1pRiYTRnqX8iVv4BumM0UJ1eHyxSbOk2IeHvARCgcLGTz7VKsMQ5rBPS2l6fGP1+VnPvNr E5tCpNh58uUmrkBh3ci0IbL60EEw0qr/JVOlNLU0zO0EMCm/p2lTVTOi9ih21EY59eVQ/W 2Qlanv0CgGe0g07eoFd9ea4AEQ9NS+jEpKm9LLiiffbPZNEu97gCsiwKMMM4fXJJUSmHt4 2+4BKmaTSmIAfMxI5kZdgLnsyUgvPfgPiUomh1OtitLEiqimmcw0I7rBfWsU1Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1788848540; 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=FbKyjWw5mfZHH0FX6Zh5pd3WFdFK8W+TfufQoK8ZQGQ=; b=iEIntkcz+LIDM0UmBJ829O1ZYbgdhIU6QNxGmOgH25r/+g54GewTuDl+7Pscgms5EmMjCT CTamRlOFNI+HttDQ== Date: Tue, 08 Sep 2026 08:22:21 +0200 Subject: [PATCH v2 7/7] tracing: Parse filter from boot 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: <20260908-tracing-cli-event-filter-v2-7-05396a3fb663@linutronix.de> References: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> In-Reply-To: <20260908-tracing-cli-event-filter-v2-0-05396a3fb663@linutronix.de> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: linux-doc@vger.kernel.org, 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=1788848535; l=8735; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=frgMevK5TVhiaL5RJpv209UOvEFNyDdYVbihdVW1tJ8=; b=qYDgbBKKc7G/UYGZrxg7iQhbfFk4xfG+6cwPAR+qYc1Wbrc39ACv/w5FcDdccSeVIqTM5dWXY wV6Ay+5QKPxB6xwWqRsShtu2MAlv3e+Hd83sN4wAbSb1fryhQxvh0MU 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. Example: trace_event=3Dsyscalls:sys_enter_clock_nanosleep:filter:which_clock=3D=3D0 Signed-off-by: Thomas Wei=C3=9Fschuh --- Documentation/admin-guide/kernel-parameters.txt | 9 +++++++-- Documentation/trace/events.rst | 5 +++++ include/linux/trace_events.h | 2 +- kernel/trace/trace.h | 3 ++- kernel/trace/trace_boot.c | 2 +- kernel/trace/trace_events.c | 27 +++++++++++++++++----= ---- kernel/trace/trace_events_test.c | 26 +++++++++++++++++++++= --- 7 files changed, 58 insertions(+), 16 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 68647ff4bdd2..63347a986706 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -7769,8 +7769,13 @@ Kernel parameters trace_event=3D:mod: =20 The value before :mod: will only enable specific events - that are part of the module. See the above mentioned - document for more information. + that are part of the module. + + To apply a filter, use the :filter: keyword: + + trace_event=3D...:filter: + + See the above mentioned document for more information. =20 trace_instance=3D[instance-info] [FTRACE] Create a ring buffer instance early in boot up. diff --git a/Documentation/trace/events.rst b/Documentation/trace/events.rst index 581f2260614b..6ce53372acbc 100644 --- a/Documentation/trace/events.rst +++ b/Documentation/trace/events.rst @@ -118,6 +118,11 @@ In order to facilitate early boot debugging, use boot = option:: event-list is a comma separated list of events. See section 2.1 for event format. =20 +The boot option also supports the ``:filter:`` keyword to apply a filter. +The ``:filter:`` keyword needs to be at the end of the event specification= :: + + ::mod::filter: + 3. Defining an event-enabled tracepoint =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index af46614bc75d..c1f6bb94f483 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -882,7 +882,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, const char *buf, int set); +int ftrace_set_clr_event(struct trace_array *tr, const char *buf, int set,= bool handle_filter); 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.h b/kernel/trace/trace.h index 35f619a1655e..2ec212d90192 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -2508,5 +2508,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, + bool handle_filter, char **filter); #endif diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c index 5da0a8bbb110..6ba70dac1f06 100644 --- a/kernel/trace/trace_boot.c +++ b/kernel/trace/trace_boot.c @@ -94,7 +94,7 @@ trace_boot_enable_events(struct trace_array *tr, struct x= bc_node *node) continue; } =20 - if (ftrace_set_clr_event(tr, buf, 1) < 0) + if (ftrace_set_clr_event(tr, buf, 1, false) < 0) pr_err("Failed to enable event: %s\n", p); } } diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index f8881a9d3c7a..2e2815d95c56 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -1455,10 +1455,21 @@ 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, + bool handle_filter, char **filter) { *event =3D NULL; *sub =3D NULL; + *filter =3D NULL; + + /* event filters can be appended with :filter: */ + if (handle_filter) { + *filter =3D strstr(buf, ":filter:"); + if (*filter) { + **filter =3D '\0'; + *filter +=3D 8; + } + } =20 /* Modules events can be appended with :mod: */ *mod =3D strstr(buf, ":mod:"); @@ -1498,9 +1509,9 @@ ftrace_parse_event_string(char *buf, char **match, ch= ar **sub, char **event, cha } EXPORT_SYMBOL_IF_KUNIT(ftrace_parse_event_string); =20 -int ftrace_set_clr_event(struct trace_array *tr, const char *arg_buf, int = set) +int ftrace_set_clr_event(struct trace_array *tr, const char *arg_buf, int = set, bool handle_filter) { - char *event, *sub, *match, *mod; + char *event, *sub, *match, *mod, *filter; =20 if (!tr) return -ENOENT; @@ -1509,9 +1520,9 @@ int ftrace_set_clr_event(struct trace_array *tr, cons= t char *arg_buf, int set) if (!dupped_buf) return -ENOMEM; =20 - ftrace_parse_event_string(dupped_buf, &match, &sub, &event, &mod); + ftrace_parse_event_string(dupped_buf, &match, &sub, &event, &mod, handle_= filter, &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 /** @@ -1593,7 +1604,7 @@ ftrace_event_write(struct file *file, const char __us= er *ubuf, if (*parser.buffer =3D=3D '!') set =3D 0; =20 - ret =3D ftrace_set_clr_event(tr, parser.buffer + !set, set); + ret =3D ftrace_set_clr_event(tr, parser.buffer + !set, set, false); if (ret) goto out_put; } @@ -4842,10 +4853,10 @@ static __init void __early_set_events(struct trace_= array *tr, char *buf, bool en while ((token =3D strsep(&buf, ","))) { if (*token) { if (enable) { - if (ftrace_set_clr_event(tr, token, 1)) + if (ftrace_set_clr_event(tr, token, 1, true)) pr_warn("Failed to enable trace event: %s\n", token); } else { - ftrace_set_clr_event(tr, token, 0); + ftrace_set_clr_event(tr, token, 0, true); } } =20 diff --git a/kernel/trace/trace_events_test.c b/kernel/trace/trace_events_t= est.c index 515d2e668c31..4a2d77fa0f58 100644 --- a/kernel/trace/trace_events_test.c +++ b/kernel/trace/trace_events_test.c @@ -8,7 +8,7 @@ struct parse_event_string_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_string_test_case parse_event_string_test_c= ases[] =3D { @@ -37,6 +37,12 @@ static const struct parse_event_string_test_case parse_e= vent_string_test_cases[] .sub =3D "sub", .event =3D "event", }, + { + "sub:event:filter:filter", + .sub =3D "sub", + .event =3D "event", + .filter =3D "filter", + }, { "match", .match =3D "match", @@ -51,6 +57,19 @@ static const struct parse_event_string_test_case parse_e= vent_string_test_cases[] .event =3D "event", .mod =3D "module", }, + { + "sub:event:mod:module:filter:filter", + .sub =3D "sub", + .event =3D "event", + .mod =3D "module", + .filter =3D "filter", + }, + { + "sub:event:mod:module:filter:unexpected-filter", + .sub =3D "sub", + .event =3D "event", + .mod =3D "module:filter:unexpected-filter", + }, }; =20 static void @@ -72,18 +91,19 @@ KUNIT_ARRAY_PARAM(parse_event_string, parse_event_strin= g_test_cases, parse_event static void parse_event_string(struct kunit *test) { const struct parse_event_string_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, params->filt= er, &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