* [PATCH] netdev: fold name hash properly (v3)
@ 2009-11-10 17:20 Stephen Hemminger
2009-11-10 17:37 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2009-11-10 17:20 UTC (permalink / raw)
To: David Miller; +Cc: netdev
The full_name_hash function does not produce well distributed values in
the lower bits, so most code uses hash_32() to fold it. This is really
a bug introduced when name hashing was added, back in 2.5 when I added
name hashing.
hash_32 is all that is needed since full_name_hash returns unsigned int
which is only 32 bits on 64 bit platforms.
Also, there is no point in using hash_32 on ifindex, because the is naturally
sequential and usually well distributed.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
Patch against net-next-2.6
--- a/net/core/dev.c 2009-11-09 22:19:08.731481514 -0800
+++ b/net/core/dev.c 2009-11-10 08:42:23.755003727 -0800
@@ -79,6 +79,7 @@
#include <linux/cpu.h>
#include <linux/types.h>
#include <linux/kernel.h>
+#include <linux/hash.h>
#include <linux/sched.h>
#include <linux/mutex.h>
#include <linux/string.h>
@@ -196,7 +197,7 @@ EXPORT_SYMBOL(dev_base_lock);
static inline struct hlist_head *dev_name_hash(struct net *net, const char *name)
{
unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ));
- return &net->dev_name_head[hash & (NETDEV_HASHENTRIES - 1)];
+ return &net->dev_name_head[hash_32(hash, NETDEV_HASHBITS)];
}
static inline struct hlist_head *dev_index_hash(struct net *net, int ifindex)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] netdev: fold name hash properly (v3)
2009-11-10 17:20 [PATCH] netdev: fold name hash properly (v3) Stephen Hemminger
@ 2009-11-10 17:37 ` Eric Dumazet
2009-11-12 3:58 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2009-11-10 17:37 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Stephen Hemminger a écrit :
> The full_name_hash function does not produce well distributed values in
> the lower bits, so most code uses hash_32() to fold it. This is really
> a bug introduced when name hashing was added, back in 2.5 when I added
> name hashing.
>
> hash_32 is all that is needed since full_name_hash returns unsigned int
> which is only 32 bits on 64 bit platforms.
>
> Also, there is no point in using hash_32 on ifindex, because the is naturally
> sequential and usually well distributed.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Thanks Stephen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] netdev: fold name hash properly (v3)
2009-11-10 17:37 ` Eric Dumazet
@ 2009-11-12 3:58 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2009-11-12 3:58 UTC (permalink / raw)
To: eric.dumazet; +Cc: shemminger, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 10 Nov 2009 18:37:11 +0100
> Stephen Hemminger a écrit :
>> The full_name_hash function does not produce well distributed values in
>> the lower bits, so most code uses hash_32() to fold it. This is really
>> a bug introduced when name hashing was added, back in 2.5 when I added
>> name hashing.
>>
>> hash_32 is all that is needed since full_name_hash returns unsigned int
>> which is only 32 bits on 64 bit platforms.
>>
>> Also, there is no point in using hash_32 on ifindex, because the is naturally
>> sequential and usually well distributed.
>>
>> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>>
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-12 3:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-10 17:20 [PATCH] netdev: fold name hash properly (v3) Stephen Hemminger
2009-11-10 17:37 ` Eric Dumazet
2009-11-12 3:58 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.