From: Peter Zijlstra <peterz@infradead.org>
To: Vince Weaver <vincent.weaver@maine.edu>,
'@hirez.programming.kicks-ass.net
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: Re: perf: rdpmc bug when viewing all procs on remote cpu
Date: Fri, 18 Jan 2019 21:10:51 +0100 [thread overview]
Message-ID: <20190118201051.GF27931@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <alpine.DEB.2.21.1901181217180.5762@macbook-air>
On Fri, Jan 18, 2019 at 12:24:20PM -0500, Vince Weaver wrote:
> On Fri, 18 Jan 2019, Peter Zijlstra wrote:
> >
> > You can actually use rdpmc when you attach to a CPU, but you have to
> > ensure that the userspace component is guaranteed to run on that very
> > CPU (sched_setaffinity(2) comes to mind).
>
> unfortunately the HPC people using PAPI would probably be annoyed if we
> started binding their threads to cores out from under them.
Quite.. :-)
> > The best we could possibly do is put the (target, not current) cpu
> > number in the mmap page; but userspace should already know this, for it
> > created the event and therefore knows this already.
>
> one other thing the kernel would do is just disable rdpmc (setting index
> to 0) in the case where the original perf_event_open() cpu paramater!=0
>
> though that would stop the case where we were on the same CPU from
> working.
Indeed.
> The issue is currently if you're not careful the rdpmc() interface will
> sometimes return plausible (but wrong) results for a cross-CPU rdpmc()
> call, even if you are properly falling back to read() on ->index being 0.
> It's a bit surprising and it looks like it will take a decent amount of
> userspace code to work around the issue, which cuts into the low-overhead
> nature of rdpmc.
>
> If the answer is simply this is the way the kernel is going to do it,
> that's fine, I just have to add workarounds to PAPI and then get the
> perf_even_open() manpage updated to make sure people are aware of the
> issue.
I'm not sure there really is anything the kernel can do to help here...
One thing you could look at is using rseq together with adding a CPU
number to the userspace descriptor, and if rseq gives you a matching CPU
number use rdpmc, otherwise, or on rseq abort, use read().
prev parent reply other threads:[~2019-01-18 20:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 17:35 perf: rdpmc bug when viewing all procs on remote cpu Vince Weaver
2019-01-10 17:50 ` Vince Weaver
2019-01-10 20:00 ` Vince Weaver
2019-01-11 21:52 ` Vince Weaver
2019-01-18 12:01 ` Peter Zijlstra
2019-01-18 14:09 ` Vince Weaver
2019-01-18 15:58 ` Peter Zijlstra
2019-01-18 17:24 ` Vince Weaver
2019-01-18 20:10 ` Peter Zijlstra [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=20190118201051.GF27931@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc='@hirez.programming.kicks-ass.net \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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