这个过程略有不同;你在运行命令时,不使用 start参数,而是在record参数后面加上你想追踪的函数的“模式”。你还需要指定你想要的追踪器;在这种情况下,就是function_graph。该命令会继续记录追踪,直到你用Ctrl+C停止它。所以几秒钟后,按Ctrl+C停止追踪:
# trace-cmd list -f | grep ^ext4_# trace-cmd record -l ext4_* -p function_graph plugin 'function_graph'Hit Ctrl^C to stop recording^CCPU0 data recorded at offset=0x856000 8192 bytes in size[...]
查看追踪记录
要查看你之前的追踪记录,运行带有 report参数的命令。从输出结果来看,很明显过滤器起作用了,你只看到ext4相关的函数追踪:
# trace-cmd report | head -20[...]cpus=8 trace-cmd-12697 [000] 11303.928103: funcgraph_entry: | ext4_show_options { trace-cmd-12697 [000] 11303.928104: funcgraph_entry: 0.187 us | ext4_get_dummy_policy; trace-cmd-12697 [000] 11303.928105: funcgraph_exit: 1.583 us | } trace-cmd-12697 [000] 11303.928122: funcgraph_entry: | ext4_create { trace-cmd-12697 [000] 11303.928122: funcgraph_entry: | ext4_alloc_inode { trace-cmd-12697 [000] 11303.928123: funcgraph_entry: 0.101 us | ext4_es_init_tree; trace-cmd-12697 [000] 11303.928123: funcgraph_entry: 0.083 us | ext4_init_pending_tree; trace-cmd-12697 [000] 11303.928123: funcgraph_entry: 0.141 us | ext4_fc_init_inode; trace-cmd-12697 [000] 11303.928123: funcgraph_exit: 0.931 us | } trace-cmd-12697 [000] 11303.928124: funcgraph_entry: 0.081 us | ext4_get_dummy_policy; trace-cmd-12697 [000] 11303.928124: funcgraph_entry: 0.133 us | ext4_get_group_desc; trace-cmd-12697 [000] 11303.928124: funcgraph_entry: 0.115 us | ext4_free_inodes_count; trace-cmd-12697 [000] 11303.928124: funcgraph_entry: 0.114 us | ext4_get_group_desc;