Re: [PATCH v2] ftrace: properly merge notrace hash
From: Steven Rostedt
Date: Tue Apr 08 2025 - 12:35:14 EST
On Wed, 9 Apr 2025 00:02:57 +0800
Andy Chiu <andybnac@xxxxxxxxx> wrote:
> The global notrace hash should be jointly decided by the intersection of
> each subops's notrace hash, but not the filter hash.
>
> Fixes: 5fccc7552ccb ("ftrace: Add subops logic to allow one ops to manage many")
> Signed-off-by: Andy Chiu <andybnac@xxxxxxxxx>
>
Thanks.
I'll apply this (currently testing it along with other fixes), but I
realized that this isn't working as expected.
I did the following:
# trace-cmd start -B foo -p function_graph -l '*lock*' -n '*clock*'
# trace-cmd start -B bar -p function_graph -l '*sched*' -n '*time*'
And then looked at:
# cat /sys/kernel/tracing/enabled_functions |grep clock | wc -l
176
# cat /sys/kernel/tracing/enabled_functions |grep time | wc -l
37
Which means those functions are still having callbacks even though nothing
is tracing them.
What needs to be done is to filter out the filter ops from the notrace ops
before adding them to the main ops.
The main ops shouldn't need any notrace hash unless all the subops hashes
are the empty set.
What needs to be done when adding a new subops is to:
Copy subops filter hash:
If subops filter hash is not empty:
1) Remove all the nohash functions from the copy.
2) If the main ops notrace hash is not empty, remove any of the functions
in the copy from it.
If subops filter hash is empty
1) intersect the notrace ops with the current notrace ops
I'll write up a patch on top of this one.
-- Steve