Hi Stephane,

Thank you for your reply. I understand that I can pass the inherit flag to 
perf_event_open() on my own. However, it can only apply to the child threads 
created after the perf_event_open() syscall, and does not apply to the existing 
child threads. For example, if process 1234 creates 4 child threads at time t0 
and we setup the perf events at time t1 using PID 1234, even with the inherit 
flag we won’t be able to count the events happened on the 4 existing child 
threads.

My question is:

1) whether there is a way that I can count the existing child threads as well?
2) how does perf stat implement this (I found perf stat -p actually counts for 
the existing child threads)?

Thank you!

Yunqi
> On Apr 27, 2015, at 5:11 PM, Stephane Eranian <eran...@googlemail.com> wrote:
> 
> 
> Hi,
> 
> On Fri, Apr 24, 2015 at 9:33 PM, Yunqi Zhang <zhangyunqi...@gmail.com 
> <mailto:zhangyunqi...@gmail.com>> wrote:
> Hi all,
> 
> I'm trying to use libpfm to collect performance counter data for some 
> multi-threaded applications. I would like to aggregate the data for all the 
> child threads under the same process. I found that the "inherit" flag does 
> not work for existing children threads as suggested by perf_event_open 
> <http://man7.org/linux/man-pages/man2/perf_event_open.2.html>.
>        inherit
>               The inherit bit specifies that this counter should count
>               events of child tasks as well as the task specified.  This
>               applies only to new children, not to any existing children at
>               the time the counter is created (nor to any new children of
>               existing children).
> However, it seems to me that the tool perf stat 
> <https://perf.wiki.kernel.org/index.php/Main_Page> that comes with Linux 
> kernel works just fine in this case, which aggregates the counter data for 
> all the child threads even when they already exist.
> 
> I was wondering how I can use libpfm to achieve the same purpose, or how perf 
> stat implements this functionality.
> 
> libpfm4 does not make the perf_event_open() syscall for you. This is still 
> under the control
> of your app. Therefore, you can set the perf_event_attr->inherit flag in the 
> struct after you've called
> libpfm4 and before you call perf_event_open().
> 
> You can look at perf_examples/task.c for an example.
>  
> Thank you!
> 
> Yunqi
> 
> 
> 
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y 
> <http://ad.doubleclick.net/ddm/clk/290420510;117567292;y>
> _______________________________________________
> perfmon2-devel mailing list
> perfmon2-devel@lists.sourceforge.net 
> <mailto:perfmon2-devel@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/perfmon2-devel 
> <https://lists.sourceforge.net/lists/listinfo/perfmon2-devel>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
perfmon2-devel mailing list
perfmon2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perfmon2-devel

Reply via email to