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: Andi Kleen <ak@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	Arnaldo Carvalho de Melo <acme@infradead.org>,
	Andi Kleen <andi@firstfloor.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 4/5] perf, x86: Add INST_RETIRED.ALL workarounds
Date: Fri, 15 Aug 2014 16:31:21 +0200	[thread overview]
Message-ID: <20140815143121.GJ19379@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <CABPqkBQVwGH7GAVXAXjR1inWnWYeWuVG7Aj-aWAzAksdGq8oeg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]

On Thu, Aug 14, 2014 at 07:47:56PM +0200, Stephane Eranian wrote:
> [+perf tool maintainers]
> 
> On Thu, Aug 14, 2014 at 4:30 PM, Andi Kleen <ak@linux.intel.com> wrote:
> >
> > I understand all your points, but there's no alternative.
> > The only other way would be to disable INST_RETIRED.ALL.
> >
> You cannot do that either. INST_RETIRED:ALL is important.  I assume
> the bug applies whether or not the event is used with a filter.
> 
> I think we need to ensure that by looking at the perf.data file, one
> can reconstruct the total number of inst_Retired:all occurrences for
> the run. With a fixed period, one would do num_samples * fixed_period.
> I know the Gooda tool does that. It is used to estimate the number of
> events captured vs. the number of events occurring.

OK, I think we can make that work; IFF we guarantee
perf_event_attr::sample_period >= 128.

Suppose we start out with sample_period=192; then we'll set period_left
to 192, we'll end up with left = 128 (we truncate the lower bits). We
get an interrupt, find that period_left = 64 (>0 so we return 0 and
don't get an overflow handler), up that to 128. Then we trigger again,
at n=256. Then we find period_left = -64 (<=0 so we return 1 and do get
an overflow). We increment with sample_period so we get left = 128. We
fire again, at n=384, period_left = 0 (<=0 so we return 1 and get an
overflow). And on and on.

So while the individual interrupts are 'wrong' we get then with
interval=256,128 in exactly the right ratio to average out at 192. And
this works for everything >=128.

So the num_samples*fixed_period thing is still entirely correct +- 127,
which is good enough I'd say, as you already have that error anyhow.

So no need to 'fix' the tools, al we need to do is refuse to create
INST_RETIRED:ALL events with sample_period < 128.

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2014-08-15 14:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-14  1:17 Updated Broadwell perf patchkit Andi Kleen
2014-08-14  1:17 ` [PATCH 1/5] perf, x86: Remove incorrect model number from Haswell perf Andi Kleen
2014-08-14  1:17 ` [PATCH 2/5] perf, x86: Document all Haswell models Andi Kleen
2014-08-14  7:01   ` Peter Zijlstra
2014-08-14 15:00     ` Andi Kleen
2014-08-14  1:17 ` [PATCH 3/5] perf, x86: Add Broadwell core support Andi Kleen
2014-08-14  7:07   ` Peter Zijlstra
2014-08-14  7:32     ` Peter Zijlstra
2014-08-14 14:58       ` Andi Kleen
2014-08-14 15:10         ` Peter Zijlstra
2014-08-14  1:17 ` [PATCH 4/5] perf, x86: Add INST_RETIRED.ALL workarounds Andi Kleen
2014-08-14  4:46   ` Stephane Eranian
2014-08-14 14:30     ` Andi Kleen
2014-08-14 17:47       ` Stephane Eranian
2014-08-14 18:41         ` Andi Kleen
2014-08-15 14:31         ` Peter Zijlstra [this message]
2014-08-15 17:21           ` Andi Kleen
2014-08-14  7:10   ` Peter Zijlstra
2014-08-14  1:17 ` [PATCH 5/5] perf, x86: Use Broadwell cache event list for Haswell Andi Kleen
2014-08-25 22:43 Broadwell perf support Andi Kleen
2014-08-25 22:43 ` [PATCH 4/5] perf, x86: Add INST_RETIRED.ALL workarounds Andi Kleen
2014-09-01 13:41   ` Peter Zijlstra
2014-08-27 21:03 perf, x86: Updated Broadwell patchkit Andi Kleen
2014-08-27 21:03 ` [PATCH 4/5] perf, x86: Add INST_RETIRED.ALL workarounds Andi Kleen
2014-09-02 18:44 [PATCH 1/5] perf, x86: Remove incorrect model number from Haswell perf Andi Kleen
2014-09-02 18:44 ` [PATCH 4/5] perf, x86: Add INST_RETIRED.ALL workarounds Andi Kleen

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=20140815143121.GJ19379@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=acme@infradead.org \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@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

Powered by JetHome