From patchwork Tue Oct 27 22:04:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 37025 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 0EE74B7BA4 for ; Wed, 28 Oct 2009 09:05:18 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756798AbZJ0WEn (ORCPT ); Tue, 27 Oct 2009 18:04:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932441AbZJ0WEm (ORCPT ); Tue, 27 Oct 2009 18:04:42 -0400 Received: from mail.vyatta.com ([76.74.103.46]:38974 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756786AbZJ0WEl (ORCPT ); Tue, 27 Oct 2009 18:04:41 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id 98A4F4F423B; Tue, 27 Oct 2009 15:04:42 -0700 (PDT) X-Virus-Scanned: amavisd-new at tahiti.vyatta.com Received: from mail.vyatta.com ([127.0.0.1]) by localhost (mail.vyatta.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IsPz-PRfH3PT; Tue, 27 Oct 2009 15:04:37 -0700 (PDT) Received: from nehalam (pool-74-107-146-78.ptldor.fios.verizon.net [74.107.146.78]) by mail.vyatta.com (Postfix) with ESMTP id 7FC014F400B; Tue, 27 Oct 2009 15:04:37 -0700 (PDT) Date: Tue, 27 Oct 2009 15:04:36 -0700 From: Stephen Hemminger To: Stephen Hemminger Cc: David Miller , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, eric.dumazet@gmail.com, akpm@linux-foundation.org, torvalds@linux-foundation.org, opurdila@ixiacom.com, viro@zeniv.linux.org.uk Subject: [PATCH] net: fold network name hash (v2) Message-ID: <20091027150436.56e673cd@nehalam> In-Reply-To: <20091027102251.244ee681@nehalam> References: <9986527.24561256620662709.JavaMail.root@tahiti.vyatta.com> <19864844.24581256620784317.JavaMail.root@tahiti.vyatta.com> <20091026.222428.80364204.davem@davemloft.net> <20091027102251.244ee681@nehalam> Organization: Vyatta X-Mailer: Claws Mail 3.6.1 (GTK+ 2.16.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The full_name_hash does not produce a value that is evenly distributed over the lower 8 bits. This causes name hash to be unbalanced with large number of names. There is a standard function to fold in upper bits so use that. This is independent of possible improvements to full_name_hash() in future. Signed-off-by: Stephen Hemminger --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/net/core/dev.c 2009-10-27 14:54:21.922563076 -0700 +++ b/net/core/dev.c 2009-10-27 15:04:16.733813459 -0700 @@ -86,6 +86,7 @@ #include #include #include +#include #include #include #include @@ -199,7 +200,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 & ((1 << NETDEV_HASHBITS) - 1)]; + return &net->dev_name_head[hash_long(hash, NETDEV_HASHBITS)]; } static inline struct hlist_head *dev_index_hash(struct net *net, int ifindex)