我正在玩perf来学习如何找出进程进入“d”(不间断睡眠)状态的原因。
我正在使用perf命令:
perf record -g -p 4710 -e sched:sched_stat_iowait,sched:sched_stat_blocked sleep 60
其中
4710
是进程的pid,称为meetmaker
。然后我看到的是
meetmaker-3.0.0 4710 [008] 19187729.668851: sched:sched_stat_iowait: comm=jbd2/dm-2-8 pid=697 delay=120641 [ns]
ffffffff810a08a0 enqueue_sleeper ([kernel.kallsyms])
ffffffff810a08a0 enqueue_sleeper ([kernel.kallsyms])
ffffffff810a756a enqueue_entity ([kernel.kallsyms])
ffffffff810a7e83 enqueue_task_fair ([kernel.kallsyms])
ffffffff810967b1 ttwu_activate ([kernel.kallsyms])
ffffffff81096983 ttwu_do_activate ([kernel.kallsyms])
ffffffff8109819a ttwu_queue ([kernel.kallsyms])
ffffffff810983fe try_to_wake_up ([kernel.kallsyms])
ffffffff810ada66 autoremove_wake_function ([kernel.kallsyms])
ffffffff810ad8fa __wake_up_common ([kernel.kallsyms])
ffffffff810addb8 __wake_up ([kernel.kallsyms])
ffffffff810ade11 __wake_up_bit ([kernel.kallsyms])
ffffffff81260fcb ext4_finish_bio ([kernel.kallsyms])
ffffffff812617df ext4_end_bio ([kernel.kallsyms])
ffffffff8131b433 blk_update_request ([kernel.kallsyms])
ffffffff8131b5b7 blk_update_bidi_request ([kernel.kallsyms])
ffffffff8131c9af blk_end_bidi_request ([kernel.kallsyms])
ffffffff8148f1f0 scsi_io_completion ([kernel.kallsyms])
ffffffff813263bb blk_done_softirq ([kernel.kallsyms])
ffffffff8106af9c __do_softirq ([kernel.kallsyms])
ffffffff8106b1e5 irq_exit ([kernel.kallsyms])
ffffffff816399fa do_IRQ ([kernel.kallsyms])
ffffffff8163796d ret_from_intr ([kernel.kallsyms])
487f77 [unknown] ([unknown])
487f77 meetmaker__user_counters_get (/local/meetmaker/bin/meetmaker-3.0.0_2724)
505cff gpbrpc_exec (/local/meetmaker/bin/meetmaker-3.0.0_2724)
4eb45c ipc_game_loop (/local/meetmaker/bin/meetmaker-3.0.0_2724)
4ed48a game (/local/meetmaker/bin/meetmaker-3.0.0_2724)
48ebe3 service_late_init (/local/meetmaker/bin/meetmaker-3.0.0_2724)
47371a main (/local/meetmaker/bin/meetmaker-3.0.0_2724)
7fd3cc391c36 __libc_start_main (/lib64/libc-2.11.3.so)
meetmaker-3.0.0 4710 [008] 19187729.668886: sched:sched_stat_blocked: comm=jbd2/dm-2-8 pid=697 delay=120641 [ns]
ffffffff810a08d8 enqueue_sleeper ([kernel.kallsyms])
ffffffff810a08d8 enqueue_sleeper ([kernel.kallsyms])
ffffffff810a756a enqueue_entity ([kernel.kallsyms])
ffffffff810a7e83 enqueue_task_fair ([kernel.kallsyms])
ffffffff810967b1 ttwu_activate ([kernel.kallsyms])
ffffffff81096983 ttwu_do_activate ([kernel.kallsyms])
ffffffff8109819a ttwu_queue ([kernel.kallsyms])
ffffffff810983fe try_to_wake_up ([kernel.kallsyms])
ffffffff810ada66 autoremove_wake_function ([kernel.kallsyms])
ffffffff810ad8fa __wake_up_common ([kernel.kallsyms])
ffffffff810addb8 __wake_up ([kernel.kallsyms])
ffffffff810ade11 __wake_up_bit ([kernel.kallsyms])
ffffffff81260fcb ext4_finish_bio ([kernel.kallsyms])
ffffffff812617df ext4_end_bio ([kernel.kallsyms])
ffffffff8131b433 blk_update_request ([kernel.kallsyms])
ffffffff8131b5b7 blk_update_bidi_request ([kernel.kallsyms])
ffffffff8131c9af blk_end_bidi_request ([kernel.kallsyms])
ffffffff8148f1f0 scsi_io_completion ([kernel.kallsyms])
ffffffff813263bb blk_done_softirq ([kernel.kallsyms])
ffffffff8106af9c __do_softirq ([kernel.kallsyms])
ffffffff8106b1e5 irq_exit ([kernel.kallsyms])
ffffffff816399fa do_IRQ ([kernel.kallsyms])
ffffffff8163796d ret_from_intr ([kernel.kallsyms])
487f77 [unknown] ([unknown])
487f77 meetmaker__user_counters_get (/local/meetmaker/bin/meetmaker-3.0.0_2724)
505cff gpbrpc_exec (/local/meetmaker/bin/meetmaker-3.0.0_2724)
4eb45c ipc_game_loop (/local/meetmaker/bin/meetmaker-3.0.0_2724)
4ed48a game (/local/meetmaker/bin/meetmaker-3.0.0_2724)
48ebe3 service_late_init (/local/meetmaker/bin/meetmaker-3.0.0_2724)
47371a main (/local/meetmaker/bin/meetmaker-3.0.0_2724)
7fd3cc391c36 __libc_start_main (/lib64/libc-2.11.3.so)
据我所知,这个perf输出是处于d状态的
perf script
内核线程,它抢占了我的jbd
进程。不是meetmaker
进程进入了d状态,对吧?所以这不是我要找的。尽管我给perf提供了
meetmaker
参数,但它给了我另一个我不感兴趣的过程。我说得对吗?
这是找出任何特定流程何时以及为什么进入“d”状态的最佳方法吗?
最佳答案
perf是错误的工具。您可以使用systemtap跟踪此类状态转换。
然而,并没有什么神奇的规则。你必须分别调查每个地方。
关于linux - 使用性能来确定何时以及为何过程进入不间断 sleep ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34901524/