Re: libtracecmd: tracecmd_filter_add filters unrelated events

Petr Malat <[email protected]> Tue, 3 Jun 2025 04:51:23 -0400
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <CANMuvJk3JPs0BJBHk5CPJ_i2HXnT6VZkaEbfVpsv8rVdDSJTEw@mail.gmail.com>
Hi!
On Fri, May 30, 2025 at 10:10:33AM -0400, Steven Rostedt wrote:
> On Tue, 27 May 2025 09:22:01 -0500
> Petr Malat <[email protected]> wrote:
>
> > Hi,
> > when I attach a filter "subsys/event:field==val" using
> > tracecmd_filter_add(), it filters out all other events as well and
> > not just the event, for which the filter is relevant. I want to ask if
> > this is intentional or a bug. I expected the function to mirror filter
> > feature of ftrace, where setting a filter in events/subsys/event/filter
> > has no effect on other events than subsys/event.
> >
> > Per event filtering is done using tracecmd_follow_event(), so the
> > current behavior of tracecmd_filter_add() is redundant to it and
> > prevents creating per event filters without using custom callbacks.
> >
> > If this behavior is not intentional, I can prepare a patch to not filter
> > out events where none of the fillers is applicable to.
>
> Hmm, I think it was intentional because it's used to do filtering for
> trace-cmd report. Changing it will break behavior.
>
> It is supposed to follow what's in the man page: trace-cmd report
> under the -F option. If it doesn't follow that, then it is a bug.

Thanks for the clarification, I will use custom callbacks instead.
BR,
  Petr