lost and found ( for me ? )

How to install perf ( kernel performance monitor ) on Ubuntu , CentOS


[ install perf on Ubuntu 12.04 ]



# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"

# uname -ri
3.2.0-25-generic x86_64

install
# apt-get install linux-tools -y


monitor a chromium-browser process.
fly chromium-browser via perf like this

on GUI , issue the following command
# perf record chromium-browser




nnn, there appears a waning message.. , kernel pointer ??
Kernel address maps (/proc/{kallsyms,modules}) were restricted.                                                                        
Check /proc/sys/kernel/kptr_restrict before running 'perf record'.


to solve this:
# cat /proc/sys/kernel/kptr_restrict
1

# echo 0 > /proc/sys/kernel/kptr_restrict

# cat /proc/sys/kernel/kptr_restrict
0

# cat /proc/kallsyms  | head -10
0000000000000000 D irq_stack_union
0000000000000000 D __per_cpu_start
0000000000004000 D gdt_page
0000000000005000 d exception_stacks
000000000000b000 d tlb_vector_offset
000000000000b080 d cpu_loops_per_jiffy
000000000000b0c0 D xen_vcpu_info
000000000000b100 D xen_vcpu
000000000000b108 d idt_desc
000000000000b118 d xen_cr0_value


try again.
Okay , there are no warning messages.

check the result file
$ perf report
Events: 3K cycles
73.37%  chromium-browse  [unknown]                [.] 0x7f613588d718
 2.80%  chromium-browse  [kernel.kallsyms]        [k] native_write_msr_safe
 1.25%  chromium-browse  [kernel.kallsyms]        [k] page_fault
 1.02%  chromium-browse  libfreebl3.so            [.] 0x27d5e
<snip>

you can specify events you’d like to collect.
# perf list

List of pre-defined events (to be used in -e):
 cpu-cycles OR cycles                               [Hardware event]
 stalled-cycles-frontend OR idle-cycles-frontend    [Hardware event]
 stalled-cycles-backend OR idle-cycles-backend      [Hardware event]
 instructions                                       [Hardware event]
 cache-references                                   [Hardware event]
 cache-misses                                       [Hardware event]
 branch-instructions OR branches                    [Hardware event]
 branch-misses                                      [Hardware event]
 bus-cycles                                         [Hardware event]

 cpu-clock                                          [Software event]
 task-clock                                         [Software event]
 page-faults OR faults                              [Software event]
 minor-faults                                       [Software event]
 major-faults                                       [Software event]
 context-switches OR cs                             [Software event]
 cpu-migrations OR migrations                       [Software event]

$ perf record -e cpu-cycles -e cpu-clock -e context-switches chromium-browser

$ perf report

perf stat
$ perf stat chromium-browser

Performance counter stats for 'chromium-browser':

      2349.438123 task-clock                #    0.211 CPUs utilized          
            6,912 context-switches          #    0.003 M/sec                  
              635 CPU-migrations            #    0.000 M/sec                  
           87,726 page-faults               #    0.037 M/sec                  
    4,824,461,601 cycles                    #    2.053 GHz                     [83.95%]
    2,375,916,048 stalled-cycles-frontend   #   49.25% frontend cycles idle    [82.50%]
    1,467,114,781 stalled-cycles-backend    #   30.41% backend  cycles idle    [67.95%]
    5,208,469,775 instructions              #    1.08  insns per cycle        
                                            #    0.46  stalled cycles per insn [83.95%]
    1,091,803,683 branches                  #  464.708 M/sec                   [82.98%]
       31,296,254 branch-misses             #    2.87% of all branches         [83.44%]

     11.149857740 seconds time elapsed

[ install perf on CentOS6 ]

# cat /etc/centos-release
CentOS release 6.2 (Final)

# uname -ri
2.6.32-220.17.1.el6.x86_64 x86_64

# yum install -y perf

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.