From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7BD1D23A6; Wed, 23 Jul 2025 00:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753232321; cv=none; b=NgZ7jjPW5X6nf4VQX9gPSFx+QlGG/CfZZsyBkzjr7A3q24fsL+wxJtLKQBJGTlf6mCJ4337IoTQwHcKqTZjREhTUisF2Ds5DQXeSUHczfwVfg/c4wVN0+6JEP/Jx9+CbYuc1k/UNHKljpAAPD8QPFe+YXx5sTeoj+1hzpqQlkWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753232321; c=relaxed/simple; bh=4G0bgVi1RVDDgAIUFZL1U3SDhdVtKTFgSQxxXsA0X5s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=PyBunWE0drm66j34cnX5ku/IvGktG7d+deEP3UsNBvzUHNAhHGN47syluZMIMR+Robc+aIqu2JzDGujHXkR8OjeaF5d8PMQiTbLsfyTOuwEC6PggcVVsxjB10KZ6hWvsJ3XUX61RS5LPKGrE7dkJUw6oqRAeWJm5VWxafN0m/Kg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FXE4aXFV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FXE4aXFV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDFEBC4CEF6; Wed, 23 Jul 2025 00:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753232321; bh=4G0bgVi1RVDDgAIUFZL1U3SDhdVtKTFgSQxxXsA0X5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXE4aXFVKrKBWplCcCafnD4cuhgXVpCBjiLMFZVJFaUVAuvb9Knv9CWuWSgX9sWgf 2xD4rC0bWg/R4vvSWXnB7ekf55NViPy8bK2nPo9aMkJnld9e4rtPxNGbXoAIgbnAWU PngZ8B9ZtjJc09ePdXisUoNIsdJYY9/51BGB6iN68HkEMVfYrIkUJbagNorA3DoMGc k8o3J3SaxABUrAGt7y2UvEC9WFNMl2mAI7USme44aRrZjqrc8MSjORhq/sYT9UV5Uk bZjldJrIILf6mDD0VehPPgNjr4Th6+kN7ILNPIQqrSPOCw8thG/WaqWQWL3l5FmSlp YNZZmA+oD1YZQ== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Arnd Bergmann , "David S . Miller" , Aleksandr Loktionov , Alexander Lobakin , Sunitha Mekala , Tony Nguyen , Sasha Levin , przemyslaw.kitszel@intel.com, intel-wired-lan@lists.osuosl.org Subject: [PATCH AUTOSEL 6.6 2/5] ethernet: intel: fix building with large NR_CPUS Date: Tue, 22 Jul 2025 20:58:28 -0400 Message-Id: <20250723005833.1023337-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250723005833.1023337-1-sashal@kernel.org> References: <20250723005833.1023337-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.99 Content-Transfer-Encoding: 8bit From: Arnd Bergmann [ Upstream commit 24171a5a4a952c26568ff0d2a0bc8c4708a95e1d ] With large values of CONFIG_NR_CPUS, three Intel ethernet drivers fail to compile like: In function ‘i40e_free_q_vector’, inlined from ‘i40e_vsi_alloc_q_vectors’ at drivers/net/ethernet/intel/i40e/i40e_main.c:12112:3: 571 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) include/linux/rcupdate.h:1084:17: note: in expansion of macro ‘BUILD_BUG_ON’ 1084 | BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096); \ drivers/net/ethernet/intel/i40e/i40e_main.c:5113:9: note: in expansion of macro ‘kfree_rcu’ 5113 | kfree_rcu(q_vector, rcu); | ^~~~~~~~~ The problem is that the 'rcu' member in 'q_vector' is too far from the start of the structure. Move this member before the CPU mask instead, in all three drivers. Signed-off-by: Arnd Bergmann Acked-by: David S. Miller Reviewed-by: Aleksandr Loktionov Reviewed-by: Alexander Lobakin Tested-by: Sunitha Mekala (A Contingent worker at Intel) Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- LLM Generated explanations, may be completely bogus: **YES** This commit should be backported to stable kernel trees for the following reasons: 1. **Compilation Failure Fix**: This fixes a build-time compilation failure that occurs with large values of CONFIG_NR_CPUS. The error prevents the kernel from building successfully, which is a significant issue for systems configured with high CPU counts. 2. **Root Cause**: The issue stems from the `kfree_rcu()` macro in `include/linux/rcupdate.h:1084` which includes a `BUILD_BUG_ON(offsetof(typeof(*(ptr)), rhf) >= 4096)` check. This compile-time assertion ensures that the RCU head field is within the first 4096 bytes of the structure. 3. **Simple and Safe Fix**: The fix is straightforward - it moves the `struct rcu_head rcu` member earlier in the structure, placing it before the `cpumask_t affinity_mask` member. This is a safe change because: - It only reorders structure members - The RCU head doesn't need to be at any specific location functionally - Moving it earlier reduces the offset from the structure start - No functional code changes are required 4. **Affects Multiple Drivers**: The issue affects three Intel ethernet drivers (i40e, ixgbe, fm10k), all of which are fixed identically by moving the rcu member earlier in their respective q_vector structures. 5. **Configuration-Dependent Bug**: This bug only manifests with large CONFIG_NR_CPUS values (likely >= 512 or higher), where the `cpumask_t` type becomes large enough to push the rcu member beyond the 4096-byte offset limit. Systems with high core counts are becoming more common in production environments. 6. **No Risk of Regression**: The change is minimal and doesn't alter any functionality. It's purely a structural reordering that maintains all existing behavior while fixing the compilation issue. 7. **Meets Stable Criteria**: This fix clearly meets the stable kernel criteria as it: - Fixes a real bug (compilation failure) - Is minimal and contained - Has no risk of introducing new issues - Affects users with legitimate configurations The commit is an excellent candidate for stable backporting as it fixes a real compilation issue that prevents kernel builds on systems with large CPU counts, and the fix is trivial with no risk of regression. drivers/net/ethernet/intel/fm10k/fm10k.h | 3 ++- drivers/net/ethernet/intel/i40e/i40e.h | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/fm10k/fm10k.h b/drivers/net/ethernet/intel/fm10k/fm10k.h index 6119a41088381..65a2816142d96 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k.h +++ b/drivers/net/ethernet/intel/fm10k/fm10k.h @@ -189,13 +189,14 @@ struct fm10k_q_vector { struct fm10k_ring_container rx, tx; struct napi_struct napi; + struct rcu_head rcu; /* to avoid race with update stats on free */ + cpumask_t affinity_mask; char name[IFNAMSIZ + 9]; #ifdef CONFIG_DEBUG_FS struct dentry *dbg_q_vector; #endif /* CONFIG_DEBUG_FS */ - struct rcu_head rcu; /* to avoid race with update stats on free */ /* for dynamic allocation of rings associated with this q_vector */ struct fm10k_ring ring[] ____cacheline_internodealigned_in_smp; diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index 68f403dd2f526..9fb7c5fe05d15 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -953,6 +953,7 @@ struct i40e_q_vector { u16 reg_idx; /* register index of the interrupt */ struct napi_struct napi; + struct rcu_head rcu; /* to avoid race with update stats on free */ struct i40e_ring_container rx; struct i40e_ring_container tx; @@ -963,7 +964,6 @@ struct i40e_q_vector { cpumask_t affinity_mask; struct irq_affinity_notify affinity_notify; - struct rcu_head rcu; /* to avoid race with update stats on free */ char name[I40E_INT_NAME_STR_LEN]; bool arm_wb_state; bool in_busy_poll; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index b6f0376e42f4b..d15182657cead 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -503,9 +503,10 @@ struct ixgbe_q_vector { struct ixgbe_ring_container rx, tx; struct napi_struct napi; + struct rcu_head rcu; /* to avoid race with update stats on free */ + cpumask_t affinity_mask; int numa_node; - struct rcu_head rcu; /* to avoid race with update stats on free */ char name[IFNAMSIZ + 9]; /* for dynamic allocation of rings associated with this q_vector */ -- 2.39.5