Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1327244imm; Fri, 1 Jun 2018 21:42:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKx++W7yFi3HYf8WGuNAEYtuEmpN9g563uZ0uwT6RdIrOxG86jKGvhG9RiOKCZ5UAbzkk7l X-Received: by 2002:a17:902:b48f:: with SMTP id y15-v6mr2882001plr.261.1527914572168; Fri, 01 Jun 2018 21:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527914572; cv=none; d=google.com; s=arc-20160816; b=asKsbjJI+guclo5JydPKDldfTYuCWT/TLdi6dHTc4ZQVdkKrIuOuiR6CwOevCyLJn2 QiWjTmFizQjJcc/Hi0i+IVWRkQlO9LhAyMP9xAvaOXp77979/FctQzKdw4NpmnCNpBCe xAwMza3qaID803HXxRFNUCCl2Sf6+jdvM8wd9hPA3L+aZpbvdCJiuAN3bo92Ae2tbLnR GCePZMsFpooqKCOFYPaktaCwNd2VV4AHiZ6Ifmy7ipnlyc/byg8KBO1N32TSNc6Y605W wWpE68S6KFeQUONTsAeNXWaxa20b5dmR1eRAoM7mvyrzjgBjT8riC1W3LNIuku16A1zO jeYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=B+bsQK053O3j6sbT6vZQ6HwBhrpABQdFuDfyIO8ZYIA=; b=Pva4FVl2DxPohC0NiENxffyhgeRbZLAFoRHI7i510YXSbv6Srowo8KrwPaSb7SA85f 3j/aOUI6yDzailChjZV8F2ztT+sYfWS+UWb++t9/dxVNXy6CkdiOVjNmw/frrA3tZzlS abARtZmk4mMQZ0Wnpx94OzAWvoOeUxDmW+nyheenZvNEh08zt2eHAhABQyvuqD+FT49E y8QkryJguWdCjqFClKHDOoQx45Gm2sut31I90KtwmpOE1+B05DViOZOyBMURPJuAql62 FwbKwyN+OgFko3h33ZcYJrBkMnnFrosaYNn1L9VE8j0Vyc/KUXs/ZvtzPfq9TTEgLjCG 62zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k10-v6si31911062pgc.299.2018.06.01.21.42.36; Fri, 01 Jun 2018 21:42:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750964AbeFBEmI (ORCPT + 99 others); Sat, 2 Jun 2018 00:42:08 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:58368 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750748AbeFBEmF (ORCPT ); Sat, 2 Jun 2018 00:42:05 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1fOyMU-0001zG-Jg; Sat, 02 Jun 2018 12:41:54 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1fOyMQ-0002Qj-BH; Sat, 02 Jun 2018 12:41:50 +0800 Date: Sat, 2 Jun 2018 12:41:50 +0800 From: Herbert Xu To: Davidlohr Bueso Cc: akpm@linux-foundation.org, torvalds@linux-foundation.org, tgraf@suug.ch, manfred@colorfullife.com, mhocko@kernel.org, guillaume.knispel@supersonicimagine.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 2/5] lib/rhashtable: guarantee initial hashtable allocation Message-ID: <20180602044150.xpazuhpxbwt37xmu@gondor.apana.org.au> References: <20180601160125.30031-1-dave@stgolabs.net> <20180601160125.30031-3-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180601160125.30031-3-dave@stgolabs.net> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 01, 2018 at 09:01:22AM -0700, Davidlohr Bueso wrote: > > diff --git a/lib/rhashtable.c b/lib/rhashtable.c > index 05a4b1b8b8ce..ae17da6f0c75 100644 > --- a/lib/rhashtable.c > +++ b/lib/rhashtable.c > @@ -175,7 +175,7 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht, > int i; > > size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]); > - if (gfp != GFP_KERNEL) > + if ((gfp & ~__GFP_NOFAIL) != GFP_KERNEL) > tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY); > else > tbl = kvzalloc(size, gfp); There's another GFP_KERNEL check in this function that needs the same treatment. > @@ -1067,9 +1067,16 @@ int rhashtable_init(struct rhashtable *ht, > } > } > > + /* > + * This is api initialization and thus we need to guarantee the > + * initial rhashtable allocation. Upon failure, retry with the > + * smallest possible size with __GFP_NOFAIL semantics. > + */ > tbl = bucket_table_alloc(ht, size, GFP_KERNEL); > - if (tbl == NULL) > - return -ENOMEM; > + if (unlikely(tbl == NULL)) { > + size = min_t(u16, ht->p.min_size, HASH_MIN_SIZE); You mean max_t? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt