From nobody Fri Oct 2 06:17:08 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 2DF5F485CDA for ; Tue, 4 Aug 2026 17:43:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865404; cv=none; b=KYJjAXy4ltpr8ICUz4ILw79UWGXbRlTH/FwDd84apjdg6vgKR4h/7uWQ17grYN1j82+w/po0yrr8VccPr8duv25SxqaDYypZE57mADI6zVHrjH7XFeeOsuWrcno1G2v+qo7TApdkASaQtdb6FBkLDxKMo93S7oQ2OxUxuOjp2xI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865404; c=relaxed/simple; bh=dQafBnijouqMjy3pJ+JGvQ3Lx38g2EjDegrTCOoR974=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UOI3/fvSYn7ziE/DgKe0fEj8HmPQLDU6UdgNhDC568RJpImvK/285rbRxr61FdpusOXd/aiinKbtO22RUiVfGXIvzzX2caRluAxxhkuifgELfrJfToOnDIY9LMSIeKhHsMslMHisJsOTi/X7pgYFnFE2A+XKWP8QhE4EtFYGsK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=g4iyBEwO; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g4iyBEwO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785865402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qqt3NijuaP9d9I1bY77shy06Tx7yDwPkFM7B3C4MGt4=; b=g4iyBEwOm/8W1D7wTyd4o0JbkuKOU2johUIySnoxNuaO1iNsSG2Bwpu4Qd1WtZpM74ATLm 7+Eyzfpx4ZWy2W/hQpCWfa8U6KWxfuSC5rZEKONlGe4mzFHw27Tj3SCqtw9bZmmjjnpJDw oHN8/QOcDdRv1LUS7kKrGtpgfgUZFn4= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-9Ppxk5l_NDe8_Fv-F5qU6Q-1; Tue, 04 Aug 2026 13:43:19 -0400 X-MC-Unique: 9Ppxk5l_NDe8_Fv-F5qU6Q-1 X-Mimecast-MFC-AGG-ID: 9Ppxk5l_NDe8_Fv-F5qU6Q_1785865396 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9FBA31955DAF; Tue, 4 Aug 2026 17:43:16 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.34.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3EC4D195608E; Tue, 4 Aug 2026 17:43:12 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Tomas Glozar , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Costa Shulyupin , Crystal Wood , John Kacur , Ivan Pravdin , Jonathan Corbet Subject: [PATCH v4 1/6] rtla/osnoise: Add IPI tracking cmdline option Date: Tue, 4 Aug 2026 19:42:33 +0200 Message-ID: <20260804174242.2288433-2-vschneid@redhat.com> In-Reply-To: <20260804174242.2288433-1-vschneid@redhat.com> References: <20260804174242.2288433-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Later commits will add IPI tracking to osnoise top. To avoid breaking existing scripts, this new feature will be gated behind a new --ipi option. Suggested-by: Tomas Glozar Signed-off-by: Valentin Schneider --- Documentation/tools/rtla/rtla-osnoise-top.rst | 4 ++++ tools/tracing/rtla/src/cli.c | 1 + tools/tracing/rtla/src/cli_p.h | 3 +++ tools/tracing/rtla/src/common.h | 1 + 4 files changed, 9 insertions(+) diff --git a/Documentation/tools/rtla/rtla-osnoise-top.rst b/Documentation/= tools/rtla/rtla-osnoise-top.rst index b91c02ac2bbe1..b948a813d45cb 100644 --- a/Documentation/tools/rtla/rtla-osnoise-top.rst +++ b/Documentation/tools/rtla/rtla-osnoise-top.rst @@ -28,6 +28,10 @@ OPTIONS =3D=3D=3D=3D=3D=3D=3D .. include:: common_osnoise_options.txt =20 +**--ipi** + + Track sources of IPIs. + .. include:: common_top_options.txt =20 .. include:: common_options.txt diff --git a/tools/tracing/rtla/src/cli.c b/tools/tracing/rtla/src/cli.c index c5279c9875310..eb1e76a6b0dea 100644 --- a/tools/tracing/rtla/src/cli.c +++ b/tools/tracing/rtla/src/cli.c @@ -78,6 +78,7 @@ struct common_params *osnoise_top_parse_args(int argc, ch= ar **argv) RTLA_OPT_STOP_TOTAL('S', "stop-total", "total sample"), OSNOISE_OPT_THRESHOLD, RTLA_OPT_TRACE_OUTPUT("osnoise", opt_osnoise_trace_output_cb), + OSNOISE_OPT_IPI, =20 OPT_GROUP("Event Configuration:"), RTLA_OPT_EVENT, diff --git a/tools/tracing/rtla/src/cli_p.h b/tools/tracing/rtla/src/cli_p.h index 3c939de9abf02..d120fac424e30 100644 --- a/tools/tracing/rtla/src/cli_p.h +++ b/tools/tracing/rtla/src/cli_p.h @@ -305,6 +305,9 @@ static int opt_filter_cb(const struct option *opt, cons= t char *arg, int unset) "the minimum delta to be considered a noise", \ opt_llong_callback) =20 +#define OSNOISE_OPT_IPI OPT_BOOLEAN(0, "ipi", ¶ms->common.ipi, \ + "track sources of IPIs") + /* * Callback functions for command line options for osnoise tools */ diff --git a/tools/tracing/rtla/src/common.h b/tools/tracing/rtla/src/commo= n.h index 04b287a03f6d4..045253230fcf2 100644 --- a/tools/tracing/rtla/src/common.h +++ b/tools/tracing/rtla/src/common.h @@ -108,6 +108,7 @@ struct common_params { bool kernel_workload; bool user_data; bool aa_only; + bool ipi; =20 struct actions threshold_actions; struct actions end_actions; --=20 2.55.0 From nobody Fri Oct 2 06:17:08 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 1CD894BC018 for ; Tue, 4 Aug 2026 17:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865408; cv=none; b=TK2g/c6hSfjANkV8eD5GYLOCYJuhHSs+v8K05wXdrWYmSE3XcBLvGWsgcJRjiqK6hfl1x0xCO0IlSsbSLcaTDhVgH3S/G+Ih0BXHLLhoag/rQwujN8cEuQuHvQQ0eDcfL7HyOs1gSx0CIl+cB2NK3mG/u8i+c6ch6994Ob96ARQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865408; c=relaxed/simple; bh=fDxH/Te0cQFp5ShQesuIMkvuRo5iX/+PNojmEZYHOvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+DT45lWaWrqyBvkddMj0ka/jwe0eoXEFDXlcZIB2884xlV98w72yj7j5ZesyIKROC70TBquivLzrXDUg3g6tToEyAbku+EhIcr607xGDtixhuZyHy1wszz/tx1PNWiLAkrRxvyi7ATtQOyLBRQ9IG2JeBm3tC6FFy+xptLtxPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XoHff1Zc; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XoHff1Zc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785865406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=POtjo3MS/3gDN7qLigZ6UysW0mOjgCNLxkaaquz7gMg=; b=XoHff1Zcgq4f+xoXw98z0J2SFy+cIOlUnH6Q6y1cf5+j/HFn1HMdrBi3j+sf+Rfrp04grT IgInCtpLtPyU8vcacmxmE+QRklMxyleZxllNVe8WnwiBTJUaQXOucX3uD491vcDEaNysmr KmjphpwyTNMmH8TN9CYrdAaGbHgodQg= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-RRTCfGMTOoeTRwfTLI3gnw-1; Tue, 04 Aug 2026 13:43:21 -0400 X-MC-Unique: RRTCfGMTOoeTRwfTLI3gnw-1 X-Mimecast-MFC-AGG-ID: RRTCfGMTOoeTRwfTLI3gnw_1785865400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F08E19560B7; Tue, 4 Aug 2026 17:43:20 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.34.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 22C97195608E; Tue, 4 Aug 2026 17:43:16 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Ivan Pravdin , Jonathan Corbet Subject: [PATCH v4 2/6] rtla/osnoise: Record IPI count in osnoise top Date: Tue, 4 Aug 2026 19:42:34 +0200 Message-ID: <20260804174242.2288433-3-vschneid@redhat.com> In-Reply-To: <20260804174242.2288433-1-vschneid@redhat.com> References: <20260804174242.2288433-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Leverage the ipi_send_cpu and ipi_send_cpumask trace events to record the count of IPIs sent to monitored CPUs. These interferences are already accounted by the IRQ count, but this split gives a better overall picture. This uses the newly added --ipi cmdline option. Signed-off-by: Valentin Schneider --- tools/tracing/rtla/src/osnoise_top.c | 116 ++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 512a6299cb018..7b5ae5336cf08 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include =20 @@ -25,6 +26,7 @@ struct osnoise_top_cpu { unsigned long long irq_count; unsigned long long softirq_count; unsigned long long thread_count; + unsigned long long ipi_count; =20 int sum_cycles; }; @@ -164,6 +166,8 @@ static void osnoise_top_header(struct osnoise_tool *top) goto eol; =20 trace_seq_printf(s, " IRQ Softirq Thread"); + if (params->common.ipi) + trace_seq_printf(s, " IPI"); =20 eol: if (pretty) @@ -218,7 +222,10 @@ static void osnoise_top_print(struct osnoise_tool *too= l, int cpu) =20 trace_seq_printf(s, "%12llu ", cpu_data->irq_count); trace_seq_printf(s, "%12llu ", cpu_data->softirq_count); - trace_seq_printf(s, "%12llu\n", cpu_data->thread_count); + trace_seq_printf(s, "%12llu", cpu_data->thread_count); + if (params->common.ipi) + trace_seq_printf(s, " %12llu", cpu_data->ipi_count); + trace_seq_printf(s, "\n"); } =20 /* @@ -275,12 +282,93 @@ osnoise_top_apply_config(struct osnoise_tool *tool) return -1; } =20 +static void account_ipi(struct osnoise_tool *tool, unsigned long long dst_= cpu) +{ + struct osnoise_top_cpu *cpu_data; + struct osnoise_top_data *data; + unsigned long long inc =3D 1; + + data =3D tool->data; + cpu_data =3D &data->cpu_data[dst_cpu]; + + update_sum(&cpu_data->ipi_count, &inc); +} + +/* + * osnoise_ipi_cpu_handler - this is the handler for single CPU IPI events. + */ +static int +osnoise_ipi_cpu_handler(struct trace_seq *s, struct tep_record *record, + struct tep_event *event, void *context) +{ + struct osnoise_tool *tool; + struct osnoise_params *params; + unsigned long long dst_cpu; + struct trace_instance *trace =3D context; + + tool =3D container_of(trace, struct osnoise_tool, trace); + params =3D to_osnoise_params(tool->params); + + tep_get_field_val(s, event, "cpu", record, &dst_cpu, 1); + + if (CPU_ISSET(dst_cpu, ¶ms->common.monitored_cpus)) + account_ipi(tool, dst_cpu); + + return 0; +} + +static cpu_set_t cpumask_tmp_cpus; + +/* + * osnoise_ipi_cpumask_handler - this is the handler for broadcasted IPI e= vents. + */ +static int +osnoise_ipi_cpumask_handler(struct trace_seq *s, struct tep_record *record, + struct tep_event *event, void *context) +{ + struct trace_instance *trace =3D context; + struct osnoise_tool *tool; + struct osnoise_params *params; + struct tep_format_field *field; + cpu_set_t *event_cpus; + int len; + + tool =3D container_of(trace, struct osnoise_tool, trace); + params =3D to_osnoise_params(tool->params); + + field =3D tep_find_field(event, "cpumask"); + if (!field) + return 0; + + event_cpus =3D tep_get_field_raw(s, event, "cpumask", record, &len, 1); + if (!event_cpus) { + err_msg("Failed to get cpumask field\n"); + return 0; + } + + CPU_AND(&cpumask_tmp_cpus, event_cpus, ¶ms->common.monitored_cpus); + + /* + * Computing the mask weight is overkill but there is no leaner option + * provided by glibc, e.g cpumask_first() or somesuch. + */ + if (CPU_COUNT(&cpumask_tmp_cpus)) { + for (int cpu =3D 0; cpu < nr_cpus; cpu++) { + if (CPU_ISSET(cpu, &cpumask_tmp_cpus)) + account_ipi(tool, cpu); + } + } + + return 0; +} + /* * osnoise_init_top - initialize a osnoise top tool with parameters */ struct osnoise_tool *osnoise_init_top(struct common_params *params) { struct osnoise_tool *tool; + int retval; =20 tool =3D osnoise_init_tool("osnoise_top"); if (!tool) @@ -295,7 +383,33 @@ struct osnoise_tool *osnoise_init_top(struct common_pa= rams *params) tep_register_event_handler(tool->trace.tep, -1, "ftrace", "osnoise", osnoise_top_handler, NULL); =20 + if (!params->ipi) + goto out; + + retval =3D tracefs_event_enable(tool->trace.inst, "ipi", "ipi_send_cpu"); + if (retval < 0 && !errno) { + err_msg("Could not find ipi_send_cpu event\n"); + goto out_err; + } + + retval =3D tracefs_event_enable(tool->trace.inst, "ipi", "ipi_send_cpumas= k"); + if (retval < 0 && !errno) { + err_msg("Could not find ipi_send_cpumask event\n"); + goto out_err; + } + + tep_register_event_handler(tool->trace.tep, -1, "ipi", "ipi_send_cpu", + osnoise_ipi_cpu_handler, NULL); + + tep_register_event_handler(tool->trace.tep, -1, "ipi", "ipi_send_cpumask", + osnoise_ipi_cpumask_handler, NULL); + +out: return tool; +out_err: + osnoise_free_top_tool(tool); + osnoise_destroy_tool(tool); + return NULL; } =20 struct tool_ops osnoise_top_ops =3D { --=20 2.55.0 From nobody Fri Oct 2 06:17:08 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 636FA485CDA for ; Tue, 4 Aug 2026 17:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865409; cv=none; b=uce6wzv7QJi7cx/MTQZ/woaHHUw+g+ThxboNgqNLcOhnu648eg7BWJjp86EI+W7x/e6qIjA0MoeOWCpeIH2xb9hQDN4z60smwkZIVYRu9MTDtGfNi3aKULnWMTVN6jyntT4s+agzTMMuO1Wa46JNGEXzq9xOdGNs0VOmZyR2qQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865409; c=relaxed/simple; bh=Na7db9/2s80znu/9AE5DCwfjSCJNFyIOryOmFE9wqsM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dPrwku+13btU++DSEnrQgiChW/uF4ByU8MzMCsKhndFcss/jVPBE8WbdkTUbLL3BLLFl2FXl2UUrZPztELYWlFwodAhCLAva+kBEG/jlqRHeM8oliIFYAAWTaoZq5rMuOMNr6N6OQDlbJ4T1IoS8HNp4x/WEkIe0KyXEp3HwZO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dZCy2dss; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dZCy2dss" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785865407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XtAUMyjozqDTITd3GB3tSLmdiU/PUp/kO4z4pdtBy74=; b=dZCy2dssabQSDQ5nIXwHY5IeddM0Vyr92wARYWiWZc+7+NXFvcuCE3zeR40fr/v6pbQpi6 qi9AhJFYhqv1IVy3psf/kQVlsgV4LplUvufCIJbZ1IUcDKoOUoXoWonQz+CKo6bI6LZNEj W2AjSaEtnqs19Ok5TGTqPB/DjyqXchk= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-ez0zFdWoOX-djmQnZk_cyQ-1; Tue, 04 Aug 2026 13:43:26 -0400 X-MC-Unique: ez0zFdWoOX-djmQnZk_cyQ-1 X-Mimecast-MFC-AGG-ID: ez0zFdWoOX-djmQnZk_cyQ_1785865404 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8EF65195604B; Tue, 4 Aug 2026 17:43:24 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.34.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EF314195422C; Tue, 4 Aug 2026 17:43:20 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Ivan Pravdin , Jonathan Corbet Subject: [PATCH v4 3/6] rtla/osnoise: Leverage IPI event filters when tracing a subset of CPUs Date: Tue, 4 Aug 2026 19:42:35 +0200 Message-ID: <20260804174242.2288433-4-vschneid@redhat.com> In-Reply-To: <20260804174242.2288433-1-vschneid@redhat.com> References: <20260804174242.2288433-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Leverage the kernel event filtering infrastructure to only emit IPI events if they target CPUs that are being traced, as specified by the -c cmdline option. Note that some post-processing is still required for the ipi_send_cpumask event, as the event being emitted means *some* CPUs targeted by that event are monitored, but not all of them - userspace has to recompute that intersection. Signed-off-by: Valentin Schneider --- tools/tracing/rtla/src/osnoise_top.c | 38 ++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 7b5ae5336cf08..353b435fefcf8 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -302,17 +302,13 @@ osnoise_ipi_cpu_handler(struct trace_seq *s, struct t= ep_record *record, struct tep_event *event, void *context) { struct osnoise_tool *tool; - struct osnoise_params *params; unsigned long long dst_cpu; struct trace_instance *trace =3D context; =20 tool =3D container_of(trace, struct osnoise_tool, trace); - params =3D to_osnoise_params(tool->params); - tep_get_field_val(s, event, "cpu", record, &dst_cpu, 1); =20 - if (CPU_ISSET(dst_cpu, ¶ms->common.monitored_cpus)) - account_ipi(tool, dst_cpu); + account_ipi(tool, dst_cpu); =20 return 0; } @@ -346,6 +342,11 @@ osnoise_ipi_cpumask_handler(struct trace_seq *s, struc= t tep_record *record, return 0; } =20 + /* + * Despite already filtering for such an intersection, we need to compute + * the intersection here as the @cpumask field may contain non-monitored + * CPUs. + */ CPU_AND(&cpumask_tmp_cpus, event_cpus, ¶ms->common.monitored_cpus); =20 /* @@ -398,6 +399,33 @@ struct osnoise_tool *osnoise_init_top(struct common_pa= rams *params) goto out_err; } =20 + /* + * If tracing on a subset of possible CPUs, leverage the kernel filtering + * infrastructure to only generate events on traced CPUs. + */ + if (params->cpus) { + char filter[MAX_PATH]; + + snprintf(filter, ARRAY_SIZE(filter), "cpu & CPUS{%s}\n", params->cpus); + retval =3D tracefs_event_file_write(tool->trace.inst, + "ipi", "ipi_send_cpu", "filter", + filter); + if (retval < 0) { + err_msg("Could not set ipi_send_cpu CPU filter\n"); + goto out_err; + } + + + snprintf(filter, ARRAY_SIZE(filter), "cpumask & CPUS{%s}\n", params->cpu= s); + retval =3D tracefs_event_file_write(tool->trace.inst, + "ipi", "ipi_send_cpumask", "filter", + filter); + if (retval < 0) { + err_msg("Could not set ipi_send_cpumask CPU filter\n"); + goto out_err; + } + } + tep_register_event_handler(tool->trace.tep, -1, "ipi", "ipi_send_cpu", osnoise_ipi_cpu_handler, NULL); =20 --=20 2.55.0 From nobody Fri Oct 2 06:17:08 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 3E5DF4968FD for ; Tue, 4 Aug 2026 17:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865415; cv=none; b=Nw/d6UUKimVtNkjhNHovMiqFzgFNYUrKh/bn9dFNsFZuag6S58T3tKYDygFZGsrvC9YaYxEU281O2iqfSDmSdJsva8abBMHK0ECCOW9OSRe87cCwpSWfykvOdoz1X8ToMDANqJqkoEs6F3w+uPxtPphEcNmwewvQXIlu9k11p9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865415; c=relaxed/simple; bh=APOsm8JAmb4xKko1LI/DErr6AxacMhKSZv2IlIg/kzw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dxHQHzAopXqmZeXInWeY7YwVJ5LYOjb39LVgqkgTtdkRwhQJM9wq/a/YqThX3DJaSceRhE+zOYhw+hNHjhXi6pHxGt4GPCR0Abhwa+K3CzMrwPXqB8srGgI61lx0qWsmjatYx0dlTWKoJl4PTCWIlWS/e0Vl7xozgfXiHn+X+T8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WlYhjOu0; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WlYhjOu0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785865413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UCxPgKyWjQRuxjOhKVOZFlCvpZ99tG2XrAFjK938emU=; b=WlYhjOu0MF/wZoRcyo+LjSZd5shMLPI+pfRjWl7KnBjFLU/+UN24rhCPfiNv3Rf0OiAbHK I2vlwAgI+43kgQZ3DLZiA+z/33aUSRa8oanGGPoZRbrGdlOvzfwJP0yjCc/q8JWFwrjg6o UizWGObJTyrTCdxMaKIXV0Z9yXXb5DE= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-bhrZ8sBmM4Sdr8g8GoO1ZA-1; Tue, 04 Aug 2026 13:43:31 -0400 X-MC-Unique: bhrZ8sBmM4Sdr8g8GoO1ZA-1 X-Mimecast-MFC-AGG-ID: bhrZ8sBmM4Sdr8g8GoO1ZA_1785865409 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A0D81956044; Tue, 4 Aug 2026 17:43:29 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.34.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 265D0195608E; Tue, 4 Aug 2026 17:43:24 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Tomas Glozar , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Costa Shulyupin , Crystal Wood , John Kacur , Ivan Pravdin , Jonathan Corbet Subject: [PATCH v4 4/6] rtla/osnoise: Allow IPI filters to gracefully fail Date: Tue, 4 Aug 2026 19:42:36 +0200 Message-ID: <20260804174242.2288433-5-vschneid@redhat.com> In-Reply-To: <20260804174242.2288433-1-vschneid@redhat.com> References: <20260804174242.2288433-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" Kernels pre v6.6 won't have: 39f7c41c908b ("tracing/filters: Enable filtering a cpumask field by anoth= er cpumask") and thus won't be able to filter events using a user-provided cpumask, but will still be capable of recording IPI events. Make failing to set a filter for IPI events an acceptable error and fall back to event handlers that do the filtering job themselves. Suggested-by: Tomas Glozar Signed-off-by: Valentin Schneider --- tools/tracing/rtla/src/osnoise_top.c | 49 +++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 353b435fefcf8..afab2f341a1e9 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -313,6 +313,30 @@ osnoise_ipi_cpu_handler(struct trace_seq *s, struct te= p_record *record, return 0; } =20 +/* + * osnoise_ipi_cpu_unfiltered_handler - this is the handler for single CPU= IPI + * events. Slightly less optimized th= an + * the filtered variant. + */ +static int +osnoise_ipi_cpu_unfiltered_handler(struct trace_seq *s, struct tep_record = *record, + struct tep_event *event, void *context) +{ + struct osnoise_tool *tool; + unsigned long long dst_cpu; + struct osnoise_params *params; + struct trace_instance *trace =3D context; + + tool =3D container_of(trace, struct osnoise_tool, trace); + params =3D to_osnoise_params(tool->params); + tep_get_field_val(s, event, "cpu", record, &dst_cpu, 1); + + if (CPU_ISSET(dst_cpu, ¶ms->common.monitored_cpus)) + account_ipi(tool, dst_cpu); + + return 0; +} + static cpu_set_t cpumask_tmp_cpus; =20 /* @@ -343,7 +367,7 @@ osnoise_ipi_cpumask_handler(struct trace_seq *s, struct= tep_record *record, } =20 /* - * Despite already filtering for such an intersection, we need to compute + * Even if already filtering for such an intersection, we need to compute * the intersection here as the @cpumask field may contain non-monitored * CPUs. */ @@ -368,6 +392,7 @@ osnoise_ipi_cpumask_handler(struct trace_seq *s, struct= tep_record *record, */ struct osnoise_tool *osnoise_init_top(struct common_params *params) { + bool ipi_filters_enabled =3D false; struct osnoise_tool *tool; int retval; =20 @@ -402,6 +427,8 @@ struct osnoise_tool *osnoise_init_top(struct common_par= ams *params) /* * If tracing on a subset of possible CPUs, leverage the kernel filtering * infrastructure to only generate events on traced CPUs. + * Older kernels (pre v6.6) may have the IPI events but not the ability + * to filter them, so allow that to fail gracefully. */ if (params->cpus) { char filter[MAX_PATH]; @@ -411,8 +438,8 @@ struct osnoise_tool *osnoise_init_top(struct common_par= ams *params) "ipi", "ipi_send_cpu", "filter", filter); if (retval < 0) { - err_msg("Could not set ipi_send_cpu CPU filter\n"); - goto out_err; + debug_msg("Could not set ipi_send_cpu CPU filter\n"); + goto no_filter; } =20 =20 @@ -421,13 +448,27 @@ struct osnoise_tool *osnoise_init_top(struct common_p= arams *params) "ipi", "ipi_send_cpumask", "filter", filter); if (retval < 0) { + /* + * If we managed to set up the previous filter but not + * this one, something's really wrong + */ err_msg("Could not set ipi_send_cpumask CPU filter\n"); goto out_err; } + + ipi_filters_enabled =3D true; } +no_filter: =20 + /* + * If no filtering is available and we're tracing all CPUs, we can still + * use the filtered callback since stats are collected for all CPUs. + */ tep_register_event_handler(tool->trace.tep, -1, "ipi", "ipi_send_cpu", - osnoise_ipi_cpu_handler, NULL); + (!params->cpus || ipi_filters_enabled) ? + osnoise_ipi_cpu_handler : + osnoise_ipi_cpu_unfiltered_handler, + NULL); =20 tep_register_event_handler(tool->trace.tep, -1, "ipi", "ipi_send_cpumask", osnoise_ipi_cpumask_handler, NULL); --=20 2.55.0 From nobody Fri Oct 2 06:17:08 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 BE34F4963CA for ; Tue, 4 Aug 2026 17:43:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865438; cv=none; b=GxOwQEWTSKtljJzR1mtR8idAqTS6Mn/M9XIPwuu1AwG+LFUUEUT6gmCmvVpxImBToOSx4MBbCMPd4g6sKjSa059eqlwzc4Q9iE/I1iK0UPA+FKcn5WQDzYlJflk1eYg6/IEenH42FvSLY3GTzTq4JH2K9M3TiGYIAoPiT+HTbjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865438; c=relaxed/simple; bh=6j6oFNDGCW22dPi/OuojAv6AgzWQQtmzdQGiZwBPIS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iA8Q3y4cFE549SkWHOV5xynAJ4TTgKi2SMcNx5cYpPOwbmmi2OID7mOlF8gjeGiqInOWN3VydtBSc5IdQDFSswDF26hq5gA3iF+VBKEwf5EJf01zOlxCzhU8L8tti9kZu1Tc/cDvedgwac2+aCg7gneh3chczgYYW5LPq3LoppA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Jmc5AzDq; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Jmc5AzDq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785865435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZyfMFThYySVUZ/UP9vZ/no6yT92LHdHbfgfkLQhYtrY=; b=Jmc5AzDqiFVtYeIJjkXKXKpUlInUezXRm9dzgkRMN3Lq2uOYEgkWz2S9sLmk7fFPfvMlXb bdnDFH6djnZHpVUf7nK/LxH8SDauSNpK8tJcPQlGldSaRPboR3OAK7i4KLXS1vVyZoAque su6HZ1kXGDHdKHG5YrRcc1dQ6+POcho= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-Hq0rdqakNAeJfEKXDx4n-g-1; Tue, 04 Aug 2026 13:43:37 -0400 X-MC-Unique: Hq0rdqakNAeJfEKXDx4n-g-1 X-Mimecast-MFC-AGG-ID: Hq0rdqakNAeJfEKXDx4n-g_1785865413 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6EBF81800364; Tue, 4 Aug 2026 17:43:33 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.34.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9ACEF195608E; Tue, 4 Aug 2026 17:43:29 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Tomas Glozar , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Costa Shulyupin , Crystal Wood , John Kacur , Ivan Pravdin , Jonathan Corbet Subject: [PATCH v4 5/6] rtla: Unconditionally clean any pre-existing filters for user-provided events Date: Tue, 4 Aug 2026 19:42:37 +0200 Message-ID: <20260804174242.2288433-6-vschneid@redhat.com> In-Reply-To: <20260804174242.2288433-1-vschneid@redhat.com> References: <20260804174242.2288433-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" A later commit will apply a filter to events recorded to the trace output. To prevent any user confusion, remove pre-existing filters when enabling an event provided via the '-e' command line argument. Suggested-by: Tomas Glozar Signed-off-by: Valentin Schneider --- tools/tracing/rtla/src/trace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c index e407447773d04..f67f02cc92cdd 100644 --- a/tools/tracing/rtla/src/trace.c +++ b/tools/tracing/rtla/src/trace.c @@ -473,6 +473,10 @@ static int trace_event_enable_filter(struct trace_inst= ance *instance, char filter[MAX_PATH]; int retval; =20 + /* Unconditionally clean any pre-existing filters */ + tracefs_event_file_write(instance->inst, tevent->system, + tevent->event, "filter", "0"); + if (!tevent->filter) return 0; =20 --=20 2.55.0 From nobody Fri Oct 2 06:17:08 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 74FAB4963B6 for ; Tue, 4 Aug 2026 17:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865428; cv=none; b=QSc6INp1LitulA4VEElQAXGrzSjZYIdZoYYkg9rzY0TkYLBu9Uv8bLt12HJF63P8c0fn9CnOh8MsVeIeyHsxcxH3W8zIMZ4kR3FOdQFGvjB0ZXoEKA+RzPMzSpw56bR9bSrF5c/OZ9cRRRf1/Z9XFOrS/wX4L8dHKMRqRpGcGK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785865428; c=relaxed/simple; bh=xyTZtukQ0nTIad9odCB2JAq1OSBUbce1d5b+4Bs6x8A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nx0PStEUQQaAP5rjkGZnYFYHc76PHE8FBMb5G8jfuxp7lGILY7Kiz708etYJNMT3QF18bLTR0vnD61HN8R5e572v8pxuCSsSCZsHA/ubYGXVvfbK4IiSyBD+iXmBxhMYRXuh6hHqMX3Hwhc3sSGDF0N8YCaINgTveH9Vaw99Q/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ENy5cnxJ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ENy5cnxJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785865425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hioaiPo7qfRBBdUI+++gzH6e7JfDnvI7QypkLOQkxAg=; b=ENy5cnxJM6vp5svmwMfFcLdGGrCdt9Qt37flv9mkBT29UC50urxfRV/UYmgQh/+57LmSWl NshUJRjkf01pBi8+4Xcou+xIQVcAhPD7+8pUYVDnLay3sJTi99LayW4xePjPNABLa2ajtE dBlUFD40hL6e1VP+48j146vIDJPA2dI= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-332-GUyYSBn5Nk-jgJnT-drIYA-1; Tue, 04 Aug 2026 13:43:39 -0400 X-MC-Unique: GUyYSBn5Nk-jgJnT-drIYA-1 X-Mimecast-MFC-AGG-ID: GUyYSBn5Nk-jgJnT-drIYA_1785865417 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9DEF31800599; Tue, 4 Aug 2026 17:43:37 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.34.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 095721956043; Tue, 4 Aug 2026 17:43:33 +0000 (UTC) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Ivan Pravdin , Jonathan Corbet Subject: [PATCH v4 6/6] rtla/osnoise: Trace IPI events when recording a trace file Date: Tue, 4 Aug 2026 19:42:38 +0200 Message-ID: <20260804174242.2288433-7-vschneid@redhat.com> In-Reply-To: <20260804174242.2288433-1-vschneid@redhat.com> References: <20260804174242.2288433-1-vschneid@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" IPIs can now be monitored and accounted by osnoise top. When that is the case, also record them when saving a trace file. To match what is being recorded by the tool for its own analysis, event filters are applied to the events recorded to the trace output. Signed-off-by: Valentin Schneider --- tools/tracing/rtla/src/common.c | 2 +- tools/tracing/rtla/src/common.h | 2 +- tools/tracing/rtla/src/osnoise.c | 72 +++++++++++++++++++++++++++- tools/tracing/rtla/src/osnoise.h | 4 ++ tools/tracing/rtla/src/osnoise_top.c | 36 ++------------ 5 files changed, 80 insertions(+), 36 deletions(-) diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/commo= n.c index 8c7f5e75b2ec8..2f6cf83475550 100644 --- a/tools/tracing/rtla/src/common.c +++ b/tools/tracing/rtla/src/common.c @@ -205,7 +205,7 @@ int run_tool(struct tool_ops *ops, int argc, char *argv= []) =20 if (params->threshold_actions.present[ACTION_TRACE_OUTPUT] || params->end_actions.present[ACTION_TRACE_OUTPUT]) { - tool->record =3D osnoise_init_trace_tool(ops->tracer); + tool->record =3D osnoise_init_trace_tool(params, ops->tracer); if (!tool->record) { err_msg("Failed to enable the trace instance\n"); goto out_free; diff --git a/tools/tracing/rtla/src/common.h b/tools/tracing/rtla/src/commo= n.h index 045253230fcf2..421e06e10f3f1 100644 --- a/tools/tracing/rtla/src/common.h +++ b/tools/tracing/rtla/src/common.h @@ -178,7 +178,7 @@ int osnoise_set_workload(struct osnoise_context *contex= t, bool onoff); =20 void osnoise_destroy_tool(struct osnoise_tool *top); struct osnoise_tool *osnoise_init_tool(char *tool_name); -struct osnoise_tool *osnoise_init_trace_tool(const char *tracer); +struct osnoise_tool *osnoise_init_trace_tool(struct common_params *params,= const char *tracer); bool osnoise_trace_is_off(struct osnoise_tool *tool, struct osnoise_tool *= record); int osnoise_set_stop_us(struct osnoise_context *context, long long stop_us= ); int osnoise_set_stop_total_us(struct osnoise_context *context, diff --git a/tools/tracing/rtla/src/osnoise.c b/tools/tracing/rtla/src/osno= ise.c index 4ff5dad013b10..ae6e5f03e828f 100644 --- a/tools/tracing/rtla/src/osnoise.c +++ b/tools/tracing/rtla/src/osnoise.c @@ -1178,10 +1178,56 @@ struct osnoise_tool *osnoise_init_tool(char *tool_n= ame) return top; } =20 +/* + * osnoise_init_ipi_filters - Initialize event filtering for IPI events + */ +int osnoise_init_ipi_filters(struct osnoise_tool *tool, + struct common_params *params, + bool *filters_enabled) +{ + char filter[MAX_PATH]; + int retval; + /* + * If tracing on a subset of possible CPUs, leverage the kernel filtering + * infrastructure to only generate events on traced CPUs. + * Older kernels (pre v6.6) may have the IPI events but not the ability + * to filter them, so allow that to fail gracefully. + */ + + snprintf(filter, ARRAY_SIZE(filter), "cpu & CPUS{%s}\n", params->cpus); + retval =3D tracefs_event_file_write(tool->trace.inst, + "ipi", "ipi_send_cpu", "filter", + filter); + if (retval < 0) { + debug_msg("Could not set ipi_send_cpu CPU filter\n"); + *filters_enabled =3D false; + return 0; + } + + + snprintf(filter, ARRAY_SIZE(filter), "cpumask & CPUS{%s}\n", params->cpus= ); + retval =3D tracefs_event_file_write(tool->trace.inst, + "ipi", "ipi_send_cpumask", "filter", + filter); + if (retval < 0) { + /* + * If we managed to set up the previous filter but not + * this one, something's really wrong + */ + err_msg("Could not set ipi_send_cpumask CPU filter\n"); + *filters_enabled =3D false; + return -1; + } + + *filters_enabled =3D true; + return 0; +} + /* * osnoise_init_trace_tool - init a tracer instance to trace osnoise events */ -struct osnoise_tool *osnoise_init_trace_tool(const char *tracer) +struct osnoise_tool *osnoise_init_trace_tool(struct common_params *params, + const char *tracer) { struct osnoise_tool *trace; int retval; @@ -1196,6 +1242,30 @@ struct osnoise_tool *osnoise_init_trace_tool(const c= har *tracer) goto out_err; } =20 + if (!params->ipi) + goto done; + + retval =3D tracefs_event_enable(trace->trace.inst, "ipi", "ipi_send_cpu"); + if (retval < 0 && !errno) { + err_msg("Could not find ipi_send_cpu event\n"); + goto out_err; + } + + retval =3D tracefs_event_enable(trace->trace.inst, "ipi", "ipi_send_cpuma= sk"); + if (retval < 0 && !errno) { + err_msg("Could not find ipi_send_cpumask event\n"); + goto out_err; + } + + if (params->cpus) { + bool unused; + + retval =3D osnoise_init_ipi_filters(trace, params, &unused); + if (retval < 0) + goto out_err; + } + +done: retval =3D enable_tracer_by_name(trace->trace.inst, tracer); if (retval) { err_msg("Could not enable %s tracer for tracing\n", tracer); diff --git a/tools/tracing/rtla/src/osnoise.h b/tools/tracing/rtla/src/osno= ise.h index 340ff5a64e6e4..81a704c361ec0 100644 --- a/tools/tracing/rtla/src/osnoise.h +++ b/tools/tracing/rtla/src/osnoise.h @@ -63,6 +63,10 @@ int osnoise_enable(struct osnoise_tool *tool); int osnoise_main(int argc, char **argv); int hwnoise_main(int argc, char **argv); =20 +int osnoise_init_ipi_filters(struct osnoise_tool *tool, + struct common_params *params, + bool *filters_enabled); + extern struct tool_ops timerlat_top_ops, timerlat_hist_ops; extern struct tool_ops osnoise_top_ops, osnoise_hist_ops; =20 diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index afab2f341a1e9..87d28865515b5 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -392,7 +392,7 @@ osnoise_ipi_cpumask_handler(struct trace_seq *s, struct= tep_record *record, */ struct osnoise_tool *osnoise_init_top(struct common_params *params) { - bool ipi_filters_enabled =3D false; + bool ipi_filters_enabled; struct osnoise_tool *tool; int retval; =20 @@ -424,41 +424,11 @@ struct osnoise_tool *osnoise_init_top(struct common_p= arams *params) goto out_err; } =20 - /* - * If tracing on a subset of possible CPUs, leverage the kernel filtering - * infrastructure to only generate events on traced CPUs. - * Older kernels (pre v6.6) may have the IPI events but not the ability - * to filter them, so allow that to fail gracefully. - */ if (params->cpus) { - char filter[MAX_PATH]; - - snprintf(filter, ARRAY_SIZE(filter), "cpu & CPUS{%s}\n", params->cpus); - retval =3D tracefs_event_file_write(tool->trace.inst, - "ipi", "ipi_send_cpu", "filter", - filter); - if (retval < 0) { - debug_msg("Could not set ipi_send_cpu CPU filter\n"); - goto no_filter; - } - - - snprintf(filter, ARRAY_SIZE(filter), "cpumask & CPUS{%s}\n", params->cpu= s); - retval =3D tracefs_event_file_write(tool->trace.inst, - "ipi", "ipi_send_cpumask", "filter", - filter); - if (retval < 0) { - /* - * If we managed to set up the previous filter but not - * this one, something's really wrong - */ - err_msg("Could not set ipi_send_cpumask CPU filter\n"); + retval =3D osnoise_init_ipi_filters(tool, params, &ipi_filters_enabled); + if (retval < 0) goto out_err; - } - - ipi_filters_enabled =3D true; } -no_filter: =20 /* * If no filtering is available and we're tracing all CPUs, we can still --=20 2.55.0