Netdev List
 help / color / mirror / Atom feed
From: Jakub Sitnicki <jakub@cloudflare.com>
To: Chris J Arges <carges@cloudflare.com>
Cc: David Ahern <dsahern@kernel.org>,
	 Ido Schimmel <idosch@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	 Simon Horman <horms@kernel.org>,  Shuah Khan <shuah@kernel.org>,
	 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org, kernel-team@cloudflare.com
Subject: Re: [PATCH RFC net-next 1/3] ipv4: hash uncached routes by device
Date: Tue, 01 Sep 2026 18:20:04 +0200	[thread overview]
Message-ID: <87qzjd2bbf.fsf@cloudflare.com> (raw)
In-Reply-To: <20260826-hash-bucket-route-lists-v1-1-fa9b9f30eb74@cloudflare.com> (Chris J. Arges's message of "Wed, 26 Aug 2026 15:20:07 -0500")

On Wed, Aug 26, 2026 at 03:20 PM -05, Chris J Arges wrote:
> rt_flush_dev() currently walks every per-CPU uncached route list for each
> device being removed. This repeatedly examines unrelated routes and makes
> teardown increasingly expensive as the number of devices grows.
>
> Replace each per-CPU list with 64 hash buckets keyed by the route's
> netdevice. Keep the owning-list pointer in dst_entry so route removal
> remains unchanged, while device teardown only walks the matching bucket on
> each CPU. Hash collisions are filtered by the existing device comparison.
>
> Signed-off-by: Chris J Arges <carges@cloudflare.com>
> ---
>  net/ipv4/route.c | 36 +++++++++++++++++++++++++++++-------
>  1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 604cc51dfd9b..3f9bc1ec72cc 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -74,6 +74,7 @@
>  #include <linux/init.h>
>  #include <linux/skbuff.h>
>  #include <linux/inetdevice.h>
> +#include <linux/hash.h>
>  #include <linux/igmp.h>
>  #include <linux/pkt_sched.h>
>  #include <linux/mroute.h>
> @@ -1552,11 +1553,22 @@ struct uncached_list {
>  	struct list_head	head;
>  };
>  
> -static DEFINE_PER_CPU_ALIGNED(struct uncached_list, rt_uncached_list);
> +#define RT_UNCACHED_HASH_BITS	6
> +#define RT_UNCACHED_HASH_SIZE	BIT(RT_UNCACHED_HASH_BITS)


Consider making RT[6]_UNCACHED_HASH_BITS a build time tunable.
We've had a case in the past where we had to carry a custom patch [1]
because hash size was hardcoded.

[1] https://lore.kernel.org/netdev/1295041688-16550-1-git-send-email-wsommerfeld@google.com/

> +
> +struct uncached_table {
> +	struct uncached_list buckets[RT_UNCACHED_HASH_SIZE];
> +};
> +
> +static DEFINE_PER_CPU_ALIGNED(struct uncached_table, rt_uncached_table);

[...]

  reply	other threads:[~2026-09-01 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 20:20 [PATCH RFC net-next 0/3] net: hash uncached route lists by device Chris J Arges
2026-08-26 20:20 ` [PATCH RFC net-next 1/3] ipv4: hash uncached routes " Chris J Arges
2026-09-01 16:20   ` Jakub Sitnicki [this message]
2026-08-26 20:20 ` [PATCH RFC net-next 2/3] ipv6: " Chris J Arges
2026-08-26 20:20 ` [PATCH RFC net-next 3/3] selftests: net: cover IPv6 uncached route device mismatch Chris J Arges

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=87qzjd2bbf.fsf@cloudflare.com \
    --to=jakub@cloudflare.com \
    --cc=carges@cloudflare.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /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