From: Artem Savkov <asavkov@redhat.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/2] perf script: Fix perf script -F +metric
Date: Mon, 1 Jul 2024 09:04:38 +0200 [thread overview]
Message-ID: <20240701070438.GA12242@alecto.usersys.redhat.com> (raw)
In-Reply-To: <Zn8M39dHtqYpRa0o@tassilo>
On Fri, Jun 28, 2024 at 12:19:59PM -0700, Andi Kleen wrote:
> > This works, however there seems to be yet another issue on
> > perf-tools-next branch that breaks script metrics.
> >
> > 617824a7f0f73 (perf parse-events: Prefer sysfs/JSON hardware
> > events over legacy, 2024-04-15) changes event priority so on
> > my host "instructions" have type PERF_TYPE_RAW instead of
> > PERF_TYPE_HARDWARE.
>
> FWIW I don't see this on my build on Intel, even with that commit.
>
> > This results in evsel__stat_type no longer recognizing these as
> > STAT_INSTRUCTIONS.
>
> I guess we could just fix evsel__stat_type to handle that case
>
> Does this patch work?
It does for this specific example, but there are other events as well.
From arch/x86/events/intel/core.c:
static u64 intel_perfmon_event_map[PERF_COUNT_HW_MAX] __read_mostly =
{
[PERF_COUNT_HW_CPU_CYCLES] = 0x003c,
[PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
[PERF_COUNT_HW_CACHE_REFERENCES] = 0x4f2e,
[PERF_COUNT_HW_CACHE_MISSES] = 0x412e,
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4,
[PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5,
[PERF_COUNT_HW_BUS_CYCLES] = 0x013c,
[PERF_COUNT_HW_REF_CPU_CYCLES] = 0x0300, /* pseudo-encoding */
};
The list is probably different on other arches.
> perf: Workaround event priority problems
>
> When instructions is not of HARDWARE types anymore, but raw,
> which breaks the shadow stat metrics detection for IPC.
>
> Reported-by: Artem Savkov <asavkov@redhat.com>
> Fixes: 617824a7f0f73 (perf parse-events: Prefer sysfs/JSON hardware
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
> diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
> index 3466aa952442..87a503e47ff0 100644
> --- a/tools/perf/util/stat-shadow.c
> +++ b/tools/perf/util/stat-shadow.c
> @@ -97,9 +97,11 @@ static enum stat_type evsel__stat_type(const struct evsel *evsel)
>
> if (evsel__is_clock(evsel))
> return STAT_NSECS;
> - else if (evsel__match(evsel, HARDWARE, HW_CPU_CYCLES))
> + else if (evsel__match(evsel, HARDWARE, HW_CPU_CYCLES) ||
> + !strcmp(evsel__name((struct evsel *)evsel), "cycles"))
It is also probably worth to add a PERF_TYPE_RAW check.
> return STAT_CYCLES;
> - else if (evsel__match(evsel, HARDWARE, HW_INSTRUCTIONS))
> + else if (evsel__match(evsel, HARDWARE, HW_INSTRUCTIONS) ||
> + !strcmp(evsel__name((struct evsel *)evsel), "instructions"))
> return STAT_INSTRUCTIONS;
> else if (evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND))
> return STAT_STALLED_CYCLES_FRONT;
>
--
Artem
next prev parent reply other threads:[~2024-07-01 7:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 0:42 [PATCH 1/2] perf script: Fix perf script -F +metric Andi Kleen
2024-06-25 0:42 ` [PATCH 2/2] Add a test case for " Andi Kleen
2024-06-27 22:54 ` Namhyung Kim
2024-06-26 9:09 ` [PATCH 1/2] perf script: Fix " Artem Savkov
2024-06-27 22:50 ` Namhyung Kim
2024-06-28 19:19 ` Andi Kleen
2024-07-01 7:04 ` Artem Savkov [this message]
2024-07-01 16:54 ` Andi Kleen
2024-06-27 22:46 ` 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=20240701070438.GA12242@alecto.usersys.redhat.com \
--to=asavkov@redhat.com \
--cc=ak@linux.intel.com \
--cc=linux-perf-users@vger.kernel.org \
/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).