Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 288BA246BB5 for ; Mon, 30 Jun 2025 09:35:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751276152; cv=none; b=fvTWw1+4CYxER2AHooUCeRXmtsMPn5cjwZ98Oq27CMmgMTOWL2PEl20GfoNcQWGni1SkI9Io0lEFLj212lBaC1eicN47qvQwhcxM7NwO4Zo/RGxQXLdMUwsXHLXKiQ0Nfse/0hQk9GzVRYPsQ1c3DGWwycsxzmK5IWKIzpezxiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751276152; c=relaxed/simple; bh=h3heU2K0GsXbz0FHFyzN4/B/IwFDOuqk/6bnzHBPOF4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UTBqh9e1FqCb6UfbN7k91MB7uZrA2LecrxEbZym9dycYq0/4B+HkKNIQga3geknVBsf+vLyuJzS8kCF3/U2q6d2hoFm9YVhD90rrO53Es2eEGQThAJsX/BSL7vNNqv253YBnWHfetZ4GSQMRkPe6l+iAb5VDyJaPgesA9lfkoQ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kCPOKOw/; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kCPOKOw/" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-70e649662deso23746337b3.2 for ; Mon, 30 Jun 2025 02:35:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1751276150; x=1751880950; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1kYmMm4FiOHgXVZCZzdvmjZJcyMUaNZWKvL+31mKlDk=; b=kCPOKOw/M/eIq1wLrMqgjEYMxof/xipTmgtVx8XPqjE67JVy14LkU8RHEFHBhI97nL 3RPoN4Nd+6Pfvj8xcx3ae2EvRnMj8FSMgwrNT1uRe4AUV4wNrkwXttF0hhCpYtVNz5Ef fMPlTNGjB1WXuzFNvd+aslUb1nHbrAw73OmeFLUI5tOls8gj6UBp5QBLidrI95xJ2ein AFXKnGZFL65HGC+EnMi0nSm3pk18ONjR6XDKf3zTg2NYfDrIwGk/38/YgNk6/1K4nbOW uHsLN0ovL73X86A168gUmuCPxauwuG9OaEqD4DL44I6lZ1sjzU7Nh4zgwdMc8K1x1Ft5 PtiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751276150; x=1751880950; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1kYmMm4FiOHgXVZCZzdvmjZJcyMUaNZWKvL+31mKlDk=; b=JBlKrPMmFf71wfr/raftiBwEBraiBoyJizP6bDaJG/JfEo0lUFUXADfDzdNqHUIyEc W1v0MyZInEtqnjwjuR/Ghvya8Sq3qw/Danrg05BivLCbB8ASZLlBwQwZjOcq7epA3zVi +B7HOAIIOiMoUqZA2N/11oZRjZH7C5spui8fQnkOYZ626ykvPcxnLgYOd91HGYcYZySR XllNhWmEDO+80MkjYANe8LzdahjIu6x8mL42GZgwwzCpkSaYWfYrVFMXbSx4mLL/7UMe 0fjTOJdfOmKq8NBgr5VmpyaXyrE4F21W1wBD/mOJs0wWyQ4BCN+nYOOZKp1FmRUL1Lg3 oiqA== X-Forwarded-Encrypted: i=1; AJvYcCUsaG34GWmdRnWsCHc0+DZ4B4CU1bedn3MXGdJgwDnYFBDupqmi5YJ6kvXFEufBaRjuCr0t/ec=@vger.kernel.org X-Gm-Message-State: AOJu0YxPJ4qS1R3Z3ldYkc8nZ8ZBXGDjJXSmIofgdJTuU3eaKq8TpVjz 2hvWzwMpPyv35Jij4kSKFgdswDSC83gXmBifyIntGN6Po271qAq3BBlsvFumfoG2AcM1JXytM/s fK2zZO6X2OZDgBw== X-Google-Smtp-Source: AGHT+IGa8jxvaIVFZ29RhZEnRP5NWiDGEXZzYWVfZfP/q0jLZZ20xX+qQWNmRefRE1KkV0lnhoZ1lXOpLZjYJA== X-Received: from ybaa7.prod.google.com ([2002:a05:6902:4807:b0:e82:466b:5564]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6902:1507:b0:e82:4ad:10c7 with SMTP id 3f1490d57ef6-e87a7b533f2mr16688910276.28.1751276149927; Mon, 30 Jun 2025 02:35:49 -0700 (PDT) Date: Mon, 30 Jun 2025 09:35:40 +0000 In-Reply-To: <20250630093540.3052835-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250630093540.3052835-1-edumazet@google.com> X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog Message-ID: <20250630093540.3052835-5-edumazet@google.com> Subject: [PATCH v2 net-next 4/4] udp: move udp_memory_allocated into net_aligned_data From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Willem de Bruijn , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Content-Type: text/plain; charset="UTF-8" ____cacheline_aligned_in_smp attribute only makes sure to align a field to a cache line. It does not prevent the linker to use the remaining of the cache line for other variables, causing potential false sharing. Signed-off-by: Eric Dumazet Reviewed-by: Willem de Bruijn --- include/net/aligned_data.h | 1 + include/net/udp.h | 1 - net/ipv4/udp.c | 4 +--- net/ipv4/udp_impl.h | 1 + net/ipv4/udplite.c | 2 +- net/ipv6/udp.c | 2 +- net/ipv6/udp_impl.h | 1 + net/ipv6/udplite.c | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/net/aligned_data.h b/include/net/aligned_data.h index bedb4f86b0fea1ce13a10895182681c37ef7e904..e1a1c8aedc79753f63eb7c81757639ea20829f0d 100644 --- a/include/net/aligned_data.h +++ b/include/net/aligned_data.h @@ -13,6 +13,7 @@ struct net_aligned_data { atomic64_t net_cookie ____cacheline_aligned_in_smp; #if defined(CONFIG_INET) atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp; + atomic_long_t udp_memory_allocated ____cacheline_aligned_in_smp; #endif }; diff --git a/include/net/udp.h b/include/net/udp.h index a772510b2aa58a922dc4dd5bd7cb7f7f0c1ce0e3..f8ae2c4ade141d27e4af3376f5a177e46d5b39ea 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -205,7 +205,6 @@ static inline void udp_hash4_dec(struct udp_hslot *hslot2) extern struct proto udp_prot; -extern atomic_long_t udp_memory_allocated; DECLARE_PER_CPU(int, udp_memory_per_cpu_fw_alloc); /* sysctl variables for udp */ diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 19573ee64a0f18cf55df34ace1956e9c3e20172c..49f43c54cfb0e3ac85c1a6202f3d6a2f1ca6d0ba 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -127,8 +127,6 @@ struct udp_table udp_table __read_mostly; long sysctl_udp_mem[3] __read_mostly; EXPORT_IPV6_MOD(sysctl_udp_mem); -atomic_long_t udp_memory_allocated ____cacheline_aligned_in_smp; -EXPORT_IPV6_MOD(udp_memory_allocated); DEFINE_PER_CPU(int, udp_memory_per_cpu_fw_alloc); EXPORT_PER_CPU_SYMBOL_GPL(udp_memory_per_cpu_fw_alloc); @@ -3235,7 +3233,7 @@ struct proto udp_prot = { #ifdef CONFIG_BPF_SYSCALL .psock_update_sk_prot = udp_bpf_update_proto, #endif - .memory_allocated = &udp_memory_allocated, + .memory_allocated = &net_aligned_data.udp_memory_allocated, .per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc, .sysctl_mem = sysctl_udp_mem, diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h index e1ff3a37599614b18a0b621534019a7bd71ea901..c7142213fc2112c9e423caa5e6d84bafeaca9936 100644 --- a/net/ipv4/udp_impl.h +++ b/net/ipv4/udp_impl.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #ifndef _UDP4_IMPL_H #define _UDP4_IMPL_H +#include #include #include #include diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index af37af3ab727bffeebe5c41d84cb7c130f49c50d..d3e621a11a1aa4cafb62eb53ddc0ed1ca517a7fe 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c @@ -60,7 +60,7 @@ struct proto udplite_prot = { .rehash = udp_v4_rehash, .get_port = udp_v4_get_port, - .memory_allocated = &udp_memory_allocated, + .memory_allocated = &net_aligned_data.udp_memory_allocated, .per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc, .sysctl_mem = sysctl_udp_mem, diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index ebb95d8bc6819f72842fd1567e73fcef4f1e0ed0..6bbdadbd5fecccfb7de99f05c6fb179393e162f2 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1925,7 +1925,7 @@ struct proto udpv6_prot = { .psock_update_sk_prot = udp_bpf_update_proto, #endif - .memory_allocated = &udp_memory_allocated, + .memory_allocated = &net_aligned_data.udp_memory_allocated, .per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc, .sysctl_mem = sysctl_udp_mem, diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h index 0590f566379d7d07dfdd1b0ae808b9d8964eb5aa..8a406be25a3a6dee687a6a02ea0b6a28428abb86 100644 --- a/net/ipv6/udp_impl.h +++ b/net/ipv6/udp_impl.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ #ifndef _UDP6_IMPL_H #define _UDP6_IMPL_H +#include #include #include #include diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index a60bec9b14f14a5b2d271f9965b5fca3d2a440c8..2cec542437f74eba9540fc464ee70d8b0bc0be79 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c @@ -59,7 +59,7 @@ struct proto udplitev6_prot = { .rehash = udp_v6_rehash, .get_port = udp_v6_get_port, - .memory_allocated = &udp_memory_allocated, + .memory_allocated = &net_aligned_data.udp_memory_allocated, .per_cpu_fw_alloc = &udp_memory_per_cpu_fw_alloc, .sysctl_mem = sysctl_udp_mem, -- 2.50.0.727.gbf7dc18ff4-goog