'perf mem doesn't records mem load on heap
I used perf mem on my test C program, because I want to get how many times the mem load(and store) on the same pages.
a. My C program is here:
"stest.c"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
const int TESTSIZE = 1024*10;
int main(){
int* ptr_obj = (int*)malloc(sizeof(int)*TESTSIZE);
int count = 0;
while(count < 1000){
for (int i=0; i< TESTSIZE; i++) {
ptr_obj[i] = 12;
}
for (int i=1; i < TESTSIZE-1; i++) {
ptr_obj[i] = ptr_obj[i-1] + ptr_obj[i+1] - ptr_obj[i] + 1;
}
count ++;
sleep(1);
}
return 0;
}
b. Then I build it with this command:
gcc -O0 -o stest stest.c
c. Next recorded by perf mem in using this command:
perf mem record ./stest
I broke the process by CTRL + C after about 5 seconds.
d. I used this command to get the report:
perf mem report --stdio -d stest
here is the output.(only mem load)
# To display the perf.data header info, please use --header/--header-only options.
#
# dso: stest
#
# Total Lost Samples: 0
#
# Samples: 94 of event 'cpu/mem-loads,ldlat=30/P'
# Total weight : 5792
# Sort order : local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked
#
# Overhead Samples Local Weight Memory access Symbol Data Symbol Data Object Snoop TLB access Locked
# ........ ............ ............ ........................ ........ ...................... ........... ............ ...................... ......
#
6.22% 8 45 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
5.92% 7 49 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
5.28% 6 51 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
4.87% 6 47 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
4.45% 6 43 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
3.97% 5 46 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
3.45% 4 50 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
2.75% 3 53 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
2.69% 3 52 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
2.49% 3 48 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
2.21% 4 32 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
2.07% 3 40 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.93% 2 56 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.90% 2 55 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.86% 2 54 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.81% 3 35 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.76% 3 34 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.71% 3 33 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.52% 2 44 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.45% 2 42 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.42% 2 41 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.35% 2 39 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
1.00% 1 58 LFB or LFB hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
0.66% 1 38 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
0.64% 1 37 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
0.62% 1 36 L1 or L1 hit [.] main [.] 0x00007ffd193dbd50 [stack] None L1 or L2 hit No
Obviously, no heap record here.
My question is
a. why no heap record?
b. how to get the record.
c. or maybe my test C program has something wrong
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
