zoukankan      html  css  js  c++  java
  • 抓取进程中包括其所有线程的iowait时间

    perf事件是可以按照线程按照进程统计的呢,但是/proc/接口就不提供这样的功能

    hon@station6:/proc/6288$ sudo perf stat -e sched:sched_switch -p 6288
    [sudo] hon 的密码: 
    ^C
     Performance counter stats for process id '6288':
    
                   473      sched:sched_switch                                          
    
           1.267507195 seconds time elapsed
    
    
    hon@station6:/proc/6288$ sudo perf stat -e sched:sched_switch -t 6291
    ^C
     Performance counter stats for thread id '6291':
    
                   157      sched:sched_switch                                          
    
           1.497770188 seconds time elapsed
    

     perf可以提供线程和进程的统计功能的,perf统计的原理是啥子呢

    在perf_event_open处跟踪pid函数,发现结果是:

    hon@station6:~/codebox/pthread$ sudo stap perf_event_open.stp 
    Begin
    perf: pid:6291
    
    perf: pid:6288
    perf: pid:6289
    perf: pid:6290
    perf: pid:6291
    perf: pid:6292
    

    这就明白是咋回事了,一个进程的线程是如何获取的,然后进程的pid

    最重要的结构体是perf_event_context和perf_event,

    perf: pid:12500 group_fd:4294967295
    perf perf_event_alloc
    perf: find_get_context.isra.82 ffff8800a770ba00
    perf: pid:12932 group_fd:4294967295
    perf perf_event_alloc
    perf: find_get_context.isra.82 0
    perf: alloc_perf_context
    
    
    
    perf: pid:12931 group_fd:4294967295
    perf perf_event_alloc
    perf: find_get_context.isra.82 0
    perf: alloc_perf_context
    perf: pid:12932 group_fd:4294967295
    perf perf_event_alloc
    perf: find_get_context.isra.82 ffff88013677ee00
    perf: pid:12933 group_fd:4294967295
    perf perf_event_alloc
    perf: find_get_context.isra.82 0
    perf: alloc_perf_context
    perf: pid:12934 group_fd:4294967295
    perf perf_event_alloc
    perf: find_get_context.isra.82 0
    perf: alloc_perf_context
    perf: pid:12935 group_fd:4294967295
    perf perf_event_alloc
    perf: find_get_context.isra.82 0
    perf: alloc_perf_context
    

     都是在第一次新建的时候创建的

  • 相关阅读:
    img的srcset和sizes属性作用
    屏幕尺寸,分辨率,像素,PPI之间到底什么关系
    img 的 srcset、sizes 属性和 picture 元素
    收房细则
    购买雅居乐湖居笔记不得不知。
    Andoird Studio 错误: 非法字符: 'ufeff' 解决方案。
    解决mysql 1040错误Too many connections的方法
    Android布局优化之include、merge、ViewStub的使用
    美国人、英国人、中国人一生都是如何度过
    Android常用正则工具类
  • 原文地址:https://www.cnblogs.com/honpey/p/9108728.html
Copyright © 2011-2022 走看看