Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3602960imm; Tue, 29 May 2018 10:01:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpbbnPXH0l40A9NYy3M120Pm0TJ+Lcm3i5e7NXIiKHfgszhzz7s6CSP/F9iv+rI/F1TERLv X-Received: by 2002:a62:859a:: with SMTP id m26-v6mr17999460pfk.247.1527613274197; Tue, 29 May 2018 10:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527613274; cv=none; d=google.com; s=arc-20160816; b=lDppbaS1ffBD2Ey4/rMnBm8DPaV/k1PJt1jakbVJPBR5TeExT6CMuY0ZFu0A8huraa orZkMRflKMiXR+HKorL3rnWC4wVnjWa3yKeA04MPQj0JI48dL02Fmtu5ayi2qvhz9qCJ rRobZvFwlYG599M1nO61hNSUBU4x8VAFMRb65kvVCK9GKkiPI1TBXfadgrSdRoT2mlaA PjxkUCadDNabMQ6NOTwaQ4sawyRTMLpA1d4UeiMUEMFrrPIel6sw1MbcDQ2Ike3WWd/9 k0rbWQjzUfmMDI479xyza7jXIlzRODnlffyB0eWh/Lhm53wYhQ9LlVq9/fqB5Fdc85mw YL3g== 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=RWiySKv/O9unN4wZV/HAYO7RdqkcnbFtBLWvDT3fkyw=; b=AbdPUBvg0mRJXpwqYYEbL4bqcMFfr41jpLlcI8/LF4D4+IqNnFtG5b+v8z1c2/QNSN ePNykheWQCeHj7kgugn/q+Ty5JGITxoQ/ce+okjfFEcvrciyDHSqlS9s+WiOcwwOVLTm OXGOpMM4qnQwDMnCUU9jZjg+gw1kPjmDmAPfVuE47Ix6Dj1f3dI3vfSSJfUhLHgEiF1r m4mUEyXtffqe23FSa6XLxLUzS5yiD+GRaAYslltbS2FF3Ms6NtgztaUtcWrLpjCRiz8C u1zKQTmfhPdbSzMG5LoT9Yae7EzKjX1GMHU5Y7U17q5Tor9+3Mc0Pm2twLd/aGSalnkt oRqg== 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 z13-v6si33489678pfc.128.2018.05.29.10.00.59; Tue, 29 May 2018 10:01:14 -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 S965329AbeE2Q7Z (ORCPT + 99 others); Tue, 29 May 2018 12:59:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:39355 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965094AbeE2Q7W (ORCPT ); Tue, 29 May 2018 12:59:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1C35BAD0E; Tue, 29 May 2018 16:59:21 +0000 (UTC) Date: Tue, 29 May 2018 09:42:31 -0700 From: Davidlohr Bueso To: Herbert Xu Cc: akpm@linux-foundation.org, torvalds@linux-foundation.org, tgraf@suug.ch, manfred@colorfullife.com, guillaume.knispel@supersonicimagine.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 2/6] lib/rhashtable: guarantee initial hashtable allocation Message-ID: <20180529164231.yoj57nqhghtmy54v@linux-n805> References: <20180524211135.27760-1-dave@stgolabs.net> <20180524211135.27760-3-dave@stgolabs.net> <20180528100237.needq2u5e3v2n642@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180528100237.needq2u5e3v2n642@gondor.apana.org.au> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 May 2018, Herbert Xu wrote: >On Thu, May 24, 2018 at 02:11:31PM -0700, Davidlohr Bueso wrote: >> >> + /* >> + * This is api initialization and thus we need to guarantee the >> + * initial rhashtable allocation. Upon failure, retry with a >> + * smallest possible size, otherwise we exhaust our options with >> + * __GFP_NOFAIL. >> + */ >> tbl = bucket_table_alloc(ht, size, GFP_KERNEL); >> - if (tbl == NULL) >> - return -ENOMEM; >> + if (unlikely(tbl == NULL)) { >> + size = HASH_MIN_SIZE; > >You should also take min_size into account. Yes I know the current >code ignores it unless you also set nelem_hint. But that's just a >bug. For the sake of simplicity, Linus suggested directly using HASH_MIN_SIZE such that we have a single fallback. Thanks, Davidlohr