From patchwork Fri Jan 13 16:36:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri Sivanich X-Patchwork-Id: 135922 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.180.67]) by ozlabs.org (Postfix) with ESMTP id D0248B6F62 for ; Sat, 14 Jan 2012 03:36:53 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755825Ab2AMQgr (ORCPT ); Fri, 13 Jan 2012 11:36:47 -0500 Received: from relay3.sgi.com ([192.48.152.1]:40834 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751778Ab2AMQgq (ORCPT ); Fri, 13 Jan 2012 11:36:46 -0500 Received: from estes.americas.sgi.com (estes.americas.sgi.com [128.162.236.10]) by relay3.corp.sgi.com (Postfix) with ESMTP id 58EC0AC009; Fri, 13 Jan 2012 08:36:43 -0800 (PST) Received: from santana (santana.americas.sgi.com [128.162.232.69]) by estes.americas.sgi.com (Postfix) with ESMTP id DB3C270016CD; Fri, 13 Jan 2012 10:36:42 -0600 (CST) Received: by santana (Postfix, from userid 30782) id 584144741B9; Fri, 13 Jan 2012 10:36:42 -0600 (CST) Date: Fri, 13 Jan 2012 10:36:42 -0600 From: Dimitri Sivanich To: Al Viro Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy , "Paul E. McKenney" , Paul Gortmaker , Andrew Morton , Jiri Kosina , Avi Kivity , linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH] Fix panic in __d_lookup with high dentry hashtable counts Message-ID: <20120113163642.GB25788@sgi.com> References: <20120113155237.GA25103@sgi.com> <20120113162236.GK23916@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120113162236.GK23916@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Jan 13, 2012 at 04:22:36PM +0000, Al Viro wrote: > On Fri, Jan 13, 2012 at 09:52:37AM -0600, Dimitri Sivanich wrote: > > When the number of dentry cache hash table entries gets too high > > (2147483648 entries), use of a signed integer in the initialization > > loop prevents the dentry_hashtable from getting initialized, resulting > > in a panic in __d_lookup. Fixing this in dcache_init and a few other > > spots for consistency. > > > static void __init dcache_init(void) > > { > > - int loop; > > + long loop; > > You've got to be kidding. Note that D_HASHMASK is at most 32bit. Use > of long here is an overkill and so's 2^31 hash buckets (that's what, > 16Gb in hash list heads alone? What kind of average chain length do > you expect, BTW?) Yes, long might be overkill right now, but the code is all __init time code. I don't have numbers showing average chain length at this point, I was simply fixing this one end case > > Can alloc_large_system_hash() produce the horrors that large, anyway? On a 16TB system, alloc_large_system_hash() produces 2^31 hash buckets, yes. Would simply capping the value in alloc_large_system_hash() be more palatable? Something like the following? --- 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 Index: linux/mm/page_alloc.c =================================================================== --- linux.orig/mm/page_alloc.c +++ linux/mm/page_alloc.c @@ -5257,6 +5257,7 @@ void *__init alloc_large_system_hash(con if (max == 0) { max = ((unsigned long long)nr_all_pages << PAGE_SHIFT) >> 4; do_div(max, bucketsize); + max = min(max, 1ULL << 30); } if (numentries > max)