mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: "Liang, Kan" <kan.liang@linux.intel.com>,
	linux-kernel@vger.kernel.org, kan.liang@intel.com,
	ak@linux.intel.com, namhyung.kim@kernel.org, irogers@google.com
Subject: Re: [PATCH] perf/x86/intel/uncore: fix broken read_counter() for SNB IMC PMU
Date: Thu, 25 Aug 2022 11:26:19 +0200	[thread overview]
Message-ID: <YwdAOwS7AK/KrOfJ@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <CABPqkBSGXwm_OFWt9tDq2WuXpuLtOJzekhiqH=c0_rOX6ZM2=g@mail.gmail.com>

On Mon, Aug 15, 2022 at 03:28:36PM -0700, Stephane Eranian wrote:
> On Thu, Aug 4, 2022 at 6:09 AM Liang, Kan <kan.liang@linux.intel.com> wrote:
> >
> >
> >
> > On 2022-08-03 12:00 p.m., Stephane Eranian wrote:
> > > Existing code was generating bogus counts for the SNB IMC bandwidth counters:
> > >
> > > $ perf stat -a -I 1000 -e uncore_imc/data_reads/,uncore_imc/data_writes/
> > >      1.000327813           1,024.03 MiB  uncore_imc/data_reads/
> > >      1.000327813              20.73 MiB  uncore_imc/data_writes/
> > >      2.000580153         261,120.00 MiB  uncore_imc/data_reads/
> > >      2.000580153              23.28 MiB  uncore_imc/data_writes/
> > >
> > > The problem was introduced by commit:
> > >   07ce734dd8ad ("perf/x86/intel/uncore: Clean up client IMC")
> > >
> > > Where the read_counter callback was replace to point to the generic
> > > uncore_mmio_read_counter() function.
> > >
> > > The SNB IMC counters are freerunnig 32-bit counters laid out contiguously in
> > > MMIO. But uncore_mmio_read_counter() is using a readq() call to read from
> > > MMIO therefore reading 64-bit from MMIO. Although this is okay for the
> > > uncore_perf_event_update() function because it is shifting the value based
> > > on the actual counter width to compute a delta, it is not okay for the
> > > uncore_pmu_event_start() which is simply reading the counter  and therefore
> > > priming the event->prev_count with a bogus value which is responsible for
> > > causing bogus deltas in the perf stat command above.
> > >
> > > The fix is to reintroduce the custom callback for read_counter for the SNB
> > > IMC PMU and use readl() instead of readq(). With the change the output of
> > > perf stat is back to normal:
> > > $ perf stat -a -I 1000 -e uncore_imc/data_reads/,uncore_imc/data_writes/
> > >      1.000120987             296.94 MiB  uncore_imc/data_reads/
> > >      1.000120987             138.42 MiB  uncore_imc/data_writes/
> > >      2.000403144             175.91 MiB  uncore_imc/data_reads/
> > >      2.000403144              68.50 MiB  uncore_imc/data_writes/
> > >
> > > Signed-off-by: Stephane Eranian <eranian@google.com>
> >
> > Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
> >
> Any further comments?

Got lost in the holiday pile-up, applied!

  reply	other threads:[~2022-08-25  9:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 16:00 Stephane Eranian
2022-08-04 13:08 ` Liang, Kan
2022-08-15 22:28   ` Stephane Eranian
2022-08-25  9:26     ` Peter Zijlstra [this message]
2022-08-25 18:58       ` Stephane Eranian
2022-08-26 22:16 ` [tip: perf/urgent] perf/x86/intel/uncore: Fix " tip-bot2 for Stephane Eranian

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=YwdAOwS7AK/KrOfJ@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=kan.liang@intel.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung.kim@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

all inboxes | Powered by JetHome®