1999-07-09 20:45:08

by Dimitris Michailidis

[permalink] [raw]
Subject: Re: kernel profiling

Robert Walsh <[email protected]> writes:

> Other than /dev/profile, is there any mechanism available for
> profiling the kernel? For example, has anyone implemented a
> __mcount() function to handle a kernel compiled with -pg, or is this
> even possible?
>
> We're currently profiling the kernel NFS daemon (the entire path from
> network to disk) using SPECsfs and other benchmarking mechanisms, and
> before I start working on a home-grown profiling mechanism I'd like to
> make sure I'm not reinventing the wheel.
>
> BTW: /proc/profile hasn't got enough granularity for our purposes and
> doesn't provide info such as call-graph statistics.

Back in May I posted a patch to enable kernel profiling using gprof, which
should give you the call graph statistics you want. The patch basically
implements mcount() to collect statistics, adds a couple of files to /proc to
make the statistics available to the user land, and provides a command,
kernprof, to generate gmon.out for consumption by gprof. kernprof, in
addition to preparing data for gprof, also does the job of readprofile, with
a number of bugs of the latter fixed.

You can get the patch from

http://linuxwww.db.erau.edu/mail_archives/linux-kernel/May_99/2383.html

or other archives. Since there has been no response to this patch there has
been no further development since the initial release, but it probably still
applies cleanly against the 2.2.x kernels.

As noted in the initial post, due to bugs in gcc/egcs that cause
miscompilation of programs that use -pg and regparms, to use this patch you
either need a hacked version of egcs or you need to disable the FASTCALLs in
the kernel (the latter is done in the IKD patch).

Let me know if you have any suggestions to improve the patch or need other
assistance.

--
Dimitris Michailidis [email protected]