From nobody Sat Jul 25 16:45:30 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 08A7848B36F for ; Wed, 15 Jul 2026 15:46:45 +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=1784130407; cv=none; b=Fe4VAu4Ci/zr0glStyNW7WEFZwMj7TV2r6fKpxwaAg/pga54ArY6hmwOg6uKzNCxQSsXGV/fl1gNdVM6Q5KFsUH74ZPk95j5ql0rd+FpBi4y+2OrkcKW9qrk4KcZ5z0RKAskmxB/K8KwGrecNpLlyM/hrxglRD+5fAtiPR/4W6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784130407; c=relaxed/simple; bh=dQafBnijouqMjy3pJ+JGvQ3Lx38g2EjDegrTCOoR974=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ojsPzClguDKqxiDSPq0uEThXMm2LlPACbTWzchP4US2QMmRjbsTrGZnGyLCSV5ycyTp4MBGLedo4H6/tg4/PomlbcqB2lRFtEU6PtEmkYgbdp3ch9b3X4NV/NM1sV67XKLpTu3uhTceCnpfBxmT8KwhN7dsouRJ+OXu1CEApCvk= 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=SqJ29/z1; 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="SqJ29/z1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784130404; 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=SqJ29/z106VJfZROIIQI65rXZVXbYQulE00LA196kA7JiA19HH8+CVuP7FadrVSq/ZNko7 yAzsatcR72YSm+cvYYFKB5Tazjq4O82prqLRJBDz3ERUEyEHqPNGF3fkx576qs54AeJy7O yB7x/n3aVujZdt1q2GWylGQSWdVWYkA= 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-609-ppw5OaPSOIyQbEOdPlUfTw-1; Wed, 15 Jul 2026 11:46:41 -0400 X-MC-Unique: ppw5OaPSOIyQbEOdPlUfTw-1 X-Mimecast-MFC-AGG-ID: ppw5OaPSOIyQbEOdPlUfTw_1784130400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 EC0451956076; Wed, 15 Jul 2026 15:46:39 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.32.112]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B96E91800361; Wed, 15 Jul 2026 15:46:36 +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 v3 1/6] rtla/osnoise: Add IPI tracking cmdline option Date: Wed, 15 Jul 2026 17:45:46 +0200 Message-ID: <20260715154553.2020891-2-vschneid@redhat.com> In-Reply-To: <20260715154553.2020891-1-vschneid@redhat.com> References: <20260715154553.2020891-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.4.1 on 10.30.177.111 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 Sat Jul 25 16:45:30 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 F41CD48AE2B for ; Wed, 15 Jul 2026 15:46:47 +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=1784130409; cv=none; b=brPvR5J4Z0UlJfSOCbFJiL6wVxmaUyDuHTMwFWkGvtGpr7fRlThpU6xoewEB75rU1JwQc6kRSUKMa95bocOcBhgOl6J+OrOFjRz7Ti9Jlo3GgcqRFkEzmZQxbYtil7uClniw3Su/qAn9fTYScidVrvqM3K+42Qwi1gxUMqQYiZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784130409; c=relaxed/simple; bh=1F4hLTvz/4e4ufJH1DR3U7aK+N7th6xGm76jnDcaobQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TJZK/nSHUR8FlHEjPKqU8kXA6sfYWqy0vpyOmlb87vHFjBHhKxNIDW3IyIiyVwYmzynkLr2OZl8so190NZDBBqScrolzNXQ2PLcR6gvlaFx4DuJ73n6+gY7V+lxyGwdTZxX7hgKu9ursUtnAamKhogOgaple8gPs1IPgGa9ldM8= 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=iOgprCbw; 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="iOgprCbw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784130406; 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=QQnQxDAGu0qfvZdzBrLhi68ogAjIIIw2QBHzq8V/lrc=; b=iOgprCbw45HAoc5SMvoareidr11y5f2rqepw+WqXewv0mgpAu3OJvl9EVeHlxPnLT4mw7x Obz+ZSGU8pMzuXF2bD+avjqXGpk4r9FbAWB46qEmAxwe0nIDW7VIYWlE+8ixIMstjYgyk2 OJ8Mdg8vOolFiWDYkXL+NVUuEJFHVCg= Received: from mx-prod-mc-06.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-294-KGA9tqSGN5K3shxwKYyuyQ-1; Wed, 15 Jul 2026 11:46:45 -0400 X-MC-Unique: KGA9tqSGN5K3shxwKYyuyQ-1 X-Mimecast-MFC-AGG-ID: KGA9tqSGN5K3shxwKYyuyQ_1784130404 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B5E0418005BE; Wed, 15 Jul 2026 15:46:43 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.32.112]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 67E121800361; Wed, 15 Jul 2026 15:46:40 +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 v3 2/6] rtla/osnoise: Record IPI count in osnoise top Date: Wed, 15 Jul 2026 17:45:47 +0200 Message-ID: <20260715154553.2020891-3-vschneid@redhat.com> In-Reply-To: <20260715154553.2020891-1-vschneid@redhat.com> References: <20260715154553.2020891-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.4.1 on 10.30.177.111 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 -i 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 Sat Jul 25 16:45:30 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 7606F48C3F7 for ; Wed, 15 Jul 2026 15:46:53 +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=1784130416; cv=none; b=TPhP3pi7ELycjnMLNUN4y3p/QHNEFfeoM+136221oClzdsIxsXZl9Jtgh30JtKDjge7fmSD7wnRnEL6Eeu71zkIjqTfTyqpQQckxuK6K3IQB9guETieW3qdT+8aYadIyKsSKmGUJLBszrw6WTIeP7D92/JucYoozIs4VrBJOU6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784130416; c=relaxed/simple; bh=Na7db9/2s80znu/9AE5DCwfjSCJNFyIOryOmFE9wqsM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C9oTt1kgIzPk5dVW01NhmMbFIWcHt43bJwme/pLQGkOcy24dSFXcTDGRFiZXlsoHkAgZkhWfZiC2yUsR2dFZ5kwzCZRCi73q/lMmpS+PwhGirE1Tgv4PY37wS/s2nf8MmExGcH4tnYzywBlpGyjQs7OH1338n/cndw2K/5FkbZs= 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=L2RSk8iT; 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="L2RSk8iT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784130412; 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=L2RSk8iT8TLT/ZoFZIcrrInFw8Y/V8Zk6Nzu9+zFfGCmc5MZZMZRrpjfvPyMwJiNEAVffr 8iqCS8DHGcq9ZGnG3BsoO5NmKBUwnRGMNEr2ii9/SmjYckeVm/TxCfZt5lCMskWry2ZNE+ GRSMVGRQubg+Fl0tgSHug4c2e/LuJiM= 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-81-9AWdsB8KOXSWZy5Ue6FOOA-1; Wed, 15 Jul 2026 11:46:49 -0400 X-MC-Unique: 9AWdsB8KOXSWZy5Ue6FOOA-1 X-Mimecast-MFC-AGG-ID: 9AWdsB8KOXSWZy5Ue6FOOA_1784130407 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 87A1C1955F70; Wed, 15 Jul 2026 15:46:47 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.32.112]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 326BB1800286; Wed, 15 Jul 2026 15:46:43 +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 v3 3/6] rtla/osnoise: Leverage IPI event filters when tracing a subset of CPUs Date: Wed, 15 Jul 2026 17:45:48 +0200 Message-ID: <20260715154553.2020891-4-vschneid@redhat.com> In-Reply-To: <20260715154553.2020891-1-vschneid@redhat.com> References: <20260715154553.2020891-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.4.1 on 10.30.177.111 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 Sat Jul 25 16:45:30 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 A95DE48B373 for ; Wed, 15 Jul 2026 15:46:58 +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=1784130421; cv=none; b=uKPccluKGJrWEYuCpBBP9k0CiApzEIbnQNZRN84NwuJMwk6YQ1zjNZ4XDhu2GEjC4MGg0mrfadx/lWIilZLssVVgg9l0+0tRtHcDNf/GzexCza3BbX9lLBpQwIKnrF8cqp/mKKEzR81ld/EUjigGNlpG8X42p1RTomMYqV+QWtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784130421; c=relaxed/simple; bh=APOsm8JAmb4xKko1LI/DErr6AxacMhKSZv2IlIg/kzw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hpX1o5AX7MYUus6hzcRQRTxj8wG0/zF3guO6mEARQCjDKpmOa1n+PBZAVr/Zx+0MsD8X5gq4P9wJyLx0A9nNOR5BQMNTEOSDAg7XmdwM4k8Zmc+EmE6ujbSpKEE+GbFV/a/mnf2Ek0helgdyKIt3U6QBABLxNnR1jXzlnhpAP1I= 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=NrkCZkQg; 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="NrkCZkQg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784130416; 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=NrkCZkQgKmeTBogaBb/d72luTp/mYiyGQrz0W1trQ3a3qlkLXNTF5buXvSlcj1eIAy03HL ph03ufgvjZwtm9MNfDk6UGhhuFwHJ8OvoSGDIIpEzS8+dqvi7FX7JjTKhaq9xicM9n2FtN BDvgj47dJhCpeXNYyWkR8GDlLxQ5WrA= 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-573-Ug8_ypmAPi2aQ7pIrCN1aA-1; Wed, 15 Jul 2026 11:46:52 -0400 X-MC-Unique: Ug8_ypmAPi2aQ7pIrCN1aA-1 X-Mimecast-MFC-AGG-ID: Ug8_ypmAPi2aQ7pIrCN1aA_1784130411 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 4B6A21955F05; Wed, 15 Jul 2026 15:46:51 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.32.112]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 060A01800361; Wed, 15 Jul 2026 15:46:47 +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 v3 4/6] rtla/osnoise: Allow IPI filters to gracefully fail Date: Wed, 15 Jul 2026 17:45:49 +0200 Message-ID: <20260715154553.2020891-5-vschneid@redhat.com> In-Reply-To: <20260715154553.2020891-1-vschneid@redhat.com> References: <20260715154553.2020891-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.4.1 on 10.30.177.111 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 Sat Jul 25 16:45:30 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 96532391505 for ; Wed, 15 Jul 2026 15:46:59 +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=1784130424; cv=none; b=R+p9hRZhMnfr7rg2kEr+I00RMPtUhmll/KVRsm/BFPeuy2yykRgMQccFIjejliHwN0RT48pjkblHPy81EHnk5d+xTbaz2Tf2qAoe93HKqKxcsVXYvXgtX4luuPGYJeOyc2yPq9zT/LbpLhJjWaME9/6/wOTgWSucuW36g96HavI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784130424; c=relaxed/simple; bh=6j6oFNDGCW22dPi/OuojAv6AgzWQQtmzdQGiZwBPIS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BINL7T1Are1fL8Zb8Zx5lPwSckl4eY+2r52io22F2cW9dYQifvliBZOvrUDT1nINFnwqraJNv0AOwii8752UmK1wGaIELvlhXRZFcweSHknU7ldRADVzwFkG00XLLtS9ZX/etFLFIwg2Wnx8L/KvLlcjhwXzf8SFno2mGqY3bTY= 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=LZyrVxLg; 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="LZyrVxLg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784130418; 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=LZyrVxLg0BwfJGmGvd5hSfvLfu6Ic40ki3D5ikHFVhIcYON07TrlXWShX02yOdFXA1ylkE 0ykg64D8u3EyBcJwScRAo668f3Q3t5nqg1ncssUNI6v4nWQEW1SxSySJJjVv/LrsYNyR8Z N4nGUkLx1L/rb7JIggJFK7V5EQkVowg= 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-371-nrpd4CmENcac4dNV13t-pQ-1; Wed, 15 Jul 2026 11:46:56 -0400 X-MC-Unique: nrpd4CmENcac4dNV13t-pQ-1 X-Mimecast-MFC-AGG-ID: nrpd4CmENcac4dNV13t-pQ_1784130415 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 6F6031955F1D; Wed, 15 Jul 2026 15:46:55 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.32.112]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BCA251800576; Wed, 15 Jul 2026 15:46:51 +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 v3 5/6] rtla: Unconditionally clean any pre-existing filters for user-provided events Date: Wed, 15 Jul 2026 17:45:50 +0200 Message-ID: <20260715154553.2020891-6-vschneid@redhat.com> In-Reply-To: <20260715154553.2020891-1-vschneid@redhat.com> References: <20260715154553.2020891-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.4.1 on 10.30.177.111 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 Sat Jul 25 16:45:30 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 5840648BD5D for ; Wed, 15 Jul 2026 15:47:13 +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=1784130436; cv=none; b=ebghesbk8G2k73Cie9j9HpzbLNIyNuBuH3GxYckmQ6umYyFwj679ed0agN7X4cY/d25XTNK2fzy+Sd2J4XaRwz8dsnWE3EkeQbh0wVMLRb14rHb/oD+U3Agt/IFXct7nn9mhUCs3exVLBFs38mNS5hS1vZUI0RCnw5QBSt1o1Us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784130436; c=relaxed/simple; bh=9NcPnTXsdZ8RvpB1dyL2Xv3ITs7uDVh7WEThip/MWWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WoHcJh1LOVinkxGNwt7FC46RTECykkPwDH9fD4aetvRFXmrmq2u6QCNYqYK08enb4+Kb2iY3DZzGy8lPkWeu19CwJiElCRP0mkEIiGcHkGWjYDUtSCF+tHWrspBwDdnO/u0vwxpzQ2GAO5TdcHdb9CdomtwnZuE0j9z0FryOjsc= 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=a/Lxqxb0; 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="a/Lxqxb0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784130427; 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=9S45MFUtOE7ctpW9HaHMKFKg1ANHfRP1oIVMuko7qnU=; b=a/Lxqxb0ys+g/pBfX8yqHmeVljjMMTNYZqQI0FZaMgTWNd/+QnHXRu15iV+pfCmJ84+HnW Jc1ceLIhAXHb4hlm7wy7wnInaOMqvFmXydKL8zi32mAzfocFN6m7DCXtADmX2hBVIS8qwc 377V0pt1IoogH5yIPW4kuI5453S6o+k= 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-443-EZPWzez9ORaKPQRQqBWmbg-1; Wed, 15 Jul 2026 11:47:03 -0400 X-MC-Unique: EZPWzez9ORaKPQRQqBWmbg-1 X-Mimecast-MFC-AGG-ID: EZPWzez9ORaKPQRQqBWmbg_1784130422 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 459321955F18; Wed, 15 Jul 2026 15:47:01 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.32.112]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DCB8E1800286; Wed, 15 Jul 2026 15:46:55 +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 v3 6/6] rtla/osnoise: Trace IPI events when recording a trace file Date: Wed, 15 Jul 2026 17:45:51 +0200 Message-ID: <20260715154553.2020891-7-vschneid@redhat.com> In-Reply-To: <20260715154553.2020891-1-vschneid@redhat.com> References: <20260715154553.2020891-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.4.1 on 10.30.177.111 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 d0a8a6edbf0cb..dd302427557ca 100644 --- a/tools/tracing/rtla/src/common.c +++ b/tools/tracing/rtla/src/common.c @@ -204,7 +204,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