From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
"mingo@elte.hu" <mingo@elte.hu>,
vincent.weaver@maine.edu, Jiri Olsa <jolsa@redhat.com>,
"ak@linux.intel.com" <ak@linux.intel.com>
Subject: Re: [PATCH v2] perf,x86: Fix shared register mutual exclusion enforcement
Date: Mon, 24 Jun 2013 17:48:20 +0200 [thread overview]
Message-ID: <20130624154820.GV28407@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <CABPqkBRpCmDH-TJgAYCDUF4bONuY1mtSiRmRTnbxduWj=+EsEA@mail.gmail.com>
On Mon, Jun 24, 2013 at 10:01:26AM +0200, Stephane Eranian wrote:
> You are missing the error path in schedule_events():
>
> if (!assign || num) {
>
> for (i = 0; i < n; i++) {
> if (x86_pmu.put_event_constraints)
> x86_pmu.put_event_constraints(cpuc,
> cpuc->event_list[i]);
> }
>
> }
>
> That one wipes out on get() even on events that were correctly
> schedule in the previous
> invocation. So here group2 fails, but it should not release the
> constraints from group1.
What I was saying:
schedule(group1)
get_event_constraints() +1
no error path, no puts
schedule(group2)
get_event_constraints() +1
*fail*
put_event_constraints() -1
This leaves the constraints of group1 with a net +1 'ref' count and thus
if we were to treat the get/put as such, the put wouldn't be the last
and thus shouldn't release resources.
> > Only once these events pass through x86_pmu_del() will they get a final
> > put and the 'ref' count will drop to 0.
> >
> > Now the problem seems to be the get/put things don't actually count
> > properly.
> >
> > However, if we look at __intel_shared_reg_{get,put}_constraints() there
> > is a refcount in there; namely era->ref; however we don't appear to
> > clear reg->alloc based on it.
> >
> The era->ref is not used to ref count the number of successful attempts
> at scheduling. It is used to count the number of CPU sharing the resource.
> So it goes from 0, 1, to 2. You can invoke schedule_events() many more
> times. The reg->alloc is a bypass, to avoid checking the shared reg
> again and again if it succeeded once.
Oh right, I knew I was missing something.. :/
> For a while I thought I could leverage the era->ref to account the get/put.
> But it does not work. Because the of the put().
Crud, right you are.
Also, I don't think we could even use them as I outlined; suppose it
would have worked; then we'd have:
schedule(group1)
get_event_constraints() +1
schedule(group2)
get_event_constraints() +1
And we'd be stuck with a ref of 2, the put at x86_pmu_del() would never
be sufficient to drop them back to 0 again.
A well, your patch does indeed make it work so I'll grab that.
next prev parent reply other threads:[~2013-06-24 15:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 16:42 [PATCH v2] perf,x86: Fix shared register mutual exclusion enforcement Stephane Eranian
2013-06-24 7:46 ` Peter Zijlstra
2013-06-24 8:01 ` Stephane Eranian
2013-06-24 15:48 ` Peter Zijlstra [this message]
2013-06-25 9:54 ` Stephane Eranian
2013-06-27 9:01 ` [tip:perf/core] perf/x86: " tip-bot 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=20130624154820.GV28407@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=vincent.weaver@maine.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.