All of lore.kernel.org
 help / color / mirror / Atom feed
* perf: is PERF_COUNT_SW_CONTEXT_SWITCHES a kernel or user event?
@ 2011-06-24 21:03 Vince Weaver
  2011-06-27 10:43 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Vince Weaver @ 2011-06-24 21:03 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Stephane Eranian, Frederic Weisbecker

Hello

the commit included in 2.6.34:
  perf: Use hot regs with software sched switch/migrate events
  e49a5bd38159dfb1928fd25b173bc9de4bbadb21

Changes the behavior of the PERF_COUNT_SW_CONTEXT_SWITCHES
counter.

Before 2.6.34 all of the PERF_COUNT_SW_CONTEXT_SWITCHES events were 
counted as happening in userspace (they show up in "perf stat -e cs:u") 
but after the commit they always happen in kernelspace ("perf stat -e 
cs:k").

Was this intended behavior?
I'm writing a validation test for this and want to make sure I get it
right.

This can be confusing if your tool defaults to userspace only counts (PAPI 
does this).

Thanks,

Vince

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: perf: is PERF_COUNT_SW_CONTEXT_SWITCHES a kernel or user event?
  2011-06-24 21:03 perf: is PERF_COUNT_SW_CONTEXT_SWITCHES a kernel or user event? Vince Weaver
@ 2011-06-27 10:43 ` Peter Zijlstra
  2011-06-27 18:59   ` Frederic Weisbecker
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2011-06-27 10:43 UTC (permalink / raw)
  To: Vince Weaver
  Cc: linux-kernel, Ingo Molnar, Stephane Eranian, Frederic Weisbecker

On Fri, 2011-06-24 at 17:03 -0400, Vince Weaver wrote:
> Hello
> 
> the commit included in 2.6.34:
>   perf: Use hot regs with software sched switch/migrate events
>   e49a5bd38159dfb1928fd25b173bc9de4bbadb21
> 
> Changes the behavior of the PERF_COUNT_SW_CONTEXT_SWITCHES
> counter.
> 
> Before 2.6.34 all of the PERF_COUNT_SW_CONTEXT_SWITCHES events were 
> counted as happening in userspace (they show up in "perf stat -e cs:u") 
> but after the commit they always happen in kernelspace ("perf stat -e 
> cs:k").
> 
> Was this intended behavior?
> I'm writing a validation test for this and want to make sure I get it
> right.
> 
> This can be confusing if your tool defaults to userspace only counts (PAPI 
> does this).

hurm, difficult case, like the changelog explains the previous behaviour
wasn't ideal either. Seems like we want somewhat of a middle ground
there, but I'm not quite sure how to make that happen.

Let me ponder things for a bit.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: perf: is PERF_COUNT_SW_CONTEXT_SWITCHES a kernel or user event?
  2011-06-27 10:43 ` Peter Zijlstra
@ 2011-06-27 18:59   ` Frederic Weisbecker
  2011-06-28 17:30     ` Vince Weaver
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Weisbecker @ 2011-06-27 18:59 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Vince Weaver, linux-kernel, Ingo Molnar, Stephane Eranian

On Mon, Jun 27, 2011 at 12:43:23PM +0200, Peter Zijlstra wrote:
> On Fri, 2011-06-24 at 17:03 -0400, Vince Weaver wrote:
> > Hello
> > 
> > the commit included in 2.6.34:
> >   perf: Use hot regs with software sched switch/migrate events
> >   e49a5bd38159dfb1928fd25b173bc9de4bbadb21
> > 
> > Changes the behavior of the PERF_COUNT_SW_CONTEXT_SWITCHES
> > counter.
> > 
> > Before 2.6.34 all of the PERF_COUNT_SW_CONTEXT_SWITCHES events were 
> > counted as happening in userspace (they show up in "perf stat -e cs:u") 
> > but after the commit they always happen in kernelspace ("perf stat -e 
> > cs:k").
> > 
> > Was this intended behavior?
> > I'm writing a validation test for this and want to make sure I get it
> > right.
> > 
> > This can be confusing if your tool defaults to userspace only counts (PAPI 
> > does this).
> 
> hurm, difficult case, like the changelog explains the previous behaviour
> wasn't ideal either. Seems like we want somewhat of a middle ground
> there, but I'm not quite sure how to make that happen.
> 
> Let me ponder things for a bit.

If you consider the strict meaning of exclude_user/exclude_kernel, they exclude
events that _happen_ in user/kernel space. And context switches happen in kernel
space.

Using the resuming ip in userspace if exclude_kernel and the current kernel
ip if exclude_user or default no exclude is a pure arbitrary interpretation of the
exclude things. We could, but I believe it only makes the things confusing for people.

If some users want an option where the event can trigger everywhere but hists are
sorted by the resuming userspace ip, let's tweak the "perf report -s parent" thing
to take the resuming userspace ip from the callchain as the parent and you get
the desired result.

This will have the advantage to keep exclude_* behaviour consistent everywhere and
if we want to have that user resuming ip feature, it will be available for any kind of
events.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: perf: is PERF_COUNT_SW_CONTEXT_SWITCHES a kernel or user event?
  2011-06-27 18:59   ` Frederic Weisbecker
@ 2011-06-28 17:30     ` Vince Weaver
  0 siblings, 0 replies; 4+ messages in thread
From: Vince Weaver @ 2011-06-28 17:30 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Peter Zijlstra, linux-kernel, Ingo Molnar, Stephane Eranian

On Mon, 27 Jun 2011, Frederic Weisbecker wrote:
> 
> If you consider the strict meaning of exclude_user/exclude_kernel, they exclude
> events that _happen_ in user/kernel space. And context switches happen in kernel
> space.

I can see that it's somewhat arbitrary how context switches are 
classified.

I just want some assurances that now that it's moved to being
a kernel event it stays that way.

As it is, people upgrading from 2.6.32 to 2.6.34 and using the "cs:u"
event will suddently start getting "0" results.  

Possibly perf_events should just ignore exclude_kernel/exclude_user on an 
event like this where there is no real distinction.

Vince
vweaver1@eecs.utk.edu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-28 17:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-24 21:03 perf: is PERF_COUNT_SW_CONTEXT_SWITCHES a kernel or user event? Vince Weaver
2011-06-27 10:43 ` Peter Zijlstra
2011-06-27 18:59   ` Frederic Weisbecker
2011-06-28 17:30     ` Vince Weaver

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.