From: Matt Fleming <matt@codeblueprint.co.uk>
To: Borislav Petkov <bp@alien8.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] perf/x86/amd: Make HW_CACHE_REFERENCES and HW_CACHE_MISSES measure L2
Date: Mon, 15 Aug 2016 16:13:16 +0100 [thread overview]
Message-ID: <20160815151316.GI30909@codeblueprint.co.uk> (raw)
In-Reply-To: <20160811164150.GB7296@nazgul.tnic>
On Thu, 11 Aug, at 06:41:50PM, Borislav Petkov wrote:
> Drop stable from CC.
>
> On Thu, Aug 11, 2016 at 04:21:42PM +0100, Matt Fleming wrote:
> > While the Intel PMU monitors the LLC when perf enables the
> > HW_CACHE_REFERENCES and HW_CACHE_MISSES events, these events monitor
> > L1 instruction cache fetches (0x0080) and instruction cache misses
> > (0x0081) on the AMD PMU.
> >
> > This is extremely confusing when monitoring the same workload across
> > Intel and AMD machines, since parameters like,
> >
> > $ perf stat -e cache-references,cache-misses
> >
> > measure completely different things.
> >
> > Instead, make the AMD PMU measure instruction/data cache fill requests
> > to the L2 and instruction/data cache misses in the L2 when
> > HW_CACHE_REFERENCES and HW_CACHE_MISSES are enabled, respectively.
> > That way the events measure unified caches on both platforms.
>
> I guess that's closer.
>
> Even though LLC is not always L2 on AMD (some have L3). Btw,
> what are the exact events for PERF_COUNT_HW_CACHE_REFERENCES and
> PERF_COUNT_HW_CACHE_MISSES called on Intel?
They're referred to as "LLC Reference" and "LLC Misses" in the Intel
SDM Table 18-1 and "Longest latency cache references/misses" in Table
19-1.
> I could try to find better/more fitting event selectors on AMD...
If you've got any other suggestions, I'm all ears. Note that one thing
I wasn't sure about was whether we want to include TLB events hitting
the L2. I left them out of this patch, but it might make sense to add
them so that HW_CACHE_{REFERENCES,MISSES} is actually distinguishable
from LLC-{loads,misses}.
> > Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Borislav Petkov <bp@alien8.de>
> > Cc: <stable@vger.kernel.org>
> > ---
> > arch/x86/events/amd/core.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
> > index e07a22bb9308..8fd8bf79f32b 100644
> > --- a/arch/x86/events/amd/core.c
> > +++ b/arch/x86/events/amd/core.c
> > @@ -119,8 +119,8 @@ static const u64 amd_perfmon_event_map[PERF_COUNT_HW_MAX] =
> > {
> > [PERF_COUNT_HW_CPU_CYCLES] = 0x0076,
> > [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
> > - [PERF_COUNT_HW_CACHE_REFERENCES] = 0x0080,
> > - [PERF_COUNT_HW_CACHE_MISSES] = 0x0081,
> > + [PERF_COUNT_HW_CACHE_REFERENCES] = 0x037d,
> > + [PERF_COUNT_HW_CACHE_MISSES] = 0x037e,
> > [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2,
> > [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3,
> > [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00d0, /* "Decoder empty" event */
>
> Btw, there's also amd_event_mapping in arch/x86/kvm/pmu_amd.c which has
> duplicated amd_perfmon_event_map. Would need adjusting too.
Urgh, right. I totally missed that. I'll update.
next prev parent reply other threads:[~2016-08-15 15:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 15:21 [PATCH] perf/x86/amd: Make HW_CACHE_REFERENCES and HW_CACHE_MISSES measure L2 Matt Fleming
2016-08-11 16:41 ` Borislav Petkov
2016-08-15 15:13 ` Matt Fleming [this message]
2016-08-18 16:25 ` Borislav Petkov
2016-08-19 13:34 ` Peter Zijlstra
2016-08-19 14:44 ` Borislav Petkov
2016-08-19 15:16 ` Peter Zijlstra
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=20160815151316.GI30909@codeblueprint.co.uk \
--to=matt@codeblueprint.co.uk \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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