CPU usage of the kernel module

I need to know the CPU usage of a specific kernel module (e.g. iptable_mangle) on Linux (Fedora). I know that top or mpstat shows system CPU usage, which is actually a common CPU usage in kernel space. Is there any way to find out the CPU usage of a particular kernel object?

+5
source share
1 answer

Sorry to be disappointed, but you cannot do what you want, not because Linux does not have the ability, but by definition:

A module can โ€œconnectโ€ to the kernel in two general ways: either by setting a callback (for example, a proc or sys file, device, etc.), or by starting a kernel thread. In your case, iptable_mangle connects by setting callbacks to iptables / netfilter. This means that the module code executes as part of the network stack (in the context of ksoftirqd, to be more precise).

If it was in the context of a kernel thread, Linux stores statistics. But for callbacks this is not the case. The thread that ultimately executes the module code does a lot of things, so just isolating the module code is not practical (unless, of course, you have a source, and then you can easily add synchronization expressions).

ftrace - - . , , .

+6

All Articles