Re: [PATCH v2 02/20] kbuild: unify static coverage instrumentation as COVERAGE_PROFILE
From: Nathan Chancellor
Date: Thu Nov 12 2026 - 20:34:14 EST
> The gcov plumbing is written for a single coverage implementation: the
> per-object and per-directory knobs are called GCOV_PROFILE, the flags
> are CFLAGS_GCOV, and every dependency on "coverage instrumentation is
> present" spells it as GCOV_KERNEL. Make this generic so that further
> coverage implementations can share it instead of growing parallel
> copies:
>
> - The coverage implementation becomes a choice ("Code coverage
> measurement"), with gcov as its only member besides "None" for now.
> COVERAGE_KERNEL is set whenever one is selected. allyesconfig and
> allmodconfig keep selecting gcov through a COMPILE_TEST default.
>
> - GCOV_PROFILE_ALL becomes COVERAGE_PROFILE_ALL. The old symbol is
> kept as a transitional one so that existing configurations keep
> profiling the entire kernel.
>
> - GCOV_PROFILE[_obj.o] becomes COVERAGE_PROFILE[_obj.o] tree-wide,
> with unchanged precedence (object, then directory, then
> COVERAGE_PROFILE_ALL). Out-of-tree modules that use GCOV_PROFILE
> need the same rename.
>
> - scripts/Makefile.gcov sets CFLAGS_COVERAGE instead of CFLAGS_GCOV.
>
> - The per-subsystem opt-ins GCOV_PROFILE_{NETFILTER,IPSET,IPVS,RDS,
> AMDGPU,URING,FTRACE} become COVERAGE_PROFILE_*, again with the old
> names kept as transitional symbols. The rds selftest is updated.
>
> - Dependencies that are about instrumented code rather than about
> gcov (LTO, the KCFI integer normalization workaround, the longest
> symbol KUnit test, the per-subsystem opt-ins and objtool's
> --no-unreachable) now use COVERAGE_KERNEL.
>
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
Reviewed-by: Nathan Chancellor <nathan@xxxxxxxxxx>
Sashiko's comment around tools/testing/selftests/net/rds/config.sh seems
relevant though.
> [ ... 622 lines skipped ... ]
> +config COVERAGE_PROFILE_ALL
> + bool "Profile entire kernel"
> + depends on !COMPILE_TEST
> + depends on GCOV_KERNEL && ARCH_HAS_GCOV_PROFILE_ALL
> + default GCOV_PROFILE_ALL
> + help
> + This option activates coverage instrumentation for the entire kernel.
> +
> + If unsure, say N.
> +
> + Note that a kernel compiled with profiling flags will be significantly
> + larger and run slower. Also be sure to exclude files from profiling
> + which are not linked to the kernel image to prevent linker errors.
Can you remove this sentence either in this change or a prerequisite
one? It is not needed after commit 9c2d1328f88a ("kbuild: provide
reasonable defaults for tool coverage").
--
Cheers,
Nathan