Re: libtracecmd: tracecmd_filter_add filters unrelated events

Steven Rostedt <[email protected]> Fri, 30 May 2025 10:10:33 -0400
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
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.

-- Steve