linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Stephane Eranian <eranian@google.com>,
	Ian Rogers <irogers@google.com>,
	Kan Liang <kan.liang@linux.intel.com>,
	James Clark <james.clark@linaro.org>, Leo Yan <leo.yan@arm.com>,
	Joe Mario <jmario@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Santosh Shukla <santosh.shukla@amd.com>,
	Ananth Narayan <ananth.narayan@amd.com>,
	Sandipan Das <sandipan.das@amd.com>,
	bpf@vger.kernel.org
Subject: Re: [PATCH 1/4] perf/amd/ibs: Add load/store SW filters to IBS OP PMU
Date: Mon, 2 Jun 2025 23:52:00 -0700	[thread overview]
Message-ID: <aD6bkAXjRllFvRTV@google.com> (raw)
In-Reply-To: <aDq1iG3P9_BBnx7C@gmail.com>

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

  reply	other threads:[~2025-06-03  6:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29 12:34 [PATCH 0/4] perf/amd/ibs: Introduce load/store SW filter Ravi Bangoria
2025-05-29 12:34 ` [PATCH 1/4] perf/amd/ibs: Add load/store SW filters to IBS OP PMU Ravi Bangoria
2025-05-31  7:53   ` Ingo Molnar
2025-06-03  6:52     ` Namhyung Kim [this message]
2025-06-10  5:12       ` Ravi Bangoria
2025-05-29 12:34 ` [PATCH 2/4] perf mem/c2c amd: Wire IBS OP PMU load/store SW filter Ravi Bangoria
2025-05-29 12:34 ` [PATCH 3/4] perf test amd: Add IBS load/store swfilt tests Ravi Bangoria
2025-05-29 12:34 ` [PATCH 4/4] perf doc amd: Update perf-amd-ibs man page Ravi Bangoria

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=aD6bkAXjRllFvRTV@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=ananth.narayan@amd.com \
    --cc=bpf@vger.kernel.org \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jmario@redhat.com \
    --cc=kan.liang@linux.intel.com \
    --cc=leo.yan@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=sandipan.das@amd.com \
    --cc=santosh.shukla@amd.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;
as well as URLs for NNTP newsgroup(s).