Article View: linux.kernel.netdev
Article #24648Re: [PATCH net-next v2] net: dst: avoid false sharing between tclassid and __rcuref
From: Simon Horman
Date: Mon, 30 Nov 2026 14:41
Date: Mon, 30 Nov 2026 14:41
77 lines
10400 bytes
10400 bytes
On Fri, Nov 20, 2026 at 02:16:04PM +0800, Jiebin Sun wrote:
> On x86-64 with CONFIG_IP_ROUTE_CLASSID=y, ip_rcv_finish_core() reads
> dst_entry::tclassid from the cache line containing __rcuref. Concurrent
> reference updates cause false sharing with this load.
>
> Swap expires with {error, __pad, tclassid} to move tclassid and error
> into the first cache line without growing dst_entry. The structures
> that embed it, including rtable, rt6_info, and metadata_dst, keep
> their sizes.
>
> pahole on x86-64 (sizes and offsets in bytes)
>
> +----------------------+--------+-------+
> | Struct or field | Before | After |
> +----------------------+--------+-------+
> | sizeof(dst_entry) | 136 | 136 |
> | dst_entry.expires | 24 | 96 |
> | dst_entry.__rcuref | 64 | 64 |
> | dst_entry.tclassid | 100 | 28 |
> +----------------------+--------+-------+
>
> The IPv4 loopback paths are shown below.
>
> TX: __dev_queue_xmit() -> skb_dst_force() -> dst_hold_safe()
> -> rcuref_get()
> RX: ip_rcv_finish_core() -> skb_dst(skb)->tclassid
>
> At the tclassid load, separate 30-second perf c2c runs recorded:
>
> +----------+------------+-------------+
> | Kernel | Local HITM | Remote HITM |
> +----------+------------+-------------+
> | Baseline | 2624 | 2611 |
> | Swap | 1 | 0 |
> +----------+------------+-------------+
>
> Memcached over IPv4 loopback (64 threads each, 5 x 60s,
> 20s warmup, mean ops/s)
> Baseline: commit 6628e7d4c6b2 ("Linux 7.4-rc1")
>
> +-----------+-----------------+
> | Memcached | Improvement (%) |
> +-----------+-----------------+
> | default | +32.55 |
> | hit | +45.79 |
> | balanced | -0.12 |
> | large | +45.62 |
> +-----------+-----------------+
>
> Default client
>
> memtier_benchmark -s 127.0.0.1 -p 11221 -P memcache_text
> -t 64 -c 1 --pipeline=16 --test-time=60 --ratio=1:100
> --data-size=32 --key-maximum=10000000
>
> Server
>
> memcached -c 4096 -t 64 -u pnp -p 11221 -l 127.0.0.1
>
> Client variants
>
> hit: --key-maximum=1000
> balanced: --key-maximum=1000 --ratio=1:1
> large: --key-maximum=1000 --data-size=1024
>
> Suggested-by: Eric Dumazet <edumazet@kernel.org>
> Suggested-by: Tim Chen <tim.c.chen@linux.intel.com>
> Reviewed-by: Tianyou Li <tianyou.li@intel.com>
> Reviewed-by: Wangyang Guo <wangyang.guo@intel.com>
> Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>
> ---
> Changes in v2:
> - Swap expires with error/__pad/tclassid and show the pahole results.
> - Clarify the loopback path and keep the memcached and c2c tables.
Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID:
<20261130144145.GE804035@horms.kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374252-linux-kernel-netdev=dewy.ruReferences:
<20261120061604.3676605-1-jiebin.sun@intel.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374252-linux-kernel-netdev=dewy.ru From: horms@kernel.org (Simon Horman) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2] net: dst: avoid false sharing between tclassid and __rcuref Date: Mon, 30 Nov 2026 14:41:45 +0000 Organization: Usenet Network Message-ID: <20261130144145.GE804035@horms.kernel.org> References: <20261120061604.3676605-1-jiebin.sun@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1447463"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:1DifNy6U4isnaR6FnaHNof/fYkg= sha256:RwSjoF97N5c78KOsuD1cIvTwxB2WRtIg++QEaQqjT08= sha1:1p284LZXNei8+TF2NcziTHwOQtc= sha256:pJJiXbXvZPrPPwzhQF+7PZnwOMdktSVZJcSXEGXeQZ4= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 646AE125FF0; Mon, 30 Nov 2026 17:42:06 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oZf2y5PsALtL; Mon, 30 Nov 2026 17:42:03 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-374252-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 6C2DB125FEE; Mon, 30 Nov 2026 17:41:55 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id E8D226027B1; Mon, 30 Nov 2026 14:41:54 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796049711; b=n8DveHRZPV9aXHLrRI0gn7s9GuHyUQe21oDQZ7jrwPIJu246y3LpUmo7FpyOpJvl8eP7 sJ/qun7RfKCzVGEzT3n6+OYETy9VdvpeC0+hcQ748Z02MRivgs2+cob+XWRj6PCMvEMqM hp/iHMepflnnValSV4sYPeS8OHIkXM2chHuS9YC+DwVKa45SltBaGcKCMyB9npSmgMBqW F9zkftAPnclVRQZ3qqkdnZm9IIE+CN/0sOIU8/dxH0EGbqkMHS5IVI7R5CpxQ00gvqoI2 GWwIllosJYm24aqQGFGmpPeFLY1Cx87pArhFXjhSloG5XjzezKWb/Jp+3bNQPxPqjWA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049711; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=d6FR6HAQ9AO7Unp6UklguJFR2DCaATWrss4/iaXwUaA=; b=VkjbfewPxCwSM8k+2u5MRlOsxaH419yhoHV71Pms8872hwbf3++cVKlriSYs0g7gMNWA kse/ylMams15SU31sfktjy+aytma5JnG57QPZGb56ODnW3OOwslXbIFw/Pn8qGhse8eA6 aM304cdW3XjcasRyQB6xS/ymcza9JwF2RRWAnaKtY7HqJ0XIoeEuNYMXrxlh2WefP61yT WdL5THVC6k+sP9jfUat5UW7mto/KQ7eqY6facQNyYu1g7hN7z31QwbnSGDdpy6tiAjlp9 4sh9v4hh+tgw9W16dT1qtm2OZDayy0nZH+xFR6tg/QedEa5+qTmrSMYNHjDbz+Ana5Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K7UQzg+s; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69B48606A685; Mon, 30 Nov 2026 14:41:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K7UQzg+s X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796049710; b=nAkI8jHmZ0UBFdYlLi7I8qFFxtXonRjhSPVgCZbi74jX/iMOAFwjVeY75C5wxdQNJetW v6+Ihaa1uAafyevYf4j0SicsrcXRBqISsGkqilAGELy1tzbPU3e1hjQvef3S3dpZPhYk5 0ssInYl54GVjm56oWxiLrseg2j4uF/oiDF0aQ7Ka/0x+yZfy6/mlnSp65durfbNLFLyV/ g4XnSRG7qiMPS+gD+XfUDT0mzy59q8dyv48utbFrLwMQjHPT9ngxyA4j9LbkTVwhdVVW4 03xQmRgz9IF5h/RHV8TYzrymZxQpoGx17p09ipqH5Szd2vYnbEVBby3pdpq9HicXk/g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796049710; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=d6FR6HAQ9AO7Unp6UklguJFR2DCaATWrss4/iaXwUaA=; b=bEFRaKdUiy1eNEbv9cM7roAbiNaAwzudLcVlz/MgZmJc5cXS539cgQWwBHmRlFPGP6YD bxXjXSrZtS87Sqi3sNUthRa+hK42eBHaWVHRwCagqEdtjNBk+izfyZjAatFldq7uT9kGs ImfDiCqLC92DARJykwKmFDE90IhJl+qX3wqAvzf1G5x5+eM6mQJVOETnN5KuxTe4arZpg YhtODfbYY2rZA1s1z9NycMkx+uz/TQKkyhim0rkhzCgtWU06NnE/RSJ6uxiuzl2SWPWtl ZnA5t7TfXFm429syaX06dMJp1tWAyfmCbxEx+6UDZgMTdG2UH3Dh3yX34dKegWzA2mQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K7UQzg+s; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A952606A32D; Mon, 30 Nov 2026 14:41:50 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0A631F00899; Mon, 30 Nov 2026 14:41:47 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796049709; bh=d6FR6HAQ9AO7Unp6UklguJFR2DCaATWrss4/iaXwUaA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=K7UQzg+selLjiC2j9oHNhk4IZUitF0N2yAfuZCTUP7n2UdBIIECepI+wz+KoUTwxh tNTFBiHzgwYVWQetXZXfrs1OtGkYg/V+mIO5KgNCo/W4tTfhZC9nyIllie4KPnXczG Qw39hqNT1kfqvGZCckUbA0ZJT63SzbC5pEZIlG4sUvulfm3uXoHfRGqcDyY3zaXXuP 38Q93gQfU4XeGlo7/sCznkXBjcKcgStgIo6wswPEDRv2y4G5iTEjlUc8ywqzybwFtp P5ylMvgukEm0Jk+WhqHK9gYXUYlHUNS77qNd+VevVYNXuLEfSfnbAlw6ce05ZTArIt PjV6XhW25shxw== X-Cc: netdev@vger.kernel.org, edumazet@kernel.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, tianyou.li@intel.com, wangyang.guo@intel.com X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261120061604.3676605-1-jiebin.sun@intel.com>