Commit 8806d502 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-fix-skb_ext-build_bug_on-failures-with-gcov'

Konstantin Khorenko says:

====================
net: fix skb_ext BUILD_BUG_ON failures with GCOV

This mini-series fixes build failures in net/core/skbuff.c when the
kernel is built with CONFIG_GCOV_PROFILE_ALL=y.

This is part of a larger effort to add -fprofile-update=atomic to
global CFLAGS_GCOV (posted earlier as a combined series):
  https://lore.kernel.org/lkml/20260401142020.1434243-1-khorenko@virtuozzo.com/T/#t

That combined series was split per subsystem as requested by Jakub.
The companion patches are:

 - iommu: use __always_inline for amdv1pt_install_leaf_entry()
   (sent to iommu maintainers)
 - gcov: add -fprofile-update=atomic globally (sent to gcov/kbuild
   maintainers, depends on this series and the iommu patch)

Patch 1/2 fixes a pre-existing build failure with CONFIG_GCOV_PROFILE_ALL:
GCOV counters prevent GCC from constant-folding the skb_ext_total_length()
loop.  It also removes the CONFIG_KCOV_INSTRUMENT_ALL preprocessor guard
from d6e5794b: that guard was a precaution in case KCOV instrumentation
also prevented constant folding, but KCOV's -fsanitize-coverage=trace-pc
does not interfere with GCC's constant folding (verified experimentally
with GCC 14.2 and GCC 16.0.1), so the guard is unnecessary.

Patch 2/2 is an additional fix needed when -fprofile-update=atomic is
added to CFLAGS_GCOV: __no_profile on the __always_inline function alone
is insufficient because after inlining, the code resides in the caller's
profiled body.  The caller (skb_extensions_init) needs __no_profile and
noinline to prevent re-exposure to GCOV instrumentation.
====================

Link: https://patch.msgid.link/20260410162150.3105738-1-khorenko@virtuozzo.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 06b97ff9 29b1ee87
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -5118,7 +5118,7 @@ static const u8 skb_ext_type_len[] = {
#endif
};

static __always_inline unsigned int skb_ext_total_length(void)
static __always_inline __no_profile unsigned int skb_ext_total_length(void)
{
	unsigned int l = SKB_EXT_CHUNKSIZEOF(struct skb_ext);
	int i;
@@ -5129,12 +5129,10 @@ static __always_inline unsigned int skb_ext_total_length(void)
	return l;
}

static void skb_extensions_init(void)
static noinline void __init __no_profile skb_extensions_init(void)
{
	BUILD_BUG_ON(SKB_EXT_NUM > 8);
#if !IS_ENABLED(CONFIG_KCOV_INSTRUMENT_ALL)
	BUILD_BUG_ON(skb_ext_total_length() > 255);
#endif

	skbuff_ext_cache = kmem_cache_create("skbuff_ext_cache",
					     SKB_EXT_ALIGN_VALUE * skb_ext_total_length(),