Re: [PATCH 3/4] gcov: add gcov profiling infrastructure

Ingo Molnar
2009-02-03T15:32:01Z

* Peter Oberparleiter <oberpar@linux.vnet.ibm.com> wrote:

> From: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
>
> Enable the use of GCC's coverage testing tool gcov [1] with the Linux
> kernel. gcov may be useful for:
>
> * debugging (has this code been reached at all?)
> * test improvement (how do I change my test to cover these lines?)
> * minimizing kernel configurations (do I need this option if the
> associated code is never run?)
>
> The profiling patch incorporates the following changes:
>
> * change kbuild to include profiling flags
> * provide functions needed by profiling code
> * present profiling data as files in debugfs
>
> Note that on some architectures, enabling gcc's profiling option
> "-fprofile-arcs" for the entire kernel may trigger compile/link/
> run-time problems, some of which are caused by toolchain bugs and
> others which require adjustment of architecture code.
>
> For this reason profiling the entire kernel is initially restricted
> to those architectures for which it is known to work without changes.
> This restriction can be lifted once an architecture has been tested
> and found compatible with gcc's profiling. Profiling of single files
> or directories is still available on all platforms (see config help
> text).
>
>
> [1] http://gcc.gnu.org/onlinedocs/gcc/Gcov.html
>
> Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
> ---
>
> Documentation/gcov.txt | 246 ++++++++++++++
> Documentation/kernel-parameters.txt | 7
> Makefile | 11
> arch/Kconfig | 1
> init/main.c | 8
> kernel/Makefile | 1
> kernel/gcov/Kconfig | 48 ++
> kernel/gcov/Makefile | 3
> kernel/gcov/base.c | 145 ++++++++
> kernel/gcov/fs.c | 620 ++++++++++++++++++++++++++++++++++++
> kernel/gcov/gcc_3_4.c | 419 ++++++++++++++++++++++++
> kernel/gcov/gcov.h | 128 +++++++
> scripts/Makefile.lib | 9
> 13 files changed, 1641 insertions(+), 5 deletions(-)

Nice tool - with one general observation: i'd really prefer if this was
properly integrated with ftrace.

In particular the per object file controls are nice - those might be useful
to seed ftrace filters as well.

So there's good synergy possible and we should reach that synergy before
this goes upstream instead of putting it into a separate debugfs position
with incompatible flags and concepts. Especially since user-space tools will
pick up the gcov data so this gets hardcoded compatibility-wise very quickly
and changing it after the fact will be harder.

Yes, it's more work and it means extending both the ftrace code and the gcov
code - but it's very much worth it.

Ingo