From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0A631F00899; Mon, 30 Nov 2026 14:41:47 +0000 (UTC) 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== Date: Mon, 30 Nov 2026 14:41:45 +0000 From: Simon Horman To: Jiebin Sun 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 Subject: Re: [PATCH net-next v2] net: dst: avoid false sharing between tclassid and __rcuref Message-ID: <20261130144145.GE804035@horms.kernel.org> References: <20261120061604.3676605-1-jiebin.sun@intel.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261120061604.3676605-1-jiebin.sun@intel.com> 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 > Suggested-by: Tim Chen > Reviewed-by: Tianyou Li > Reviewed-by: Wangyang Guo > Signed-off-by: Jiebin Sun > --- > 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