This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: incorrect perf counters


On 07/25/2016 12:15 PM, riya khanna wrote:
> Hi,
> 
> I'm trying to collect perf counters using systemtap. I followed
> systemtap/EXAMPLES/profiling/perf.stp to create a script to monitor a
> user process, enable counters on function entry, and spew out counters
> on function return. Please find the script (perf.stp) attached.
> 
> I use the stap script described above to monitor function func()'s
> entry and exit.
> 
> void func(void)
> {
>     printf("Measuring instruction count for this printf\n");
> }
> 
> Just to verify systemtap reported counters, I created a program
> (test.c) that uses perf_event_open() syscall to monitor func()'s
> entry/exit and spew out counters. Please find it attached as well.
> 
> However, the counters reported by perf.stp are very different from
> what is reported by test.c. For example, instruction count reported by
> test.c and perf.stp are 593 and 10610-10690.
> 
> This is how I launch perf.stp to monitor func() in test.c:
> 
> sudo /usr/local/bin/stap -s1 perf.stp test func
> 
> Why such a difference? Am I missing something?

I suspect it's because your calls set exclude_kernel and exclude_hv, and
systemtap doesn't do this.

Perhaps we should do this for the .process variant, or at least make it
an option to count only userspace.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]