* attr inherit vs inherit_stat
@ 2012-08-07 19:47 Vince Weaver
2012-09-04 6:55 ` Namhyung Kim
0 siblings, 1 reply; 5+ messages in thread
From: Vince Weaver @ 2012-08-07 19:47 UTC (permalink / raw)
To: linux-perf-users
Hello
I'm trying to figure out the difference between the "inherit" and
"inherit_stat" bitfields in the perf_event_attr structure.
Both seem to have similar functionality, and the code in core.c
is hard to follow.
Does anyone have any idea?
Thanks,
Vince
vweaver1@eecs.utk.edu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: attr inherit vs inherit_stat
2012-08-07 19:47 attr inherit vs inherit_stat Vince Weaver
@ 2012-09-04 6:55 ` Namhyung Kim
2012-09-06 15:19 ` Vince Weaver
0 siblings, 1 reply; 5+ messages in thread
From: Namhyung Kim @ 2012-09-04 6:55 UTC (permalink / raw)
To: Vince Weaver; +Cc: linux-perf-users
On Tue, 7 Aug 2012 15:47:32 -0400, Vince Weaver wrote:
> Hello
Hello Vince,
>
> I'm trying to figure out the difference between the "inherit" and
> "inherit_stat" bitfields in the perf_event_attr structure.
>
> Both seem to have similar functionality, and the code in core.c
> is hard to follow.
>
> Does anyone have any idea?
AFAIK the "inherit" field determines whether the event is inherited to a
child process/thread. The "inherit_stat" is only meaningful when the
"inherit" field is also set and it'll preserve (saved) event counts
between context switch of the inherited processes/threads.
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: attr inherit vs inherit_stat
2012-09-04 6:55 ` Namhyung Kim
@ 2012-09-06 15:19 ` Vince Weaver
2012-09-07 1:20 ` Namhyung Kim
0 siblings, 1 reply; 5+ messages in thread
From: Vince Weaver @ 2012-09-06 15:19 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-perf-users
On Tue, 4 Sep 2012, Namhyung Kim wrote:
>
> AFAIK the "inherit" field determines whether the event is inherited to a
> child process/thread. The "inherit_stat" is only meaningful when the
> "inherit" field is also set and it'll preserve (saved) event counts
> between context switch of the inherited processes/threads.
Thank you for taking the time to answer!
I'm still trying to construct a test case that shows the difference but
I'm failing.
Aren't the stats *always* saved on context switch?
Does this affect what happens when you read the perf_event fd in the
inherited threads, or only from the master thread?
What is the expected behavior if you set inherit_thread but do not set
inherit?
Thanks for any clarifications you can provide,
Vince
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: attr inherit vs inherit_stat
2012-09-06 15:19 ` Vince Weaver
@ 2012-09-07 1:20 ` Namhyung Kim
2012-09-07 15:31 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Namhyung Kim @ 2012-09-07 1:20 UTC (permalink / raw)
To: Vince Weaver; +Cc: linux-perf-users, Peter Zijlstra
(Adding peterz in case he has a time to answer)
On Thu, 6 Sep 2012 11:19:21 -0400, Vince Weaver wrote:
> On Tue, 4 Sep 2012, Namhyung Kim wrote:
>>
>> AFAIK the "inherit" field determines whether the event is inherited to a
>> child process/thread. The "inherit_stat" is only meaningful when the
>> "inherit" field is also set and it'll preserve (saved) event counts
>> between context switch of the inherited processes/threads.
>
> Thank you for taking the time to answer!
>
> I'm still trying to construct a test case that shows the difference but
> I'm failing.
Please note that my understanding of perf core code is not firm enough
so there might be some mistakes. ;-)
>
> Aren't the stats *always* saved on context switch?
If both of them are cloned from the same parent event context and
there's no event added in the meantime.
Please see perf_event_context_sched_out() calling perf_event_sync_stat.
>
> Does this affect what happens when you read the perf_event fd in the
> inherited threads, or only from the master thread?
It might. But I guess the master thread doesn't get affected from that.
>
> What is the expected behavior if you set inherit_thread but do not set
> inherit?
You meant inherit_stat, right? If so, it looks it'd be a nop since
there's no inherited events. Maybe the perf tools can be changed to
warn about that.
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: attr inherit vs inherit_stat
2012-09-07 1:20 ` Namhyung Kim
@ 2012-09-07 15:31 ` Peter Zijlstra
0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2012-09-07 15:31 UTC (permalink / raw)
To: Namhyung Kim; +Cc: Vince Weaver, linux-perf-users
On Fri, 2012-09-07 at 10:20 +0900, Namhyung Kim wrote:
> (Adding peterz in case he has a time to answer)
>
> On Thu, 6 Sep 2012 11:19:21 -0400, Vince Weaver wrote:
> > On Tue, 4 Sep 2012, Namhyung Kim wrote:
> >>
> >> AFAIK the "inherit" field determines whether the event is inherited to a
> >> child process/thread. The "inherit_stat" is only meaningful when the
> >> "inherit" field is also set and it'll preserve (saved) event counts
> >> between context switch of the inherited processes/threads.
> >
> > Thank you for taking the time to answer!
> >
> > I'm still trying to construct a test case that shows the difference but
> > I'm failing.
inherit && inherit_stat preserves the counts per-task and issues a
PERF_RECORD_READ when a task dies. This allows a per-task stat on an
inherited process hierarchy.
> > Aren't the stats *always* saved on context switch?
No, they're normally swizzled around, the only thing we care about is
the total event count for the entire task-set, not the count of the
individual tasks.
> > Does this affect what happens when you read the perf_event fd in the
> > inherited threads, or only from the master thread?
read() on an inherited event gives the total count of the entire
hierarchy.
> > What is the expected behavior if you set inherit_thread but do not set
> > inherit?
>
> You meant inherit_stat, right? If so, it looks it'd be a nop since
> there's no inherited events. Maybe the perf tools can be changed to
> warn about that.
Right that would be a pointless configuration.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-07 15:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-07 19:47 attr inherit vs inherit_stat Vince Weaver
2012-09-04 6:55 ` Namhyung Kim
2012-09-06 15:19 ` Vince Weaver
2012-09-07 1:20 ` Namhyung Kim
2012-09-07 15:31 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).