iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.36k stars 3.86k forks source link

tools/execsnoop: display which cpu the processes running on #4904

Closed markyangcc closed 7 months ago

markyangcc commented 8 months ago

In SMP systems, knowing which specific CPU a process is running on can be useful for troubleshooting.

Test it,

[root@anylinux ~]# taskset -c 0 sleep 100 &
[1] 2199347
[root@anylinux ~]# taskset -c 1 sleep 100 &
[2] 2199348

Now, execsnoop with '-C' option displays that one sleep process is running on CPU 0, the other is running on CPU 1, as expected.

[root@anylinux ~]# /usr/share/bcc/tools/execsnoop -C
PCOMM            PID     PPID    CPU  RET ARGS
taskset          2199347 2199222 0      0 /usr/bin/taskset -c 0 sleep 100
sleep            2199347 2199222 0      0 /usr/bin/sleep 100
taskset          2199348 2199222 4      0 /usr/bin/taskset -c 1 sleep 100
sleep            2199348 2199222 1      0 /usr/bin/sleep 100
yonghong-song commented 7 months ago

can we add this 'cpu' display under an option (e.g., '-c')? The reason is in most cases, the value will be 0 and we should not display them. People can use -c if they have pinned-to-cpu task and they want to monitor them.