• 抓取进程中包括其所有线程的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
    

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

  • 相关阅读:
    Nginx+Keepalived实现站点高可用
    强(strong)、软(soft)、弱(weak)、虚(phantom)引用
    Linux SSH 连接不上
    ExtJs Column 显示文字内容过长 使用Tootip显示全部内容
    史上最清晰的红黑树讲解(上)
    MySQL Cluster 集群
    分析《统计学习方法第2版》PDF+习题部分代码+部分课件讨论
    Case Styles: Camel, Pascal, Snake, and Kebab Case
    为什么EXE不能超过4GB
    But How Do It Know 关于人工智能的思考
  • 原文地址:https://www.cnblogs.com/honpey/p/9108728.html
Copyright © 2020-2023  润新知