From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Stephane Eranian <eranian@google.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
ming.m.lin@intel.com, peterz@infradead.org
Subject: Re: [rfc 1/3] perf, x86: P4 PMU - describe config format
Date: Fri, 26 Nov 2010 23:11:43 +0300 [thread overview]
Message-ID: <20101126201143.GC5620@lenovo> (raw)
In-Reply-To: <AANLkTi=3BqbTkn90s_fhs0v0tp04SCKTHR2XO1qrrjkW@mail.gmail.com>
On Fri, Nov 26, 2010 at 07:05:17PM +0100, Stephane Eranian wrote:
...
> >
> > Stephane, could you do a test? We need a pinned event which would be
> > running on say cpu0 only and if you set P4_CCCR_THREAD_SINGLE in CCCR
> > and event would be still incrementing -- this mean my theory is correct
> > and this "thread" field means "when" to count, if not -- you're right
> > and "thread" field means "where" instead.
> >
>
> I think we both agree that active_threads determines when to count
> in your thread based on what is going on in the other thread. It does
> not allow you to directly count the activity in the other thread (unlike
> .any).
Stephane, perhaps I simply didn't understand you right in previous mails.
Yes, AT (active thread) specify "when" to count depending on logical
cpu activity.
>
> Imagine you measure function foo() at 10k instr retired when running
> with HT off. You run the same function with HT on and set the mode to
> 10 (only when both). If you get a lower count, it means there was
> nothing going on on the other thread. If you get the same, then it
> means the other thread was busy all along. If you set it to 01 instead
> and get the same count, then you know the other thread was idle all
> along.
Lets do some general overview first so you might check me ;)
The perf MSRs are shared across threads in core. And events may be either
Thread Independent [TI] (ie there is no way to qualify event affinity to
logical cpu, for example FSB bus activity events) and Thread Specific [TS]
(for example retirement of instructions which could be treated as associated
with specific logical cpu).
For TI events we require CAP_SYS_ADMIN and perf "paranoid" level to be
granted because this might be security issue (though at moment I can't
imagine how it's possible to abuse "FSB bus activity", but say for
"trace cache deliver mode" event you can specify /via ESCR mask/ to count
event when second logical cpu is in "build mode", not sure if it is
somehow being abused either).
So logical cpu filtering is achieved via ESCR Tx bits, and when event
is scheduled-in to run on specific thread, we simply set proper Tx bits
on kernel level, the RAW events have no control over them.
While with "TS events" the events are filtered according to on which cpu they
are happened I think there is no such way for TI events, and if event
say happened on cpu 1 but measured on cpu 0 and ESCR has T0_ bits set --
you'll observe events from another cpu (but, hey, we require the user
to have special rights to count such events, ie CAP_SYS_ADMIN and perf
"paranoid").
For instr-retired example, we need to take into account that this
is a TS event and we set ESCR Tx's bits according to cpu on which we
executing, and when event "happens" on different cpu the Tx filer simply
drop such occurence. But what happens if we set "Active Thread" to 'single'
on such event -- it will be counted _only_ when cpu is running alone and
second cpu is in indle state.
>
> The question is: does this present a security issue? Can you infer
> something about what is going on in the other thread. It is clear
> you can figure out when it did run or not. Is that any different
> than running top? I suspect not, so I think what you have is
> probably okay.
>
At moment I can't imagine any issue here.
Cyrill
next prev parent reply other threads:[~2010-11-26 20:11 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-23 22:46 [rfc 0/3] perf,x86: p4 pmu series Cyrill Gorcunov
2010-11-23 22:46 ` [rfc 1/3] perf, x86: P4 PMU - describe config format Cyrill Gorcunov
2010-11-26 10:57 ` Stephane Eranian
2010-11-26 11:14 ` Cyrill Gorcunov
2010-11-26 11:32 ` Cyrill Gorcunov
2010-11-26 11:35 ` Stephane Eranian
2010-11-26 11:58 ` Cyrill Gorcunov
2010-11-26 12:46 ` Stephane Eranian
2010-11-26 13:04 ` Cyrill Gorcunov
2010-11-26 13:06 ` Peter Zijlstra
2010-11-26 13:47 ` Cyrill Gorcunov
2010-11-26 13:10 ` Stephane Eranian
2010-11-26 13:50 ` Cyrill Gorcunov
2010-11-26 13:54 ` Stephane Eranian
2010-11-26 15:27 ` Cyrill Gorcunov
2010-11-26 16:22 ` Stephane Eranian
2010-11-26 17:16 ` Cyrill Gorcunov
2010-11-26 18:05 ` Stephane Eranian
2010-11-26 20:11 ` Cyrill Gorcunov [this message]
2010-11-26 12:48 ` Stephane Eranian
2010-11-26 12:59 ` Peter Zijlstra
2010-11-26 13:07 ` Stephane Eranian
2010-11-26 13:07 ` Cyrill Gorcunov
2010-11-23 22:46 ` [rfc 2/3] perf, x86: P4 PMU - Fix unflagged overflows handling v4 Cyrill Gorcunov
2010-11-23 22:46 ` [rfc 3/3] perf, x86: P4 PMU -- export ABI part of event config to userspace Cyrill Gorcunov
2010-11-24 8:32 ` Peter Zijlstra
2010-11-24 8:48 ` Cyrill Gorcunov
2010-11-24 9:02 ` Peter Zijlstra
2010-11-24 9:39 ` Cyrill Gorcunov
2010-11-24 11:46 ` Cyrill Gorcunov
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=20101126201143.GC5620@lenovo \
--to=gorcunov@gmail.com \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.m.lin@intel.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.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