#165 opreport --xml total event count mismatch

closed-fixed
None
5
2009-07-31
2008-06-02
Tommi Rantala
No

Profiling with the --separate flag, opreport XML output can give incorrect total count.

To reproduce:

1) Put this to ''/tmp/test.c'' and compile with ''gcc test.c -o test'':
#include <stdlib.h>
int main() { unsigned i; for (i=0; i < 30000000; ++i) free(malloc(2048)); return 0; }

2) Do some profiling:
$ opcontrol --separate=library --no-vmlinux --setup --event=CPU_CLK_UNHALTED:100000 --start --image=/tmp/test
$ /tmp/test
$ opcontrol --shutdown

3) opreport output:
CPU: Core 2, speed 1600 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (Unhalted core cycles) count 100000
CPU_CLK_UNHALT...|
samples| %|
------------------
49275 100.000 test
CPU_CLK_UNHALT...|
samples| %|
------------------
46516 94.4008 libc-2.7.so
2757 5.5951 test
2 0.0041 ld-2.7.so

4) opreport --xml output snippet, the total count is different from the output given in the ASCII report above:
[...]
<setup>
<eventsetup id="0" eventname="CPU_CLK_UNHALTED" unitmask="0" setupcount="100000"/>
</setup>

<binary name="/tmp/test">
<count>
142307</count>
[...]

5) I noticed that commenting out line 640 in libpp/xml_utils.cpp seems to fix the problem. The branch ''m > 0'' is executed repeatedly, and some values are added over and over again to the total count giving the large value in the XML output.

void binary_info::
add_module_symbol(string const & module, string const & app,
· sym_iterator it)
{
· size_t m = nr_modules;

· if (module == app) {
· · // set begin symbol for binary if not set
· · set_begin(it);

· · if (m > 0) {
· · · // close out current module
· · · module_info & mod = my_modules[m-1];
· · · mod.set_end(it);
· · · //add_to_summary(mod.get_summary()); // remove this
· · }

· · // no module, so add symbol count to binary count
· · add_to_summary((*it)->sample.counts);
· · return;
· }

Discussion

    • assigned_to: nobody --> maynardj
     
  • I posted a patch to the oprofile-list on March 10 to address this problem -- subject line:
    "[PATCH] Fix for 'make distcheck' failure: Make map_event_to_counter handle a non-native cpu_type"

    ttrantal, can you please test it? Thanks.

     
  • ttrantal,
    Sorry, my previous comment in this but was misplaced; that comment was meant for another bug tracker. The correct information is that I posted a patch to the oprofile-list on March 23 to address this xml output bug. The posting has a subject line of "[PATCH] Fix binary count total in XML output when using --separate=lib". Could you please test the patch and give feedback on whether it fixes this bug? Thanks.

     
    • status: open --> open-fixed
     
  • The patch I posted on March 23 has been reviewed and committed to CVS. The bug submitter should test this fix, but my pleas to do so have gone unanswered. I'm changing the Resolution to "Fixed" until I find out otherwise.

     
    • status: open-fixed --> closed-fixed