Re: [PATCH v2] kernel: add kcov code coverage

From: Kirill A. Shutemov
Date: Thu Jan 14 2016 - 07:50:09 EST


On Thu, Jan 14, 2016 at 01:21:27PM +0100, Dmitry Vyukov wrote:
> >> Alternatively, you can try to bulk disable instrumentation of
> >> everything related to boot process (by adding KCOV_INSTRUMENT := n to
> >> the Makefile). Most likely it is due to instrumentation. If it helps,
> >> try to bisect the the guilty files.
> >
> > Okay, I'll try.
>
>
> I've tried with exactly your gcc revision and your config and VM boots fine...
>
> For me it prints 4 CPUs:
> [ 0.193348] smpboot: Total of 4 processors activated
> so it is probably fine :)
>
> I am almost sure that the root cause is kcov instrumentation is some
> inappropriate place. I've fixed such symptoms several times by
> disabling instrumentation in various places.

Okay, I found it. The patch below helps.

But I wounder how safe this thing is. :-/

Looks like -fsanitize-coverage=trace-pc doesn't play well when we change
calling convention for the compilation unit, as we do for hweight.o.
See CONFIG_ARCH_HWEIGHT_CFLAGS.

What else should we expect from GCC in this mode?

diff --git a/lib/Makefile b/lib/Makefile
index 58043870dbd2..56171482f99f 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -15,6 +15,7 @@ KCOV_INSTRUMENT_rbtree.o := n
KCOV_INSTRUMENT_list_debug.o := n
KCOV_INSTRUMENT_debugobjects.o := n
KCOV_INSTRUMENT_dynamic_debug.o := n
+KCOV_INSTRUMENT_hweight.o := n

lib-y := ctype.o string.o vsprintf.o cmdline.o \
rbtree.o radix-tree.o dump_stack.o timerqueue.o\
--
Kirill A. Shutemov