From nobody Sat Sep 26 10:02:05 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 D0DD0490BF3 for ; Wed, 2 Sep 2026 12:40: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=1788352830; cv=none; b=ZCKekBM/o5yKJmgSr3Czev/bZ9tU0JTZGOiEh1OkeD8GDqB8MLMiUV6gmxutEvO5JILgG0bykzlXNP5anAORbT1vYMIZh9txRupvskQnq3Q+DpAgZ2qAGsGThX2yHp3nfFXmglI3CuVhVAvMFlUB6wL8YtVUjZIbAhIU3zAeqgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788352830; c=relaxed/simple; bh=4ynCKSBrYH99EP9t5ZyjcuDEGLq+jBmn0qOkuGMRw38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q5ugnceU7b7L+FxSkhECiWZ85evDHgbMaWOsNmvJYwk8QoOhj1ukvuoWjPzLJYA/5zCFyAxqppd3O9NQys9TZxU/AGIO1BZt1vvCGB7MC+8yRExE0+5tB0kRhifV9XpyjZl09cx3zy/1PaKztJ4AVx+pShE37VkI0GDwQJh/yu4= 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=LfuJ41B5; 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="LfuJ41B5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352825; 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=Tq6X9iHJwj0Z4++cseQ+WkYkIyZIsUxG0iOqqACkzfM=; b=LfuJ41B55kflz4nMHg3bdbrKemdhfvTSDnsgzNQaMcXe7c15xvOzqUQmie2ODVd2MnFFzG O2coJSQWDDKlfYor+FZ7x1lq/YuWsnmGz5J817OjJq4Fo69cKQx2RnyfBQTPp+gqxT1xS9 Drn0PljqBfZjYrJOQssWh+0kHmAmB9Q= 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-381-TShCLYeGMgCq6KwHVgGDuQ-1; Wed, 02 Sept 2026 08:40:22 -0400 X-MC-Unique: TShCLYeGMgCq6KwHVgGDuQ-1 X-Mimecast-MFC-AGG-ID: TShCLYeGMgCq6KwHVgGDuQ_1788352820 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 7E7D61953972; Wed, 2 Sep 2026 12:40:20 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.33.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DB2B61955F7C; Wed, 2 Sep 2026 12:40:16 +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 v5 1/8] rtla/osnoise: Add IPI tracking cmdline option Date: Wed, 2 Sep 2026 14:39:30 +0200 Message-ID: <20260902123942.695822-2-vschneid@redhat.com> In-Reply-To: <20260902123942.695822-1-vschneid@redhat.com> References: <20260902123942.695822-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 fb8c972c0746b..8c02b94ce4321 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 661240d44ad9a..f2dd7c610093d 100644 --- a/tools/tracing/rtla/src/cli_p.h +++ b/tools/tracing/rtla/src/cli_p.h @@ -497,6 +497,9 @@ static int opt_filter_cb(const struct option *opt, cons= t char *arg, int unset) #define OSNOISE_OPT_THRESHOLD RTLA_OPT_LLONG('T', "threshold", ¶ms->th= reshold, "us", \ "the minimum delta to be considered a noise") =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 Sep 26 10:02:05 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 CD23E490C13 for ; Wed, 2 Sep 2026 12:40:30 +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=1788352832; cv=none; b=gN6uDkL2TbYX7P9IJNW5g1p1ubqEcVmYyEtuZezF3cQTLHbY9pKmKsaVSykram5m+PZJmg+2f1eMe0TPceZsEfoInIVFma0pB66emcEOqT67s62514LHhXIxeG1XbgUTlSwKcqJicVAwtDbqKCKt/Vy/a7+XavB2wGbfXV5PwMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788352832; c=relaxed/simple; bh=fDxH/Te0cQFp5ShQesuIMkvuRo5iX/+PNojmEZYHOvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F5JFsPLLh3HNZz+Reuie8LRiu1a667ZSvJIGuQUCPqygjeorpdX4is8gmKq7gIFb81BacHhHk7Yn8fkQZh79KXhYhFj5iGsrbWq4GFdXpUPgVLImyT15h4hUsRJfGRNeMLZlrEeG5J+tYLV0CHT2M5qaj5r40EWdVyteotxKTFM= 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=Qez3ofS3; 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="Qez3ofS3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352829; 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=Qez3ofS35lQSZhknsZ3794srxl7ltZHdMYuh7k3B6He6bxdXhdqNq0WlY8TaCFKk5yvaHN 0Qt2K9KPZoOiJyXFYjN/AmNV3zLxRFw/9zRcY3pE8gAA3PkpjwBpXc3dO3M/CZmDdvRO+q 467hUnYIIKCqiC3nlfqaRPY+Gc+cg7Y= 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-160-YuCptREKN5SRK22hA2CmFw-1; Wed, 02 Sept 2026 08:40:25 -0400 X-MC-Unique: YuCptREKN5SRK22hA2CmFw-1 X-Mimecast-MFC-AGG-ID: YuCptREKN5SRK22hA2CmFw_1788352824 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 3E6A61953948; Wed, 2 Sep 2026 12:40:24 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.33.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D9ADB1955F72; Wed, 2 Sep 2026 12:40: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 v5 2/8] rtla/osnoise: Record IPI count in osnoise top Date: Wed, 2 Sep 2026 14:39:31 +0200 Message-ID: <20260902123942.695822-3-vschneid@redhat.com> In-Reply-To: <20260902123942.695822-1-vschneid@redhat.com> References: <20260902123942.695822-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 Sat Sep 26 10:02:05 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 5EC5C48F858 for ; Wed, 2 Sep 2026 12:40:34 +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=1788352836; cv=none; b=UuWIoq+vcJHSeXJqMAgkA7CRcG31BU+dj7AyUj1qerya493m82BoSByO6YnytLR/F9xVvN8DC26jpWPpCdLhRn03fnwgIhvAORKnS7BTd+kI9qZawrqDTXR5yFGURBJ1WXJA0ZA7UZZtIw5xeJAK5y5D8WyntonIWgJY838/CHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788352836; c=relaxed/simple; bh=Na7db9/2s80znu/9AE5DCwfjSCJNFyIOryOmFE9wqsM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QDJQJ0b9fuyCRNVQgxcAxYee0qeIKoTYXHyQKQCfd4ckwy1+yAxO/cqjjVrrz9f2bCy5Y2W/lFjo7HsvitFJZsiurx7kUYhhHOPDPYWhkcvIXTrD4GmI8ZFQhyy0UiXaUb8qDkii4AWLSUDZwGp4Wm5UYLa50MLmALn3xag4ecM= 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=VMOFnRD/; 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="VMOFnRD/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352833; 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=VMOFnRD/DXPaClQ0AVlSxL5194DJHn01lnfV/qbNusE3RdHyL6Ztpgk64PqBFsg2HibZ9I 1rT4uE37e0ARB4T7ulxSXWcliWNbXqLxL2xv6RCA7b3TQT2tbbVfX9RjKK3UtjKQ5GzpCz gQyZt0aUbHB4+WZJYjwZ6tu5uKyQgic= 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-590-x6c-OkcsNBWANv3AfSiupA-1; Wed, 02 Sept 2026 08:40:29 -0400 X-MC-Unique: x6c-OkcsNBWANv3AfSiupA-1 X-Mimecast-MFC-AGG-ID: x6c-OkcsNBWANv3AfSiupA_1788352828 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 4D6E7195604B; Wed, 2 Sep 2026 12:40:28 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.33.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CE0951955F72; Wed, 2 Sep 2026 12:40:24 +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 v5 3/8] rtla/osnoise: Leverage IPI event filters when tracing a subset of CPUs Date: Wed, 2 Sep 2026 14:39:32 +0200 Message-ID: <20260902123942.695822-4-vschneid@redhat.com> In-Reply-To: <20260902123942.695822-1-vschneid@redhat.com> References: <20260902123942.695822-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 Sat Sep 26 10:02:05 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 A1758494A0B for ; Wed, 2 Sep 2026 12:40:37 +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=1788352839; cv=none; b=ajXDrArAtoz/YHvS7OoM7jnu1x4QHZcgCdKbFcI7KGsSvyJxlMlswfQGu12wEsDvDlxTdYYgVcJGOwdnZeAU1SmSw8Q8Bb3AYCSpX3PBTKV0qYEtmxgxsmZHmDXOVZAj1egnbOsnNyr2EBEFCtYtIRiPHAebeMnxMXj/yd8OxJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788352839; c=relaxed/simple; bh=APOsm8JAmb4xKko1LI/DErr6AxacMhKSZv2IlIg/kzw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OQ3SyMp+OSHkbdZ3F+sY91SCvC7so2T1nTSMHA2nV0rNqSW4A4ss1qpMvJ+qZzn4gmbXpZVh6C37lzmcuxRoGL0v1bO6TiPPxYmPV87pLGS+Yt1/iA742PbtvfzZxHcncNSQBWTpSaG8UUWRb0amfovKQpEnVGZ/Vn2o/G0TR0M= 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=JCenzcQ7; 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="JCenzcQ7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352836; 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=JCenzcQ786FWPo7t2V7UhNOfyWtWtyO6+FII7jKJ8TMpo6vk7jakl3E31F35ToZ9PscN+8 yldYMQvuYJtgvqhfL6lodPm0BU2YhvHUBtLRK3AIt9ZLrSLprkOVc/tNQ7CoQr/txcmCFv SJGOI2sffqsqI/DuCSVDLxgEL6s0MDE= 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-383-R92UWmuJNqy746IuVZLbwA-1; Wed, 02 Sept 2026 08:40:34 -0400 X-MC-Unique: R92UWmuJNqy746IuVZLbwA-1 X-Mimecast-MFC-AGG-ID: R92UWmuJNqy746IuVZLbwA_1788352832 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B1D9E1802149; Wed, 2 Sep 2026 12:40:32 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.33.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C5C1B1955F72; Wed, 2 Sep 2026 12:40:28 +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 v5 4/8] rtla/osnoise: Allow IPI filters to gracefully fail Date: Wed, 2 Sep 2026 14:39:33 +0200 Message-ID: <20260902123942.695822-5-vschneid@redhat.com> In-Reply-To: <20260902123942.695822-1-vschneid@redhat.com> References: <20260902123942.695822-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 Sat Sep 26 10:02:05 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 C1A3A4963B6 for ; Wed, 2 Sep 2026 12:40:44 +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=1788352846; cv=none; b=FFZliQdoODl2LSEuC1y3c+Oc1iIsS8X3PjCWSCDKNgeCxJjTqyyrMzSYLeTQ4EORYwK399UuciOTDczXs4JBttP8zVKbtBEsjCCB2ixHsbgqtJhF9Ld46RFWYPVxxApkvQE6nxYqkQNU9xVC3rYsQVPJzaXuB+REr33edFKi7rg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788352846; c=relaxed/simple; bh=qT0DAOgjdJrEEKXxnuOv96A2U8pBrx1RjuWnyxOYjQI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jozQrAepucWNx8kuZ0R0u8GKfDXI+r4Tupr2F9a7alf8Gi0fJvNR3vWSY/5iFruRUNaOrK3iPQ8TPBnKlMYko3F9gw5FgcoEY+zkS1xmnIS/AgZatEO7bgwXzv2zGjZAd8pEjsRShfzY/B6lCX63Bf4XbhWdRVh5b3buptIkJCE= 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=CND+5YCx; 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="CND+5YCx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352843; 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=hhKZ4yS66uthVZ2uXlRGt01Z3p06b8KRi2tpqHHHg8w=; b=CND+5YCxWCEN2Z5X5ZZ0MDzsCr9G+efhwOJavIzhgbeGCBVeOGQiiJpIb2jcR4kAvw5jMX 6l5K5sl0t5JuNOG+itAOVSQl2McEcAmkXSdafjmFr0+wEMFovK+3asMTvLbMpDhXwrteZp +YP/QtqTmdIQxF5lp+Pyf4218peFo0c= 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-300-Gt7dm9-FOnKtsSwTW5pVvg-1; Wed, 02 Sept 2026 08:40:38 -0400 X-MC-Unique: Gt7dm9-FOnKtsSwTW5pVvg-1 X-Mimecast-MFC-AGG-ID: Gt7dm9-FOnKtsSwTW5pVvg_1788352837 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 164921802140; Wed, 2 Sep 2026 12:40:37 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.33.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 37FC91955F72; Wed, 2 Sep 2026 12:40:32 +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 v5 5/8] rtla: make struct trace_events double linked Date: Wed, 2 Sep 2026 14:39:34 +0200 Message-ID: <20260902123942.695822-6-vschneid@redhat.com> In-Reply-To: <20260902123942.695822-1-vschneid@redhat.com> References: <20260902123942.695822-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" The events list is currently a single linked list. New events are prepended to the list, making them the new head. This makes it easy to fetch the last-defined event when handling trigger and filter options on the cmdline, as they apply to the last-defined event, but means the events are then processed in LIFO order with regards to the command line order. To prepare for processing the events in the user-defined order, make the events list double linked. Signed-off-by: Valentin Schneider --- tools/tracing/rtla/src/cli_p.h | 4 +++- tools/tracing/rtla/src/trace.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/tracing/rtla/src/cli_p.h b/tools/tracing/rtla/src/cli_p.h index f2dd7c610093d..7e3a713f97c62 100644 --- a/tools/tracing/rtla/src/cli_p.h +++ b/tools/tracing/rtla/src/cli_p.h @@ -394,8 +394,10 @@ static int opt_event_cb(const struct option *opt, cons= t char *arg, int unset) if (!tevent) fatal("Error alloc trace event"); =20 - if (*events) + if (*events) { tevent->next =3D *events; + (*events)->prev =3D tevent; + } *events =3D tevent; =20 return 0; diff --git a/tools/tracing/rtla/src/trace.h b/tools/tracing/rtla/src/trace.h index 95b911a2228b2..eacafc0c96b31 100644 --- a/tools/tracing/rtla/src/trace.h +++ b/tools/tracing/rtla/src/trace.h @@ -4,6 +4,7 @@ =20 struct trace_events { struct trace_events *next; + struct trace_events *prev; char *system; char *event; char *filter; --=20 2.55.0 From nobody Sat Sep 26 10:02:05 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 D4ADF499F1B for ; Wed, 2 Sep 2026 12:40: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=1788352849; cv=none; b=s+v5CpcMx0rNzLvutqCIVkDNgzT0kL6JGwldHY7XW4A5Keo/nkzMglGjGsMqaLnRkCsA1mMId5o5oPmrdnwTmsOxT49H4uMaI3Hf51mGMtojDD9NMgdH6LT37nsaF9Hl0EFXgi8i6MqfB7ScnFRXE+FX+DqTXU24/kKUhaEcuHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788352849; c=relaxed/simple; bh=ZccytlZcaWZYFSyTPqJW0JygOeg9EwNFvjyOxiUQktU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CPW2hmx1nhtaUReW6GfN/Mk7rGfnBPfE2HoY7gQk7hppiOeeffG4ofeMPllefxBwQSZ9VIs/Bi3OEwWv8rF+0oXnIsHKMRhnUArftHkiR3BxB80AaAlDnS1VVh9zV7KUCb+cubEf8NVmb+oO9/yRp9bg9QFcS1Is8iDWsk9teA8= 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=jIju3hPE; 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="jIju3hPE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352845; 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=PA6+1++Yl6Rg3Cc+SEzrgVmupmxBw7hIdx8Fpe28Jto=; b=jIju3hPE2mHERoTebDN1Ro+fkwWYFCZlaOETXFzRayK80uXSosRdZ2Rdn5Fq9L2LB5gBz8 F56pt8Zwiklm62wEgaSRRYj/3nX4xEym1VIdLa6QWqCjs0ef0ZPKH9MIj8D4Wj6OL8e0Ug bHDWx1L382A0y9gXX7+sPmF65H0OTgs= 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-230-AMVI-rA0PVuKfpmw534X7g-1; Wed, 02 Sept 2026 08:40:42 -0400 X-MC-Unique: AMVI-rA0PVuKfpmw534X7g-1 X-Mimecast-MFC-AGG-ID: AMVI-rA0PVuKfpmw534X7g_1788352841 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 2F6711911B1F; Wed, 2 Sep 2026 12:40:41 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.33.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8F8401955F72; Wed, 2 Sep 2026 12:40:37 +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 v5 6/8] rtla: Enable and disable events in the user-defined order Date: Wed, 2 Sep 2026 14:39:35 +0200 Message-ID: <20260902123942.695822-7-vschneid@redhat.com> In-Reply-To: <20260902123942.695822-1-vschneid@redhat.com> References: <20260902123942.695822-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" Events are processed in LIFO order for ease of internal processing, but this is can be confusing to users if the processing ordering is exposed to them. A following commit will do just that by making it so the last-defined event options (filters/triggers) overrides any previous options for that same event. Thus, process the events in the user-defined order. Signed-off-by: Valentin Schneider --- tools/tracing/rtla/src/trace.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c index e407447773d04..17d148f7d5d6e 100644 --- a/tools/tracing/rtla/src/trace.c +++ b/tools/tracing/rtla/src/trace.c @@ -440,6 +440,21 @@ static void trace_event_disable_trigger(struct trace_i= nstance *instance, tevent->event ? : "*", tevent->trigger); } =20 +static inline struct trace_events *trace_events_tail(struct trace_events *= tevent) +{ + while (tevent && tevent->next) + tevent =3D tevent->next; + + return tevent; +} + +/* + * Events are stashed in LIFO order; flip that to FIFO to process them in = the + * same order as they are defined by the user on the command line. + */ +#define for_each_trace_event(tevent) \ + for (tevent =3D trace_events_tail(tevent); tevent; tevent =3D tevent->pre= v) + /* * trace_events_disable - disable all trace events */ @@ -451,7 +466,7 @@ void trace_events_disable(struct trace_instance *instan= ce, if (!events) return; =20 - while (tevent) { + for_each_trace_event(tevent) { debug_msg("Disabling event %s:%s\n", tevent->system, tevent->event ? : "= *"); if (tevent->enabled) { trace_event_disable_filter(instance, tevent); @@ -460,7 +475,6 @@ void trace_events_disable(struct trace_instance *instan= ce, } =20 tevent->enabled =3D 0; - tevent =3D tevent->next; } } =20 @@ -544,7 +558,10 @@ int trace_events_enable(struct trace_instance *instanc= e, struct trace_events *tevent =3D events; int retval; =20 - while (tevent) { + if (!events) + return 0; + + for_each_trace_event(tevent) { debug_msg("Enabling event %s:%s\n", tevent->system, tevent->event ? : "*= "); retval =3D tracefs_event_enable(instance->inst, tevent->system, tevent->= event); if (retval < 0) { @@ -562,7 +579,6 @@ int trace_events_enable(struct trace_instance *instance, return 1; =20 tevent->enabled =3D 1; - tevent =3D tevent->next; } =20 return 0; --=20 2.55.0 From nobody Sat Sep 26 10:02:05 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 06AE249B1E2 for ; Wed, 2 Sep 2026 12:40:50 +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=1788352852; cv=none; b=tf87PeBj/8s/GjRAz1vVp3okkNvDa/tZycx3LuXJfSkuoThkzShQYwERhsYe2xfeZPM1yx7DU9VysmnnFO6oG6UxwJW6JTQi9ZEGmjv68DFS8ek8JqR9IfJxkwnxnIMQescaNZkyv1xXxSfEMo8dmR5TzhFF7mL7GDRzc/fRwI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788352852; c=relaxed/simple; bh=6xcKr5tZDHqLF3+pbISrVFsd7U/HkrFpGSZ5ZOOM58o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rjSExwNJL6bTeHXsEwa4yVDRPHgGMOf9mDfdAZ+A4RXZS6319my+4/wrarqK3O+xAaBBB19vqYZvw8vBZKowtyUvtdXfwMiaeYqA/FuceYs+ADpkkIOvVe746pMkfB8rpgJLGK/M3KmG7kMckdQdLIZbTlrmzEZWir1DmfA0dG8= 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=baq6OPLe; 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="baq6OPLe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352850; 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=hvSw3fPRx5YqD5lgP9OjNR44a1FjMhKCp+Qv0Husx7U=; b=baq6OPLeCukHNNyJSw/AySgVblQUChAQWeWNe9DkIR5StBveR9f5XmbNwK5aZMfmKULnLI /1NWjSJ3DW8A+IwP6RhFdnB+u20gJ58rwEHiKliGhUfpArOofnERmpSbjkcrQc/NWLdbvs PcrZ+bofFfAxeIffaVLSDUlHGT0+Q6I= 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-581-XbkaH8BGMWm9clSAAItU_w-1; Wed, 02 Sept 2026 08:40:47 -0400 X-MC-Unique: XbkaH8BGMWm9clSAAItU_w-1 X-Mimecast-MFC-AGG-ID: XbkaH8BGMWm9clSAAItU_w_1788352845 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 C336A18512C3; Wed, 2 Sep 2026 12:40:45 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.33.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AE5B31955F7C; Wed, 2 Sep 2026 12:40:41 +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 v5 7/8] rtla: Unconditionally clean any pre-existing filters for user-provided events Date: Wed, 2 Sep 2026 14:39:36 +0200 Message-ID: <20260902123942.695822-8-vschneid@redhat.com> In-Reply-To: <20260902123942.695822-1-vschneid@redhat.com> References: <20260902123942.695822-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 --- Documentation/tools/rtla/common_options.txt | 9 ++++++++- tools/tracing/rtla/src/trace.c | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/tools/rtla/common_options.txt b/Documentation/to= ols/rtla/common_options.txt index 38da1cf443a48..6bf0f86393333 100644 --- a/Documentation/tools/rtla/common_options.txt +++ b/Documentation/tools/rtla/common_options.txt @@ -26,12 +26,19 @@ =20 **--filter** ** =20 - Filter the previous **-e** *sys:event* event with **. For = further information about event filtering see https://www.kernel.org/doc/ht= ml/latest/trace/events.html#event-filtering. + Filter the previous **-e** *sys:event* event with **. + + If the same event is specified more than once but with different f= ilters, the last specified filter will be the only one applied. + + For further information about event filtering see https://www.kernel.org/= doc/html/latest/trace/events.html#event-filtering. =20 This option cannot be unset. =20 **--trigger** ** Enable a trace event trigger to the previous **-e** *sys:event*. + + If the same event is specified more than once but with different t= riggers, the last specified trigger will be the only one applied. + If the *hist:* trigger is activated, the output histogram will be = automatically saved to a file named *system_event_hist.txt*. For example, the command: =20 diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c index 17d148f7d5d6e..06204d339f967 100644 --- a/tools/tracing/rtla/src/trace.c +++ b/tools/tracing/rtla/src/trace.c @@ -487,6 +487,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 Sep 26 10:02:05 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 B9601493632 for ; Wed, 2 Sep 2026 12:40:57 +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=1788352859; cv=none; b=kIBxWxYnVXYAu2m/tfdzwtoPHvPwdnJWGui0ErV2s5irnkgUw8Psdxa7RHQo853k11wR/3WwOPQYgF7/yK7by8akZ7gcG6ZM/oY6NHkH3EL51nO43Va2rCGNittee8ajDNmhZHCZDN58O+IjbnfSZX+AiXCq+QgM823ZzaX6BYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788352859; c=relaxed/simple; bh=xyTZtukQ0nTIad9odCB2JAq1OSBUbce1d5b+4Bs6x8A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=agVUdFqfwxXMoOvrudaNVzoeDM9A/clywELps24R+ze35//1Ry3W7Rbf1e9+y2BIxaxDp+c0Zg6ojSyUJidqrorBZhs6HbDQszmrkxdS8Lai6AObU2BE2jRWJL5lOASsjQYKw09PbZQcSbbCVYLPcn505BZtYqd2MfojGvsvwKs= 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=KaGeGK7q; 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="KaGeGK7q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788352856; 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=KaGeGK7qIm36fyLQUeeMTyrxAZsiFuBAJRJoZxlMofDhpbKkj4QgKSqlzqnwFaA7/VVEbY RLKW6vIObYWn0wWU1mW+1WyXtQmZS7RcV2ZwGFrj+wHPL/jkX8d4vpFoJ8pl0ymQ9UnvLb 8Kb/0rTwmTu1R09Cqw3LRl5UBm1Mp88= 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-592-evUGaa1zP3ujXCvI2C7LBQ-1; Wed, 02 Sept 2026 08:40:52 -0400 X-MC-Unique: evUGaa1zP3ujXCvI2C7LBQ-1 X-Mimecast-MFC-AGG-ID: evUGaa1zP3ujXCvI2C7LBQ_1788352850 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 4B4B31921EEA; Wed, 2 Sep 2026 12:40:50 +0000 (UTC) Received: from vschneid-thinkpadt14sgen2i.remote.csb (unknown [10.44.33.19]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4FEB51955F72; Wed, 2 Sep 2026 12:40:46 +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 v5 8/8] rtla/osnoise: Trace IPI events when recording a trace file Date: Wed, 2 Sep 2026 14:39:37 +0200 Message-ID: <20260902123942.695822-9-vschneid@redhat.com> In-Reply-To: <20260902123942.695822-1-vschneid@redhat.com> References: <20260902123942.695822-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