Re: [PATCH v2] kernel: add kcov code coverage
From: Dmitry Vyukov
Date: Thu Jan 14 2016 - 09:24:59 EST
On Thu, Jan 14, 2016 at 1:49 PM, Kirill A. Shutemov
> 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?
Thank you very much tracking this down. Mailed v3 of the patch with this fix.
GCC inserts callbacks into every basic block of code. This is OK for
most of the code. But for some very special code it breaks as here. We
could change gcc to call a different callback in such cases, but it is
probably not worth it for the singe case.
> 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