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 01:55 PM, riya khanna wrote:
> Thanks!
> 
> Is there a quick way to do that? Perhaps modify tapset? I make
> necessary changes and test.

For a quick hack to see if it gets values you like, you could tweak
stp->attr in runtime/linux/perf.c, just before the calls to
perf_event_create_kernel_counter().  You don't need to recompile
systemtap for this, as runtime code is freshly compiled into the module
generated for your script.

A more permanent solution would affect how the .attr is written in
tapset-perfmon.cxx, perf_derived_probe_group::emit_module_decls().

> On Mon, Jul 25, 2016 at 3:45 PM, Josh Stone <jistone@redhat.com> wrote:
>> 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]