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
    

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

  • 相关阅读:
    BOM
    no response from Graphic Screen Painter Exiting
    Windows Mobile 中模拟按键
    C# 获取汉字拼音首字母
    Web Service介绍
    .net/c#中栈和堆的区别及代码在栈和堆中的执行流程详解
    使用JSON加速AJAX(By Sean Kelly)
    Sql字符串操作函数
    一个简单AJAX注册示例
    .Net平台开发的技术规范与实践精华总结
  • 原文地址:https://www.cnblogs.com/honpey/p/9108728.html
Copyright © 2011-2022 走看看