mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: jiebin.sun@intel.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com,
	tianyou.li@intel.com, wangyang.guo@intel.com
Subject: Re: [PATCH] net: dst: Avoid false sharing between tclassid and __rcuref
Date: Wed, 18 Nov 2026 16:58:44 +0000	[thread overview]
Message-ID: <179502112428.3136.7381445616366581807@kernel.org> (raw)
In-Reply-To: <20261116015732.2744688-1-jiebin.sun@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch moves tclassid after lwtstate in struct dst_entry
  (include/net/dst.h), which makes sizeof(struct dst_entry) on x86-64…

--

net: dst: Avoid false sharing between tclassid and __rcuref

On 64-bit builds, this commit moves dst_entry::tclassid to sit after
lwtstate, so it no longer shares a cache line with __rcuref. On x86-64,
struct dst_entry grows from 136 to 144 bytes. The commit message says the
SLAB_HWCACHE_ALIGN caches used for rtable and rt6_info absorb the growth.

> diff --git a/include/net/dst.h b/include/net/dst.h
> index dbedfe72e1fd1..f01cfb42f97c1 100644
> --- a/include/net/dst.h
> +++ b/include/net/dst.h

[ ... ]

> @@ -94,6 +94,7 @@ struct dst_entry {
>  	struct uncached_list	*rt_uncached_list;
>  #ifdef CONFIG_64BIT
>  	struct lwtunnel_state   *lwtstate;
> +	__u32			tclassid;
>  #endif
>  };

[Severity: Medium]
The commit message says:

  However, both struct rtable and struct rt6_info are allocated from slab
  caches with SLAB_HWCACHE_ALIGN, so the per-object allocation sizes
  remain unchanged at 192 bytes for rtable and 256 bytes for rt6_info.

Does the same hold for struct metadata_dst? It also embeds dst_entry, but
it is allocated with kmalloc and not from an aligned cache:

include/net/dst_metadata.h:
struct metadata_dst {
	struct dst_entry		dst;
	enum metadata_type		type;
	union {
		struct ip_tunnel_info	tun_info;
		...
	} u;
};

The union is 16-byte aligned because ip_tunnel_info::options[] is marked
__aligned_largest. So the 8-byte growth of dst_entry becomes 16 bytes
here. On x86-64 with CONFIG_DST_CACHE=y, sizeof(struct metadata_dst) goes
from 240 to 256.

metadata_dst_alloc() then allocates that size plus the options length:

net/core/dst.c:metadata_dst_alloc() {
	...
	md_dst = kmalloc_flex(*md_dst, u.tun_info.options, optslen, flags);
	...
}

With the new 256-byte base, does any optslen > 0 now land in kmalloc-512
instead of kmalloc-256?

On a collect_md device, vxlan_rcv() does this for every received packet:

	tun_dst = udp_tun_rx_dst(skb, vxlan_get_sk_family(vs), flags,
				 key32_to_tunnel_id(vni), sizeof(*md));

That reaches udp_tun_rx_dst()->__ip_tun_set_dst()->metadata_dst_alloc()
with GFP_ATOMIC and optslen = sizeof(struct vxlan_metadata), which is 4.
Before this patch the allocation is 244 bytes (kmalloc-256). After it,
the allocation is 260 bytes (kmalloc-512).

geneve_rx() passes gnvh->opt_len * 4. Before the patch, options of up to
16 bytes still fit in kmalloc-256. After it, would any Geneve option at
all push the allocation into kmalloc-512?

The growth also applies to 64-bit kernels built with
CONFIG_IP_ROUTE_CLASSID=n, where nothing reads tclassid on the hot path.

Could the commit message cover the metadata_dst case? Alternatively,
could the layout be arranged so that metadata_dst stays within the
256-byte kmalloc bucket?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116015732.2744688-1-jiebin.sun%40intel.com

  reply	other threads:[~2026-11-18 16:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  1:57 Jiebin Sun
2026-11-18 16:58 ` netdev-bot+sashiko [this message]
2026-11-18 17:15 ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179502112428.3136.7381445616366581807@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jiebin.sun@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tianyou.li@intel.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=wangyang.guo@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®