Linux Trace Kernel
 help / color / mirror / Atom feed
From: Valentin Schneider <vschneid@redhat.com>
To: Tomas Glozar <tglozar@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.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: Re: [RFC PATCH v2 4/4] rtla/osnoise: Leverage IPI event filters when tracing a subset of CPUs
Date: Tue, 30 Jun 2026 15:59:50 +0200	[thread overview]
Message-ID: <xhsmhmrwcw2ll.mognet@vschneid-thinkpadt14sgen2i.remote.csb> (raw)
In-Reply-To: <CAP4=nvQ_x+LyDBoQWOBB4ERy8OwEp9LQzyLJJMHzYdrZzK4zyw@mail.gmail.com>

On 30/06/26 12:14, Tomas Glozar wrote:
> st 17. 6. 2026 v 15:18 odesílatel Valentin Schneider
> <vschneid@redhat.com> napsal:
>> @@ -406,6 +408,33 @@ struct osnoise_tool *osnoise_init_top(struct common_params *params)
>>                 goto out_err;
>>         }
>>
>> +       /*
>> +        * 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 = tracefs_event_file_write(tool->trace.inst,
>> +                                                 "ipi", "ipi_send_cpu", "filter",
>> +                                                 filter);
>> +               if (retval) {
>
> retval is the number of bytes written here, so this should be "retval
> < 0" like in trace_event_enable_filter() in trace.c. Same below.
>

According to the docstring:

 * Return 0 on success, and -1 on error.

but regardless yes that should be a '< 0' check to match existing code.

>> +                       err_msg("Could not set ipi_send_cpu CPU filter\n");
>> +                       goto out_err;
>
> It would be useful to have --ipi work even on older kernels that don't
> yet have your cpumask trace event filter patchset [1], for example, by
> printing a debug message that filtering is disabled and setting a flag
> instead of erroring out here. Then the code in
> osnoise_ipi_cpu_handler() can preserve the CPU_ISSET check if the flag
> is set.
>
> As --ipi is optional, we can choose to only support it on newer
> kernels, but it would be nice to have it working without the filter,
> too.
>
> [1] https://lore.kernel.org/linux-trace-kernel/20230707172155.70873-1-vschneid@redhat.com/T/#u
>

Makes sense, will do.

>> +               }
>> +
>> +
>> +               snprintf(filter, ARRAY_SIZE(filter), "cpumask & CPUS{%s}\n", params->cpus);
>> +               retval = tracefs_event_file_write(tool->trace.inst,
>> +                                                 "ipi", "ipi_send_cpumask", "filter",
>> +                                                 filter);
>> +               if (retval) {
>> +                       err_msg("Could not set ipi_send_cpumask CPU filter\n");
>> +                       goto out_err;
>> +               }
>
> Same two comments above apply here.
>
>> +       }
>> +
>>         tep_register_event_handler(tool->trace.tep, -1, "ipi", "ipi_send_cpu",
>>                                    osnoise_ipi_cpu_handler, NULL);
>>
>> --
>> 2.54.0
>>
>
> I was thinking that it might make sense to enable the filters also for
> the trace output instance. On the other hand, it would make it
> difficult to enable the event without the filter then, as specifying
> "-e ipi" or similar only re-enables the event but does not remove the
> filter. Maybe the better idea is to implement an option to filter any
> event enabled through -e/--event only to the measurement CPU, as a
> separate feature.
>

I had actually forgotten about applying the filters for the output
instance... I'll look into it.

> Tomas


  reply	other threads:[~2026-06-30 13:59 UTC|newest]

Thread overview: 17+ 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-29 10:51   ` Tomas Glozar
2026-06-30 13:59     ` Valentin Schneider
2026-06-17 13:17 ` [RFC PATCH v2 2/4] rtla/osnoise: Record IPI count in osnoise top Valentin Schneider
2026-06-29 12:56   ` Tomas Glozar
2026-06-30 13:59     ` Valentin Schneider
2026-06-17 13:17 ` [RFC PATCH v2 3/4] rtla/osnoise: Trace IPI events when recording a trace file Valentin Schneider
2026-06-30 11:32   ` Tomas Glozar
2026-06-17 13:17 ` [RFC PATCH v2 4/4] rtla/osnoise: Leverage IPI event filters when tracing a subset of CPUs Valentin Schneider
2026-06-30 10:14   ` Tomas Glozar
2026-06-30 13:59     ` Valentin Schneider [this message]
2026-07-01  6:45       ` Tomas Glozar
2026-07-01  7:25         ` Valentin Schneider
2026-07-01 13:11         ` Steven Rostedt
2026-06-26 10:26 ` [RFC PATCH v2 0/4] tracing/osnoise: Track IPIs Steven Rostedt
2026-06-26 12:25   ` 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=xhsmhmrwcw2ll.mognet@vschneid-thinkpadt14sgen2i.remote.csb \
    --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