From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 362EEC433DF for ; Tue, 7 Jul 2020 08:18:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC2B7206F6 for ; Tue, 7 Jul 2020 08:18:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="JBW7R8NI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC2B7206F6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6C7FA6B009D; Tue, 7 Jul 2020 04:18:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 678026B009E; Tue, 7 Jul 2020 04:18:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 568776B009F; Tue, 7 Jul 2020 04:18:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 423BB6B009D for ; Tue, 7 Jul 2020 04:18:20 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D2B21181AEF10 for ; Tue, 7 Jul 2020 08:18:19 +0000 (UTC) X-FDA: 77010577518.30.table51_290177726eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id ACB46180B3C8B for ; Tue, 7 Jul 2020 08:18:19 +0000 (UTC) X-HE-Tag: table51_290177726eb2 X-Filterd-Recvd-Size: 3299 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 08:18:19 +0000 (UTC) Received: from kernel.org (unknown [87.71.40.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D7FAA206C3; Tue, 7 Jul 2020 08:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594109898; bh=+PF6hJTZmNi14SpZ7fetiogdxipMfdQWwB9JQZMG5fs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JBW7R8NI69CCof8isf8K7twVpVD+N7D5tEzJVDKsOa3fvtZegYQbCN7j8nuCiQgm0 PJQ9FUMdnkWcpgfpqu6Ufw+rVahoD0au1RDqJEf844gVWN9ImvL45hxvpeASckkxZC dKU+xpzNLtPUNCfL09P9X4A2gF9JfbEyHmbbKHEQ= Date: Tue, 7 Jul 2020 11:18:11 +0300 From: Mike Rapoport To: Barry Song Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, Mike Kravetz , Jonathan Cameron , Roman Gushchin Subject: Re: [PATCH v3] mm/hugetlb: avoid hardcoding while checking if cma is enable Message-ID: <20200707081811.GD9449@kernel.org> References: <20200707040204.30132-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707040204.30132-1-song.bao.hua@hisilicon.com> X-Rspamd-Queue-Id: ACB46180B3C8B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Jul 07, 2020 at 04:02:04PM +1200, Barry Song wrote: > hugetlb_cma[0] can be NULL due to various reasons, for example, node0 has > no memory. so NULL hugetlb_cma[0] doesn't necessarily mean cma is not > enabled. gigantic pages might have been reserved on other nodes. > > Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma") > Cc: Mike Kravetz > Cc: Jonathan Cameron > Acked-by: Roman Gushchin > Signed-off-by: Barry Song Acked-by: Mike Rapoport > --- > -v3: add acked-by; make code more canonical > > mm/hugetlb.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 57ece74e3aae..d293c823121e 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -2546,6 +2546,20 @@ static void __init gather_bootmem_prealloc(void) > } > } > > +bool __init hugetlb_cma_enabled(void) > +{ > +#ifdef CONFIG_CMA > + int node; > + > + for_each_online_node(node) { > + if (hugetlb_cma[node]) > + return true; > + } > +#endif > + > + return false; > +} > + > static void __init hugetlb_hstate_alloc_pages(struct hstate *h) > { > unsigned long i; > @@ -2571,7 +2585,7 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h) > > for (i = 0; i < h->max_huge_pages; ++i) { > if (hstate_is_gigantic(h)) { > - if (IS_ENABLED(CONFIG_CMA) && hugetlb_cma[0]) { > + if (hugetlb_cma_enabled()) { > pr_warn_once("HugeTLB: hugetlb_cma is enabled, skip boot time allocation\n"); > break; > } > -- > 2.27.0 > > > -- Sincerely yours, Mike.