Re: perf_counters issue with enable_on_exec

From: Peter Zijlstra
Date: Mon Aug 24 2009 - 12:07:53 EST

On Mon, 2009-08-24 at 18:03 +0200, stephane eranian wrote:

> >> 2) enable_on_exec on !leader counters is undefined
> >
> > then fail it.

Or make it work :-)

> >> 3) there is something fishy non the less
> >>
> > True.
> >
> >>
> >> 1. you fork() then create a counter group in both the parent and the
> >> child without sync, then read the parent group. This obviously doesn't
> >> do what is expected. See attached proglet for a better version.
> >>
> > I have modified the program based on your changes. See new version attached.
> >
> >> 2. enable_on_exec only works on leaders, Paul, was that intended?
> >>
> > All events in a group are scheduled together. If one event is not enabled
> > in a group, then the group is not dispatched. Setting enable_on_exec
> > just on leader makes sense. Then to enable the group on exec, you
> > enabled all events but the leader. The enable_on_exec will enable
> > the leader on exec and the group will be ready for dispatch. That's
> > how it should work in my mind.
> >
> >
> > As you indicated the issue is with the timing information and I think
> > it is not related to enable_on_exec. It is more related to the fact
> > that to enable a group with a single ioctl() you enable ALL BUT the
> > leader. But that means that the time_enabled for the !leader is
> > ticking. Thus scaling won't be as expected yet it is correct
> > given what happens internally.
> >
> > I think there needs to be a distinction between 'enabled immediately
> > but cannot run because group is not totally enabled' and 'cannot run
> > because the group has been multiplexed out yet all could be dispatched
> > because all events were dispatched'. In the former, it seems you don't
> > want time_enabled to tick, while in the latter you do. In other words,
> > time_enabled ticks for each event if the group is 'dispatch-able' (or
> > runnable in your terminology) otherwise it does not. time_enabled reflects
> > the fact that the group could run but did not have access to the PMU
> > resource because of contention with other groups.
> >
> In other words, I think timing_enabled is measuring the wrong thing.
> It should be instead called time_runnable and it should measure the
> time during which the event is runnable, i.e, its group is runnable. That
> means the event (group) could be dispatched if PMU was "free".

I tend to agree with you, but I'm hoping Paul will speak since he wrote
both the time accounting and the enable_on_exec thing.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at