All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@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>
Subject: Re: [PATCH 1/4] perf/amd/ibs: Add load/store SW filters to IBS OP PMU
Date: Sat, 31 May 2025 09:53:44 +0200	[thread overview]
Message-ID: <aDq1iG3P9_BBnx7C@gmail.com> (raw)
In-Reply-To: <20250529123456.1801-2-ravi.bangoria@amd.com>


* 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?

> 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.

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-05-31  7:53 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 [this message]
2025-06-03  6:52     ` Namhyung Kim
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=aDq1iG3P9_BBnx7C@gmail.com \
    --to=mingo@kernel.org \
    --cc=acme@kernel.org \
    --cc=ananth.narayan@amd.com \
    --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@redhat.com \
    --cc=namhyung@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.