1.  Latencytop的作用

     首先,Android自带的Latencytop工具和Linux下的Latencytop有点不同。

     · 在Linux中
              Latencytop通过在内核上下文切换的时候,记录被切换的进程的内核栈,然后通过匹配内核栈的函数来判断是什么原因导致上下文切换,同时他把几十种容易引起切换的场景的函数都记录起来,这样在判断系统问题的时候能容易定位到问题。     
     · 在Android中
              Latencytop仅仅记录被切换的进程的内核栈,打印出导致上下文切换的函数名称。   
 

     其次,如果不做任何配置,在Android命令行环境中,输入latencytop的效果如下:

     # latencytop
  latencytop
  Could not open /proc/sys/kernel/latencytop: No such file or directory
  Could not open /proc/sys/kernel/latencytop: No such file or directory

 

2.  开启Latencytop配置

     1) make kmenuconfig

          开启如下config:

          1 CONFIG_HAVE_LATENCYTOP_SUPPORT=y 2 CONFIG_LATENCYTOP=y  

     2) 在本人的BSD上*, 还需要关闭Audio相关的CONFIG,否则uboot起不来。

      关闭如下config:

          1 CONFIG_SOUND=n 

 

3.  使用

     1) latencytop的使用效果

 1 # latencytop                                           
 2 
 3 Latencies across all processes:
 4    Maximum     Average    Count   Reason
 5  117.18 ms   117.18 ms        1   vm_mmap_pgoff
 6  107.42 ms   107.42 ms        1   __access_remote_vm
 7    9.76 ms     9.76 ms        1   __lock_page_killable
 8    9.76 ms     9.76 ms        2   wait_on_page_bit_killable
 9    9.76 ms     9.76 ms        1   binder_ioctl
10    9.76 ms     9.76 ms        6   binder_thread_read

     同Linux下的latencytop相比,功能略显简陋,但是可以通过修改源代码,增强该工具的功能。(还在研究中。。。应该需要修改内核代码)

     PS:至于linux下的latencytop是什么样子,请自行谷歌 or 参考此链接 http://blog.yufeng.info/archives/1239

     2) latencytop命令参数

         Android中,latencytop是一个userspace工具,(源代码在此位置:https://android.googlesource.com/platform/system/extras, 其中的latencytop目录)。
         一般查看整个系统workload时,输入如下命令:

         #latencytop -d 1

         参数的具体含义(相信英文应该都看得懂吧...):

         Usage: latencytop [ -d delay ] [ -n iterations ] [ -p pid [ -t tid ] ] [ -h ]

              -d delay Time to sleep between updates.
              -n iterations Number of updates to show (0 = infinite).
              -p pid Process to monitor (default is all).
              -t tid Thread (within specified process) to monitor (default is all).
              -h Display this help screen.

         
       部分内容参考:http://blog.yufeng.info/archives/1239

  

  

posted on 2015-10-15 18:33  全能码农  阅读(807)  评论(0编辑  收藏  举报