On 05.02.2014 18:36, H. Peter Anvin wrote: > On 02/05/2014 09:00 AM, Peter Oberparleiter wrote: >> >> Could you give this patch a try? It is a variation of the approach >> proposed in the discussion mentioned earlier and fixes the problem >> on my system. >> > > I would rather suggest that we explicitly disable gcov etc. from these > kinds of small, magic primitives. Honestly, you're just trying to put a > bandaid on a gaping wound. > > The real thing here is that hweight.c is not a normal C file, and we > shouldn't treat is as such. It is a constrained environment, and trying > to tack crap like gcov to it is bound to lose, simply because gcov > doesn't know the rules it has to play by. > > Even with the below change, if gcov clobbers, say, %rdx we're still screwed.
I'm fine with the proposed alternative of disabling gcov profiling for lib/hweight.c. The patch below fixes the problem on my test system. --- x86/hweight: Fix BUG when booting with CONFIG_GCOV_PROFILE_ALL=y Commit d61931d89b, "x86: Add optimized popcnt variants" introduced compile flag -fcall-saved-rdi for lib/hweight.c. When combined with options -fprofile-arcs and -O2, this flag causes gcc to generate broken constructor code. As a result, a 64 bit x86 kernel compiled with CONFIG_GCOV_PROFILE_ALL=y prints message "gcov: could not create file" and runs into sproadic BUGs during boot. This patch avoids the bug by excluding lib/hweight.o from coverage profiling. Reported-by: Meelis Roos <mr...@linux.ee> Cc: H. Peter Anvin <h...@zytor.com> Cc: Andrew Morton <a...@linux-foundation.org> Signed-off-by: Peter Oberparleiter <ober...@linux.vnet.ibm.com> --- lib/Makefile | 1 + 1 file changed, 1 insertion(+) diff -Naurp a/lib/Makefile b/lib/Makefile --- a/lib/Makefile +++ b/lib/Makefile @@ -43,6 +43,7 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o +GCOV_PROFILE_hweight.o := n CFLAGS_hweight.o = $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS)) obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/