* [PATCH net-next] netns: get more entropy from net_hash_mix()
@ 2018-06-22 23:27 Eric Dumazet
2018-06-23 2:00 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2018-06-22 23:27 UTC (permalink / raw)
To: David S . Miller; +Cc: netdev, Eric Dumazet, Eric Dumazet
struct net are effectively allocated from order-1 pages on x86,
with one object per slab, meaning that the 13 low order bits
of their addresses are zero.
Once shifted by L1_CACHE_SHIFT, this leaves 7 zero-bits,
meaning that net_hash_mix() does not help spreading
objects on various hash tables.
For example, TCP listen table has 32 buckets, meaning that
all netns use the same bucket for port 80 or port 443.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Maciej Żenczykowski <maze@google.com>
---
include/net/netns/hash.h | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/include/net/netns/hash.h b/include/net/netns/hash.h
index 24c78183a4c262e086c29cde1e61b7f397d8bab0..16a842456189f2fc1a3363685b5dd4310a32b2b8 100644
--- a/include/net/netns/hash.h
+++ b/include/net/netns/hash.h
@@ -9,12 +9,7 @@ struct net;
static inline u32 net_hash_mix(const struct net *net)
{
#ifdef CONFIG_NET_NS
- /*
- * shift this right to eliminate bits, that are
- * always zeroed
- */
-
- return (u32)(((unsigned long)net) >> L1_CACHE_SHIFT);
+ return (u32)(((unsigned long)net) >> ilog2(sizeof(*net)));
#else
return 0;
#endif
--
2.18.0.rc2.346.g013aa6912e-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] netns: get more entropy from net_hash_mix()
2018-06-22 23:27 [PATCH net-next] netns: get more entropy from net_hash_mix() Eric Dumazet
@ 2018-06-23 2:00 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-06-23 2:00 UTC (permalink / raw)
To: edumazet; +Cc: netdev, eric.dumazet
From: Eric Dumazet <edumazet@google.com>
Date: Fri, 22 Jun 2018 16:27:47 -0700
> struct net are effectively allocated from order-1 pages on x86,
> with one object per slab, meaning that the 13 low order bits
> of their addresses are zero.
>
> Once shifted by L1_CACHE_SHIFT, this leaves 7 zero-bits,
> meaning that net_hash_mix() does not help spreading
> objects on various hash tables.
>
> For example, TCP listen table has 32 buckets, meaning that
> all netns use the same bucket for port 80 or port 443.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Maciej Żenczykowski <maze@google.com>
Good catch, applied, thanks Eric.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-23 2:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-22 23:27 [PATCH net-next] netns: get more entropy from net_hash_mix() Eric Dumazet
2018-06-23 2:00 ` David Miller
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).