* Re: [PATCH 1/4] perf/amd/ibs: Add load/store SW filters to IBS OP PMU
[not found] ` <aDq1iG3P9_BBnx7C@gmail.com>
@ 2025-06-03 6:52 ` Namhyung Kim
2025-06-10 5:12 ` Ravi Bangoria
0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2025-06-03 6:52 UTC (permalink / raw)
To: Ingo Molnar
Cc: Ravi Bangoria, Peter Zijlstra, Arnaldo Carvalho de Melo,
Ingo Molnar, Stephane Eranian, Ian Rogers, Kan Liang, James Clark,
Leo Yan, Joe Mario, linux-kernel, linux-perf-users,
Santosh Shukla, Ananth Narayan, Sandipan Das, bpf
Hello,
+ bpf list
On Sat, May 31, 2025 at 09:53:44AM +0200, Ingo Molnar wrote:
>
> * Ravi Bangoria <ravi.bangoria@amd.com> wrote:
>
> > Since current IBS OP PMU does not have the capability to tag only load/
> > stores instructions, tools like perf mem/c2c ends up recording lots of
> > unwanted samples. So, introduce a load/store software filter in the IBS
> > OP PMU:
> >
> > ibs_op/swfilt=1,ldop=1/ --> Only load samples
> > ibs_op/swfilt=1,stop=1/ --> Only store samples
> > ibs_op/swfilt=1,ldop=1,stop=1/ --> Load OR store samples
> >
> > Other HW or SW filters in combination with this ldst filter are logical
> > AND. For ex:
> >
> > ibs_op/swfilt=1,ldop=1,stop=1/u is
> > "privilege == userspace && (ldop == 1 || stop == 1)"
> >
> > ibs_op/swfilt=1,ldop=1,stop=1,l3missonly=1/ is
> > "l3missonly == 1 && (ldop == 1 || stop == 1)"
>
> No objections, but:
>
> > An alternate approach is mem_op BPF filter:
> >
> > perf record --filter "mem_op == load || mem_op == store" ...
> >
> > However, there are few issues with it:
> > o BPF filter is called after preparing entire perf sample. If the sample
> > does not satisfy the filtering criteria, all the efforts of preparing
> > perf sample gets wasted.
>
> Could we add an 'early' BPF callback point as well, to fast-discard
> samples?
I guess that would require a new BPF program type than PERF_EVENT and
handle driver-specific details.
>
> > o BPF filter requires root privilege.
>
> Could we add 'built-in', 'safe' BPF scripts that are specifically
> prepared for perf events filtering purposes, that can be toggled by
> non-root users as well? These could be toggled by tooling via sysfs or
> so, or even via the perf syscall if that turns out to be the better
> approach.
We have BPF filter framework in the perf tools and it can be run as
normal user. But root user should load and pin the BPF program prior
to use like below.
$ sudo perf record --setup-filter pin
$ perf record -d -e ibs_op/swfilt/u --filter 'mem_op == load' ...
Thanks,
Namhyung
>
> It would give us the flexibility and extensibility of BPF, combining it
> with the safety & compatibility of the filtering functionality being
> provided by the kernel.
>
> It could be provided in the form of a BPF program crypto signature
> registry of upstream-approved BPF scripts for perf BPF callback(s),
> or so. (While root could load any BPF script.)
>
> Thanks,
>
> Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/4] perf/amd/ibs: Add load/store SW filters to IBS OP PMU
2025-06-03 6:52 ` [PATCH 1/4] perf/amd/ibs: Add load/store SW filters to IBS OP PMU Namhyung Kim
@ 2025-06-10 5:12 ` Ravi Bangoria
0 siblings, 0 replies; 2+ messages in thread
From: Ravi Bangoria @ 2025-06-10 5:12 UTC (permalink / raw)
To: Ingo Molnar, Namhyung Kim
Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, Ingo Molnar,
Stephane Eranian, Ian Rogers, Kan Liang, James Clark, Leo Yan,
Joe Mario, linux-kernel, linux-perf-users, Santosh Shukla,
Ananth Narayan, Sandipan Das, bpf, Ravi Bangoria
Hi Ingo, Namhyung,
>>> An alternate approach is mem_op BPF filter:
>>>
>>> perf record --filter "mem_op == load || mem_op == store" ...
>>>
>>> However, there are few issues with it:
>>> o BPF filter is called after preparing entire perf sample. If the sample
>>> does not satisfy the filtering criteria, all the efforts of preparing
>>> perf sample gets wasted.
>>
>> Could we add an 'early' BPF callback point as well, to fast-discard
>> samples?
>
> I guess that would require a new BPF program type than PERF_EVENT and
> handle driver-specific details.
Right.
>>> o BPF filter requires root privilege.
>>
>> Could we add 'built-in', 'safe' BPF scripts that are specifically
>> prepared for perf events filtering purposes, that can be toggled by
>> non-root users as well? These could be toggled by tooling via sysfs or
>> so, or even via the perf syscall if that turns out to be the better
>> approach.
>
> We have BPF filter framework in the perf tools and it can be run as
> normal user. But root user should load and pin the BPF program prior
> to use like below.
>
> $ sudo perf record --setup-filter pin
>
> $ perf record -d -e ibs_op/swfilt/u --filter 'mem_op == load' ...
Thanks Namhyung.
Ingo, Do you feel the idea of perf specific 'safe' BPF script is still
worth pursuing despite similar functionality is already provided by
--setup-filter?
Thanks,
Ravi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-10 5:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250529123456.1801-1-ravi.bangoria@amd.com>
[not found] ` <20250529123456.1801-2-ravi.bangoria@amd.com>
[not found] ` <aDq1iG3P9_BBnx7C@gmail.com>
2025-06-03 6:52 ` [PATCH 1/4] perf/amd/ibs: Add load/store SW filters to IBS OP PMU Namhyung Kim
2025-06-10 5:12 ` Ravi Bangoria
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox