From nobody Mon Jun 15 10:47:20 2026 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F21F426290; Thu, 9 Apr 2026 21:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.117.225.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775771275; cv=none; b=KKpv06jgdtqUDSN6XhCIAfM6hnAl52gJ/knVjpM1/L5GHd5DjWb43jlsz9b+IdTWUYj2ZHtlrL4sWuALVjapltEOUmw94vTkwJG4BPP1MwQnAu1907X32txSLPIEaAR5+9rC6qCGx4r5zsDEAxjRACi96aUDHx+vnFkbuFQGLZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775771275; c=relaxed/simple; bh=DOHeJdgg83sZ0T9jmnNAfQfxk9FMb4A2+LrUFf+Vtk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LnZrnP8bnTZWWhon249oiPeOR1IGEJHlmKEiQjiUhC1oHtkyj38+MTBb3y87b2IxOIGAFI0SKjrIXdjhOUQa3rQg/mX4ptP/p+0zH6aXouh5BPLbcXyILiU6gPGG2vneiQLGrQkXLrRaoS5ogtx7YzAy1+Og82XqSDsYoXOK5to= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com; spf=pass smtp.mailfrom=virtuozzo.com; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b=VdEM7HRy; arc=none smtp.client-ip=130.117.225.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="VdEM7HRy" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=18EucyhQlopspBaafNNDLK93kDt938llAL+OtB7xCJg=; b=VdEM7HRyDIjn i7AaD6Rjqx3h0y0Y1GXFTmEUf0ILA8nBL/Wsouoln4qVKeNIUvitEg8LtEgaiONlvbbu3aQXt2VA/ KLUlh5vEfrZ4AxxXsw6qH9wWJld5kDQL4+Z3Q7jlnVq7qaoTPflSSB+tVvv7pcyUuJ4aSsrswRXxx lT1SI1V7T/R2q0+zsuaRW2G+wbqmGDWeZK/EnYylpX6FDaD8RGRePUAPpmCFv8JE5M4CbL2N41yCu ZG7dMrCEZ1NWltlAXDGQXjK4e0AmF26dYY4NOudPSDOHXg1KUm3tI3mfdf5MuE9q+x3/WbpWzl5++ sHvs9kflq03Stf2a7/rEvg==; Received: from [130.117.225.5] (helo=finist-alma9.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1wAxBX-002p6C-26; Thu, 09 Apr 2026 23:47:34 +0200 From: Konstantin Khorenko To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Arnd Bergmann , Peter Oberparleiter , Mikhail Zaslonko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Tikhomirov , Vasileios Almpanis , Konstantin Khorenko Subject: [PATCH v2 1/2] net: fix skb_ext_total_length() BUILD_BUG_ON with CONFIG_GCOV_PROFILE_ALL Date: Fri, 10 Apr 2026 00:47:35 +0300 Message-ID: <20260409214736.2651198-2-khorenko@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260409214736.2651198-1-khorenko@virtuozzo.com> References: <20260402140558.1437002-1-khorenko@virtuozzo.com> <20260409214736.2651198-1-khorenko@virtuozzo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When CONFIG_GCOV_PROFILE_ALL=3Dy is enabled, the kernel fails to build: In file included from : In function 'skb_extensions_init', inlined from 'skb_init' at net/core/skbuff.c:5214:2: ././include/linux/compiler_types.h:706:45: error: call to '__compiletime_assert_1490' declared with attribute error: BUILD_BUG_ON failed: skb_ext_total_length() > 255 CONFIG_GCOV_PROFILE_ALL adds -fprofile-arcs -ftest-coverage -fno-tree-loop-im to CFLAGS globally. GCC inserts branch profiling counters into the skb_ext_total_length() loop and, combined with -fno-tree-loop-im (which disables loop invariant motion), cannot constant-fold the result. BUILD_BUG_ON requires a compile-time constant and fails. The issue manifests in kernels with 5+ SKB extension types enabled (e.g., after addition of SKB_EXT_CAN, SKB_EXT_PSP). With 4 extensions GCC can still unroll and fold the loop despite GCOV instrumentation; with 5+ it gives up. Mark skb_ext_total_length() with __no_profile to prevent GCOV from inserting counters into this function. Without counters the loop is "clean" and GCC can constant-fold it even with -fno-tree-loop-im active. This allows BUILD_BUG_ON to work correctly while keeping GCOV profiling for the rest of the kernel. This also removes the CONFIG_KCOV_INSTRUMENT_ALL preprocessor guard introduced by d6e5794b06c0. That guard was added as a precaution because KCOV instrumentation was also suspected of inhibiting constant folding. However, KCOV uses -fsanitize-coverage=3Dtrace-pc, which inserts lightweight trace callbacks that do not interfere with GCC's constant folding or loop optimization passes. Only GCOV's -fprofile-arcs combined with -fno-tree-loop-im actually prevents the compiler from evaluating the loop at compile time. The guard is therefore unnecessary and can be safely removed. Fixes: 96ea3a1e2d31 ("can: add CAN skb extension infrastructure") Signed-off-by: Konstantin Khorenko Reviewed-by: Thomas Weissschuh --- net/core/skbuff.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 43ee86dcf2ea..59fb4b2bb821 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5142,7 +5142,7 @@ static const u8 skb_ext_type_len[] =3D { #endif }; =20 -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 =3D SKB_EXT_CHUNKSIZEOF(struct skb_ext); int i; @@ -5156,9 +5156,7 @@ static __always_inline unsigned int skb_ext_total_len= gth(void) static void 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 =20 skbuff_ext_cache =3D kmem_cache_create("skbuff_ext_cache", SKB_EXT_ALIGN_VALUE * skb_ext_total_length(), --=20 2.43.5 From nobody Mon Jun 15 10:47:20 2026 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9EBC37C92C; Thu, 9 Apr 2026 21:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.117.225.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775771279; cv=none; b=Tl0R3sURPxYCIxk6WuamkeORDbNLU7FZIVXrDiynOWacTFp9pKhJ3gb0HGXYs6h7pUjho/j1oafmw03Pfiq3UtRD3sq0Ni31JrSaWAjgwml90QRewdYKXQWlWnV8Do0o/YR9MZRvAHuFAnE8gGJtfiPEYuEgjOvw7WtwT4Te9Ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775771279; c=relaxed/simple; bh=8tsXI5GWVUlhJaYC/LK3zhp+R7hyhPbm41VUEHqo5p0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qZc9Dti5+66GL4r1kzn86pSyIJWSoQW4aYVIxjkfXtyZa1zBikTurMSpRIRe0nfWdBbZ8cJIwC0ICumAPWw+grSMnMODtZP52iHaQ1PbDZ0tMg2vwGUbLWjMmmYfByF6Kr518unrkLX8BZdUoXI2hHi7Qngmz8+CygK12rpzJ0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com; spf=pass smtp.mailfrom=virtuozzo.com; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b=eVop7GSp; arc=none smtp.client-ip=130.117.225.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="eVop7GSp" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=7SNfDvJtC0DyGm9hfzn/dNerAkSGQ1wxTuVdvFD0rFY=; b=eVop7GSpqu9d 9rAxQOjmSsWn4sGLDD7vPiyfTVvl9XQ/7W/9tTd6ijQYdssY5zi33q1nCKNIAMAGntrzwVc4EkUdh k33Cc8DKiHIAEwggUEPc9ibPDk+IDpZ3fynBOzELunz5bZuWfaifWuZy9ADmz5r+bdyWKbrdl4NfC aXaANFWWaQlb0xDt/KxwZD7/buhTlxTghbJyZzgE6cm0yi2h+ua4WtjcwszwFilAx3IM9p/LL/DWS OGA6SFRWSYjAHGyHgPevDsr9kykzIVTTVb/J6AFTlNuw0u63sIdwMtCQOXgW7KF35g/i11Fd5sgdc 061Sh1LBb+NRDv86jUG68g==; Received: from [130.117.225.5] (helo=finist-alma9.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1wAxBX-002p6C-2H; Thu, 09 Apr 2026 23:47:34 +0200 From: Konstantin Khorenko To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Arnd Bergmann , Peter Oberparleiter , Mikhail Zaslonko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Tikhomirov , Vasileios Almpanis , Konstantin Khorenko Subject: [PATCH v2 2/2] net: add noinline __no_profile to skb_extensions_init() for GCOV compatibility Date: Fri, 10 Apr 2026 00:47:36 +0300 Message-ID: <20260409214736.2651198-3-khorenko@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20260409214736.2651198-1-khorenko@virtuozzo.com> References: <20260402140558.1437002-1-khorenko@virtuozzo.com> <20260409214736.2651198-1-khorenko@virtuozzo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With -fprofile-update=3Datomic in global CFLAGS_GCOV, GCC still cannot constant-fold the skb_ext_total_length() loop when it is inlined into a profiled caller. The existing __no_profile on skb_ext_total_length() itself is insufficient because after __always_inline expansion the code resides in the caller's body, which still carries GCOV instrumentation. Mark skb_extensions_init() with __no_profile so the BUILD_BUG_ON checks can be evaluated at compile time. Also mark it noinline to prevent the compiler from inlining it into skb_init() (which lacks __no_profile), which would re-expose the function body to GCOV instrumentation. Build-tested with both CONFIG_GCOV_PROFILE_ALL=3Dy and CONFIG_KCOV_INSTRUMENT_ALL=3Dy. Signed-off-by: Konstantin Khorenko --- net/core/skbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 59fb4b2bb821..8d75e352e3b1 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5153,7 +5153,7 @@ static __always_inline __no_profile unsigned int skb_= ext_total_length(void) return l; } =20 -static void skb_extensions_init(void) +static noinline void __no_profile skb_extensions_init(void) { BUILD_BUG_ON(SKB_EXT_NUM > 8); BUILD_BUG_ON(skb_ext_total_length() > 255); --=20 2.43.5