iovisor / bcc

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

How to profile the execution time of a packet in kernel processing stack? #2086

Open MtKawakarpo opened 5 years ago

MtKawakarpo commented 5 years ago

Bcc is a greate tool! And I wonder if there has a way to measure the execution time of each packet in kernel processing (TCP/IP stack and socket processing)? I tried to do that but found that it is hard to identify a specific packet to calculate the latency of a processing step.

For example, the latency of a packet from receiving from NICs to finishing IP processing; and the latency from a socket event being ready, to the time the application proactively calling epoll_wait to poll event.

Hope for any suggestion and possible solution!

brendangregg commented 5 years ago

Yes, I believe it's possible. It's not easy though, and I'd expect this to take several days of reading the kernel TCP/IP implementation as well as examining code flow under different workloads using bcc tools.