From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Willem de Bruijn <willemb@google.com>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 1/4] net: rps: change skb_flow_limit() hash function
Date: Mon, 7 Apr 2025 16:35:59 +0000 [thread overview]
Message-ID: <20250407163602.170356-2-edumazet@google.com> (raw)
In-Reply-To: <20250407163602.170356-1-edumazet@google.com>
As explained in commit f3483c8e1da6 ("net: rfs: hash function change"),
masking low order bits of skb_get_hash(skb) has low entropy.
A NIC with 32 RX queues uses the 5 low order bits of rss key
to select a queue. This means all packets landing to a given
queue share the same 5 low order bits.
Switch to hash_32() to reduce hash collisions.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/core/dev.c | 2 +-
net/core/dev.h | 2 +-
net/core/sysctl_net_core.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 0608605cfc24..f674236f34be 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5038,7 +5038,7 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)
rcu_read_lock();
fl = rcu_dereference(sd->flow_limit);
if (fl) {
- new_flow = skb_get_hash(skb) & (fl->num_buckets - 1);
+ new_flow = hash_32(skb_get_hash(skb), fl->log_buckets);
old_flow = fl->history[fl->history_head];
fl->history[fl->history_head] = new_flow;
diff --git a/net/core/dev.h b/net/core/dev.h
index 7ee203395d8e..b1cd44b5f009 100644
--- a/net/core/dev.h
+++ b/net/core/dev.h
@@ -16,7 +16,7 @@ struct cpumask;
#define FLOW_LIMIT_HISTORY (1 << 7) /* must be ^2 and !overflow buckets */
struct sd_flow_limit {
u64 count;
- unsigned int num_buckets;
+ u8 log_buckets;
unsigned int history_head;
u16 history[FLOW_LIMIT_HISTORY];
u8 buckets[];
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index c7769ee0d9c5..5cfe76ede523 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -248,7 +248,7 @@ static int flow_limit_cpu_sysctl(const struct ctl_table *table, int write,
ret = -ENOMEM;
goto write_unlock;
}
- cur->num_buckets = netdev_flow_limit_table_len;
+ cur->log_buckets = ilog2(netdev_flow_limit_table_len);
rcu_assign_pointer(sd->flow_limit, cur);
}
}
--
2.49.0.504.g3bcea36a83-goog
next prev parent reply other threads:[~2025-04-07 16:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 16:35 [PATCH net-next 0/4] rps: misc changes Eric Dumazet
2025-04-07 16:35 ` Eric Dumazet [this message]
2025-04-07 18:53 ` [PATCH net-next 1/4] net: rps: change skb_flow_limit() hash function Willem de Bruijn
2025-04-07 16:36 ` [PATCH net-next 2/4] net: rps: annotate data-races around (struct sd_flow_limit)->count Eric Dumazet
2025-04-07 18:55 ` Willem de Bruijn
2025-04-07 16:36 ` [PATCH net-next 3/4] net: add data-race annotations in softnet_seq_show() Eric Dumazet
2025-04-07 19:04 ` Willem de Bruijn
2025-04-07 16:36 ` [PATCH net-next 4/4] net: rps: remove kfree_rcu_mightsleep() use Eric Dumazet
2025-04-07 19:36 ` Willem de Bruijn
2025-04-08 20:08 ` [PATCH net-next 0/4] rps: misc changes patchwork-bot+netdevbpf
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=20250407163602.170356-2-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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;
as well as URLs for NNTP newsgroup(s).