Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

perf_event_open: Including the execution of child process in case of sampling

According to man pages to consider the execution of child process when counting for events, inherit bit can be set. inherit can not be used when using PERF_FORMAT_GROUP. So, how can I include the execution of child process (execution of shell commands with in C source code, for example) so that it can be counted when sampling (PERF_FORMAT_GROUP) using perf_event_open

if PERF_FORMAT_GROUP is not specified, does this indicate that for each recorded sample, each sample record will include struct read_format equal to the number of events or a sample will be recorded for each event alone.

like image 674
user3527764 Avatar asked Oct 17 '25 16:10

user3527764


1 Answers

If you need to use PERF_FORMAT_GROUP, and that doesn't work with the built-in inherit, then you have to keep track of the children yourself. You can do that by using ptrace and then setup perf_event_open for all child tasks. Then you also have to merge the samples from all event file descriptors.

Edit: Without PERF_FORMAT_GROUP, the internal sampling recording is not at the same time. You could of course just setup counting events (instead of a sampling events), and read them at the same time in regular intervals from userspace.

like image 129
Zulan Avatar answered Oct 20 '25 15:10

Zulan