From: Namhyung Kim <namhyung@kernel.org>
To: "Liang, Kan" <kan.liang@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>, Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org,
Ravi Bangoria <ravi.bangoria@amd.com>,
Mark Rutland <mark.rutland@arm.com>,
James Clark <james.clark@arm.com>,
Kajol Jain <kjain@linux.ibm.com>,
Thomas Richter <tmricht@linux.ibm.com>,
Atish Patra <atishp@atishpatra.org>,
Palmer Dabbelt <palmer@rivosinc.com>,
Mingwei Zhang <mizhang@google.com>
Subject: Re: [PATCH 07/10] perf tools: Separate exclude_hv fallback
Date: Mon, 30 Sep 2024 13:37:37 -0700 [thread overview]
Message-ID: <ZvsMEaZT9ESTWOxt@google.com> (raw)
In-Reply-To: <8b9d3cbb-99bd-4474-8daf-e9ab36e42a77@linux.intel.com>
On Fri, Sep 06, 2024 at 11:21:21AM -0400, Liang, Kan wrote:
>
>
> On 2024-09-05 4:24 p.m., Namhyung Kim wrote:
> > The exclude_hv was added in the evsel__fallback() in the commit
> > 4ec8d984895fef43a ("perf record: Fix priv level with branch sampling
> > for paranoid=2") to address branch stack samples on Intel PMUs.
> > As some other PMUs might not support that, let's separate the bit from
> > exclude_kernel to make sure it can add the bit only if required.
> >
> > Technically it should change the modifier string at the end of the
> > event name. ":u" is for exclude_kernel + exclude_hv, so it should be
> > ":uh" if it has exclude_kernel only. That means the default events for
> > regular users will looks like "cycles:Puh" (for perf record) or
> > "instructions:uh" (for perf stat). But I'm not sure if it's worth the
> > trouble so I didn't touch the name in this patch.
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> > tools/perf/util/evsel.c | 16 +++++++++++++---
> > 1 file changed, 13 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index 1a4f52767942e5ad..c5df45bb74dfc1b5 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -3389,10 +3389,20 @@ bool evsel__fallback(struct evsel *evsel, struct target *target, int err,
> > free(evsel->name);
> > evsel->name = new_name;
> > scnprintf(msg, msgsize, "kernel.perf_event_paranoid=%d, trying "
> > - "to fall back to excluding kernel and hypervisor "
> > - " samples", paranoid);
> > + "to fall back to excluding kernel samples", paranoid);
> > evsel->core.attr.exclude_kernel = 1;
> > - evsel->core.attr.exclude_hv = 1;
> > +
> > + return true;
> > + } else if (err == EACCES && !evsel->core.attr.exclude_hv &&
> > + (paranoid = perf_event_paranoid()) > 1) {
> > + /* If event has exclude user then don't exclude hv. */
> > + if (evsel->core.attr.exclude_user)
> > + return false;
> > +
> > + /* Intel branch stack requires exclude_hv */
>
> I don't think it's an requirement for Intel branch stack. The HV is
> ignored for all X86.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/events/core.c#n542
>
> I think it's a generic request for branch on all arch.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/events/core.c#n366
Ok, I'll update the comment.
Thanks,
Namhyung
>
> > + scnprintf(msg, msgsize, "kernel.perf_event_paranoid=%d, trying "
> > + "to fall back to excluding hypervisor samples", paranoid);
> > + evsel->core.attr.exclude_hv = 1;
> >
> > return true;
> > } else if (err == EOPNOTSUPP && !evsel->core.attr.exclude_guest &&
next prev parent reply other threads:[~2024-09-30 20:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 20:24 [RFC/PATCHSET 00/10] perf tools: Do not set attr.exclude_guest by default (v3) Namhyung Kim
2024-09-05 20:24 ` [PATCH 01/10] perf tools: Add fallback for exclude_guest Namhyung Kim
2024-09-06 13:47 ` Liang, Kan
2024-09-30 20:36 ` Namhyung Kim
2024-09-05 20:24 ` [PATCH 02/10] perf tools: Don't set attr.exclude_guest by default Namhyung Kim
2024-09-06 14:10 ` Liang, Kan
2024-09-05 20:24 ` [PATCH 03/10] perf tools: Simplify evsel__add_modifier() Namhyung Kim
2024-09-05 20:24 ` [PATCH 04/10] perf stat: Add --exclude-guest option Namhyung Kim
2024-09-06 14:33 ` Liang, Kan
2024-09-23 8:47 ` James Clark
2024-09-24 20:21 ` Namhyung Kim
2024-09-25 8:36 ` James Clark
2024-09-30 20:13 ` Namhyung Kim
2024-09-25 13:49 ` Liang, Kan
2024-09-30 20:07 ` Namhyung Kim
2024-09-05 20:24 ` [PATCH 05/10] perf tools: Do not set exclude_guest for precise_ip Namhyung Kim
2024-09-05 20:24 ` [PATCH 06/10] perf tools: Detect missing kernel features properly Namhyung Kim
2024-09-05 20:24 ` [PATCH 07/10] perf tools: Separate exclude_hv fallback Namhyung Kim
2024-09-06 15:21 ` Liang, Kan
2024-09-30 20:37 ` Namhyung Kim [this message]
2024-09-05 20:24 ` [PATCH 08/10] perf tools: Move x86__is_amd_cpu() to util/env.c Namhyung Kim
2024-09-05 20:24 ` [PATCH 09/10] perf tools: Check fallback error and order Namhyung Kim
2024-09-05 20:24 ` [PATCH 10/10] perf record: Just use "cycles:P" as the default event Namhyung Kim
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=ZvsMEaZT9ESTWOxt@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=atishp@atishpatra.org \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=mizhang@google.com \
--cc=palmer@rivosinc.com \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=tmricht@linux.ibm.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.