public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Stephane Eranian <eranian@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"mingo@elte.hu" <mingo@elte.hu>, Jiri Olsa <jolsa@redhat.com>,
	vincent.weaver@maine.edu,
	"ak@linux.intel.com" <ak@linux.intel.com>
Subject: Re: [PATCH] perf,x86: Fix shared registers mutual exclusion bug
Date: Thu, 20 Jun 2013 14:07:43 +0200	[thread overview]
Message-ID: <20130620120743.GA15789@gmail.com> (raw)
In-Reply-To: <CABPqkBTtnX3KNyVXzXwL82EADhs14v-LCuoxLgGnXPTP_FaSFQ@mail.gmail.com>


* Stephane Eranian <eranian@google.com> wrote:

> On Tue, Jun 18, 2013 at 11:11 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Wed, Jun 05, 2013 at 04:43:46PM +0200, Stephane Eranian wrote:
> >>
> >> This patch fixes a problem with the shared registers mutual
> >> exclusion code and incremental event scheduling by the
> >> generic perf_event code.
> >>
> >> There was a bug whereby the mutual exclusion on the shared
> >> registers was not enforced because of incremental scheduling
> >> abort due to event constraints.
> >>
> >> Example on Nehalem:
> >> group1= ref-cycles,OFFCORE_RESPONSE_0:PF_RFO
> >> group2= ref-cycles
> >>
> >> The ref-cycles event can only be measured by 1 counter. Yet, there
> >> are 2 instances here. The first group can be scheduled and is committed.
> >> Then, the generic code tries to schedule group2 and this fails (because
> >> there is no more counter to support the 2nd instance of ref-cycles).
> >>
> >> But in x86_schedule_events() error path, put_event_contraints() is invoked
> >> on ALL the events and not just the ones that just failed. That causes the
> >> "lock" on the shared offcore_response MSR to be released. Yet the first group
> >> is actually scheduled and is exposed to reprogramming of that shared msr by
> >> the sibling HT thread (when they are shared by HT threads). In other words,
> >> there is no guarantee on what is measured for the offcore_response event.
> >>
> >> This patch fixes the problem by tagging committed events with the
> >> PERF_X86_EVENT_COMMITTED tag. In the error path of x86_schedule_events(),
> >> only the events NOT tagged have their constraint released. The tag
> >> is eventually removed when the event in descheduled.
> >>
> >> Example was given with offcore_response but also applies to LBR_SELECT
> >> and LDLAT shared registers.
> >>
> >> Signed-off-by: Stephane Eranian <eranian@google.com>
> >
> > I'm getting conflicts against other patches -- most notably I think the
> > contraints stack opt from Andrew Hunter.
> >
> Yes, that would not surprise me. I wrote this patch without assuming
> Andrew's patch would be there. But we need to add it. Then we can fix
> the shared_regs patch.
> 
> > I'll try and get Ingo to finally pick up my queued patches so we can
> > rebase.
> 
> Ok, thanks.

That happened yesterday, so latest -tip should be a good base to work on.

Thanks,

	Ingo

      reply	other threads:[~2013-06-20 12:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-05 14:43 [PATCH] perf,x86: Fix shared registers mutual exclusion bug Stephane Eranian
2013-06-18  9:11 ` Peter Zijlstra
2013-06-18 18:43   ` Stephane Eranian
2013-06-20 12:07     ` Ingo Molnar [this message]

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=20130620120743.GA15789@gmail.com \
    --to=mingo@kernel.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=peterz@infradead.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox