Re: profiling the kernel

Ingo Molnar (mingo@pc5829.hil.siemens.at)
Tue, 22 Apr 1997 21:01:21 +0200 (MET DST)


On Tue, 22 Apr 1997, John Brosnan wrote:

> I'm looking for any tools/ideas to help profile the Linux TCP/UDP
> stacks, where the time is spent, etc. I'm guess I'm looking for a
> 'kernel' gprof.

first, there is the 'normal' kernel profiler (readprofile), which
maintains an EIP based histogram. You can turn it on by passing profile=2
on the boot prompt. It should give such output:

14944 5.26% c01311e4 try_to_free_buffer
16336 5.76% c01a2074 extract_entropy
16857 5.94% c011be34 free_module
17103 6.03% c01310f8 grow_buffers

You can go down to function level to display the histogram. This one uses
the timer-interrupt to do the histogram, thus it's a good idea to increase
asm/param.h:HZ before doing heavy profiling.

additionally there is an experimental 'kernel tracer', which is something
like strace, but for kernel-space. It traces functions and calculates
latencies with microsecond accuracy (thus nice for performance-tuning):

ftp://kernel.panic.julia.de/pub/linux/ktrace/ktrace-2.1.32.tar.gz

it gives this type of output:

Trace: c010c9b8 <*FAST_IRQ_ENTRY*+10/70> (4.98)
Trace: c01ba882 <aic7xxx_isr+16/26e8> (24.09)
Trace: c01ba0db <aic7xxx_done+f/4c> (3.36)
Trace: c01b9fd2 <aic7xxx_free_scb+e/108> (10.24)
Trace: c01af85f <scsi_done+13/66c> (2.00)
Trace: c01b04ff <update_timeout+13/17c> (24.57)

[we are thinking about adding call graph support to it, but it's not ready
yet]

-- mingo