From: Andi Kleen <andi@firstfloor.org>
To: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <andi@firstfloor.org>, Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrew Morton <akpm@linux-foundation.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH 07/12] perf, x86: Avoid checkpointed counters causing excessive TSX aborts v3
Date: Tue, 29 Jan 2013 00:16:59 +0100 [thread overview]
Message-ID: <20130128231659.GW30577@one.firstfloor.org> (raw)
In-Reply-To: <CABPqkBTM8w_RVrQNiyhBprMBjL5a0Q7Y9KQsKP3Ld62EZPSufQ@mail.gmail.com>
> I don't buy really this workaround. You are assuming you're always
> measuring INTC_CHECKPOINTED
> event by itself.
There's no such assumption.
> So what if you get into the handler because of an PMI
> due to an overflow
> of another counter which is active at the same time as counter2?
> You're going to artificially
> add an overflow to counter2. Unless you're enforcing only counter2 in use.
All the code does it to always check the counter. There's no
"overflow added". For counting it may be set back and accumulated
a bit earlier than normal, but that's no problem. This will only
happen for a checkpointed counter 2, not for anything else.
> The counter is reinstated to its state before the critical section but
> the PMI cannot be
> cancelled and there is no state left behind to tell what to do with it.
The PMI is effectively spurious, but we use it to set back. Don't know
what you mean with "cancel". It already happened of course.
> static inline bool is_event_intx_cp(struct perf_event *event)
> {
> return event && (event->hw.config & HSW_INTX_CHECKPOINTED);
> }
They both look the same to me.
>
>
> > for_each_set_bit(bit, (unsigned long *)&status, X86_PMC_IDX_MAX) {
> > struct perf_event *event = cpuc->events[bit];
> >
> > @@ -1615,6 +1635,20 @@ static int hsw_hw_config(struct perf_event *event)
> > ((event->hw.config & ARCH_PERFMON_EVENTSEL_ANY) ||
> > event->attr.precise_ip > 0))
> > return -EIO;
> > + if (event->hw.config & HSW_INTX_CHECKPOINTED) {
> > + /*
> > + * Sampling of checkpointed events can cause situations where
> > + * the CPU constantly aborts because of a overflow, which is
> > + * then checkpointed back and ignored. Forbid checkpointing
> > + * for sampling.
> > + *
> > + * But still allow a long sampling period, so that perf stat
> > + * from KVM works.
> > + */
>
> What has perf stat have to do with sample_period?
It always uses a period to accumulate in a larger counter as you probably know.
Also with the other code we only allow checkpoint with stat.
>
> > + if (event->attr.sample_period > 0 &&
> > + event->attr.sample_period < 0x7fffffff)
> > + return -EIO;
> > + }
> same comment about -EIO vs. EOPNOTSUPP. sample_period is u64
> so, it's always >= 0. Where does this 31-bit limit come from?
That's what perf stat uses when running in the KVM guest.
> Experimentation?
The code does > 0, not >= 0
> Could be written:
> if (event->attr.sample_period && event->attr.sample_period < 0x7fffffff)
That's 100% equivalent to what I wrote.
I can change the error value.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
next prev parent reply other threads:[~2013-01-28 23:17 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 22:00 Basic perf PMU support for Haswell v1 Andi Kleen
2013-01-25 22:00 ` [PATCH 01/12] perf, x86: Add PEBSv2 record support Andi Kleen
2013-01-28 13:15 ` Stephane Eranian
2013-01-28 16:10 ` Andi Kleen
2013-01-31 17:15 ` Stephane Eranian
2013-01-25 22:00 ` [PATCH 02/12] perf, x86: Basic Haswell PMU support v2 Andi Kleen
2013-01-28 15:34 ` Stephane Eranian
2013-01-28 16:16 ` Andi Kleen
2013-01-25 22:00 ` [PATCH 03/12] perf, x86: Basic Haswell PEBS support v3 Andi Kleen
2013-01-28 15:56 ` Stephane Eranian
2013-01-25 22:00 ` [PATCH 04/12] perf, x86: Support the TSX intx/intx_cp qualifiers v2 Andi Kleen
2013-01-26 11:54 ` Ingo Molnar
2013-01-26 21:00 ` Andi Kleen
2013-01-27 13:14 ` Ingo Molnar
[not found] ` <20130128050234.GQ30577@one.firstfloor.org>
2013-01-28 10:47 ` Ingo Molnar
2013-01-28 16:52 ` Stephane Eranian
2013-01-28 17:37 ` Andi Kleen
2013-01-25 22:00 ` [PATCH 05/12] perf, x86: Support Haswell v4 LBR format Andi Kleen
2013-01-28 21:47 ` Stephane Eranian
2013-01-28 22:08 ` Andi Kleen
2013-01-28 22:20 ` Stephane Eranian
2013-01-25 22:00 ` [PATCH 06/12] perf, x86: Support full width counting Andi Kleen
2013-01-25 22:00 ` [PATCH 07/12] perf, x86: Avoid checkpointed counters causing excessive TSX aborts v3 Andi Kleen
2013-01-28 22:32 ` Stephane Eranian
2013-01-28 23:16 ` Andi Kleen [this message]
2013-01-29 0:30 ` Stephane Eranian
2013-01-29 1:00 ` Andi Kleen
2013-01-30 8:51 ` Stephane Eranian
2013-01-30 20:58 ` Andi Kleen
2013-01-25 22:00 ` [PATCH 08/12] perf, x86: Move NMI clearing to end of PMI handler after the counter registers are reset Andi Kleen
2013-01-25 22:00 ` [PATCH 09/12] perf, x86: Disable LBR recording for unknown LBR_FMT Andi Kleen
2013-01-25 22:00 ` [PATCH 10/12] perf, x86: Support LBR filtering by INTX/NOTX/ABORT v2 Andi Kleen
2013-01-25 22:00 ` [PATCH 11/12] perf, tools: Support sorting by intx, abort branch flags v2 Andi Kleen
2013-01-25 22:00 ` [PATCH 12/12] perf, tools: Add abort_tx,no_tx,in_tx branch filter options to perf record -j v3 Andi Kleen
2013-01-31 17:19 ` Basic perf PMU support for Haswell v1 Stephane Eranian
2013-01-31 17:47 ` 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=20130128231659.GW30577@one.firstfloor.org \
--to=andi@firstfloor.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.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