imx6Q 4.1.15 Perf support

Perf是Linux kernel自带的系统性能优化工具。Perf的优势在于与Linux Kernel的紧密结合,它可以最先应用到加入Kernel的new feature。pef可以用于查看热点函数,查看cashe miss的比率,从而帮助开发者来优化程序性能。

编译器:gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz

Linux Kernel: imx6Q 4.1.15

1)补丁

Makefile.perf添加WERROR=0支持

2)编译
make LDFLAGS=-static ARCH=arm CROSS_COMPILE=/home/jiujin/workbench/toolchain/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- DEBUG=1

  CC       tests/hists_cumulate.o
  CC       tests/python-use.o
  CC       tests/bp_signal.o
  CC       tests/bp_signal_overflow.o
  CC       tests/task-exit.o
  CC       tests/sw-clock.o
  CC       tests/mmap-thread-lookup.o
  CC       tests/thread-mg-share.o
  CC       tests/switch-tracking.o
  CC       tests/keep-tracking.o
  CC       tests/code-reading.o
  CC       tests/sample-parsing.o
  CC       tests/parse-no-sample-id-all.o
  CC       tests/kmod-path.o
  LD       tests/perf-in.o
  CC       perf.o
  LD       perf-in.o
  LINK     perf
/work/aosp/kernel_imx/tools/lib/traceevent/libtraceevent.a(libtraceevent-in.o): In function `load_plugin':
/work/aosp/kernel_imx/tools/lib/traceevent/event-plugin.c:304: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libperf.a(libperf-in.o): In function `target__parse_uid':
/work/aosp/kernel_imx/tools/perf/util/target.c:79: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/work/aosp/kernel_imx/tools/perf/util/target.c:91: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
  GEN      perf-archive
  GEN      perf-with-kcore


3)
sabresd_6dq:/data # ./perf top                                                 
Cannot read kernel map
Segmentation fault

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

4)
sabresd_6dq:/data # ./perf top                                                 
[mac80211] with build id f31d71174e3e0ac590852c07a0a1e9c79f219752 not found, continuing without symbols

   PerfTop:    1563 irqs/sec  kernel:93.7%  exact:  0.0% [4000Hz cycles],  (all, 2 CPUs)
-------------------------------------------------------------------------------

    40.77%  [kernel]            [k] cpuidle_enter_state        
     8.96%  [kernel]            [k] radix_tree_lookup          
     7.83%  [kernel]            [k] __do_softirq               
     7.78%  [kernel]            [k] _raw_spin_unlock_irqrestore
     7.55%  [kernel]            [k] _raw_spin_unlock_irq       
     2.56%  [kernel]            [k] preempt_count_add          
     2.56%  [kernel]            [k] __timer_delay              
     1.28%  [kernel]            [k] put_cpu_partial            
     1.28%  [kernel]            [k] irq_to_desc                
     1.28%  [kernel]            [k] rcu_process_callbacks      
     1.28%  [kernel]            [k] file_free_rcu              
     1.28%  libc.so             [.] 0x000489f0                 
     1.28%  [kernel]            [k] tick_nohz_idle_enter       
     1.28%  [kernel]            [k] __netif_receive_skb        
     1.27%  [kernel]            [k] avc_lookup                 
     1.25%  boot.oat            [.] 0x00591f04                 
     1.25%  libc.so             [.] 0x00017592                 
     1.25%  [kernel]            [k] mix_pool_bytes