From: Valentin Schneider <vschneid@redhat.com>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Tomas Glozar <tglozar@redhat.com>,
Costa Shulyupin <costa.shul@redhat.com>,
Crystal Wood <crwood@redhat.com>, John Kacur <jkacur@redhat.com>,
Ivan Pravdin <ipravdin.official@gmail.com>,
Jonathan Corbet <corbet@lwn.net>
Subject: [RFC PATCH v2 2/4] rtla/osnoise: Record IPI count in osnoise top
Date: Wed, 17 Jun 2026 15:17:57 +0200 [thread overview]
Message-ID: <20260617131803.2988989-3-vschneid@redhat.com> (raw)
In-Reply-To: <20260617131803.2988989-1-vschneid@redhat.com>
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 <vschneid@redhat.com>
---
tools/tracing/rtla/src/osnoise_top.c | 124 ++++++++++++++++++++++++++-
1 file changed, 123 insertions(+), 1 deletion(-)
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 512a6299cb018..5b462a3543b97 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -8,6 +8,7 @@
#include <string.h>
#include <signal.h>
#include <unistd.h>
+#include <errno.h>
#include <stdio.h>
#include <time.h>
@@ -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;
int sum_cycles;
};
@@ -70,6 +72,91 @@ static struct osnoise_top_data *osnoise_alloc_top(void)
return NULL;
}
+static void account_ipi(struct osnoise_tool *tool,
+ unsigned long long src_cpu, unsigned long long dst_cpu)
+{
+ struct osnoise_top_cpu *cpu_data;
+ struct osnoise_top_data *data;
+ unsigned long long inc = 1;
+
+ data = tool->data;
+ cpu_data = &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 src_cpu, dst_cpu;
+ struct trace_instance *trace = context;
+
+ tool = container_of(trace, struct osnoise_tool, trace);
+ params = to_osnoise_params(tool->params);
+
+ src_cpu = record->cpu;
+ tep_get_field_val(s, event, "cpu", record, &dst_cpu, 1);
+
+ if (CPU_ISSET(dst_cpu, ¶ms->common.monitored_cpus))
+ account_ipi(tool, src_cpu, dst_cpu);
+
+ return 0;
+}
+
+static cpu_set_t cpumask_tmp_cpus;
+
+/*
+ * osnoise_ipi_cpumask_handler - this is the handler for broadcasted IPI events.
+ */
+static int
+osnoise_ipi_cpumask_handler(struct trace_seq *s, struct tep_record *record,
+ struct tep_event *event, void *context)
+{
+ struct trace_instance *trace = context;
+ struct osnoise_tool *tool;
+ struct osnoise_params *params;
+ struct tep_format_field *field;
+ unsigned long long src_cpu;
+ cpu_set_t *event_cpus;
+ int len;
+
+ tool = container_of(trace, struct osnoise_tool, trace);
+ params = to_osnoise_params(tool->params);
+
+ src_cpu = record->cpu;
+
+ field = tep_find_field(event, "cpumask");
+ if (!field)
+ return 0;
+
+ event_cpus = 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 = 0; cpu < nr_cpus; cpu++) {
+ if (CPU_ISSET(cpu, &cpumask_tmp_cpus))
+ account_ipi(tool, src_cpu, cpu);
+ }
+ }
+
+ return 0;
+}
+
/*
* osnoise_top_handler - this is the handler for osnoise tracer events
*/
@@ -164,6 +251,8 @@ static void osnoise_top_header(struct osnoise_tool *top)
goto eol;
trace_seq_printf(s, " IRQ Softirq Thread");
+ if (params->common.ipi)
+ trace_seq_printf(s, " IPI");
eol:
if (pretty)
@@ -218,7 +307,13 @@ static void osnoise_top_print(struct osnoise_tool *tool, int cpu)
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, "\n");
+ return;
+ }
+
+ trace_seq_printf(s, " %12llu\n", cpu_data->ipi_count);
}
/*
@@ -281,6 +376,7 @@ osnoise_top_apply_config(struct osnoise_tool *tool)
struct osnoise_tool *osnoise_init_top(struct common_params *params)
{
struct osnoise_tool *tool;
+ int retval;
tool = osnoise_init_tool("osnoise_top");
if (!tool)
@@ -295,7 +391,33 @@ struct osnoise_tool *osnoise_init_top(struct common_params *params)
tep_register_event_handler(tool->trace.tep, -1, "ftrace", "osnoise",
osnoise_top_handler, NULL);
+ if (!params->ipi)
+ goto out;
+
+ retval = 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 = tracefs_event_enable(tool->trace.inst, "ipi", "ipi_send_cpumask");
+ 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;
}
struct tool_ops osnoise_top_ops = {
--
2.54.0
next prev parent reply other threads:[~2026-06-17 13:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 13:17 [RFC PATCH v2 0/4] tracing/osnoise: Track IPIs Valentin Schneider
2026-06-17 13:17 ` [RFC PATCH v2 1/4] rtla/osnoise: Add IPI tracking cmdline option Valentin Schneider
2026-06-17 13:17 ` Valentin Schneider [this message]
2026-06-17 13:17 ` [RFC PATCH v2 3/4] rtla/osnoise: Trace IPI events when recording a trace file Valentin Schneider
2026-06-17 13:17 ` [RFC PATCH v2 4/4] rtla/osnoise: Leverage IPI event filters when tracing a subset of CPUs Valentin Schneider
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260617131803.2988989-3-vschneid@redhat.com \
--to=vschneid@redhat.com \
--cc=corbet@lwn.net \
--cc=costa.shul@redhat.com \
--cc=crwood@redhat.com \
--cc=ipravdin.official@gmail.com \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglozar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox