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=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 422D8C433DF for ; Tue, 7 Jul 2020 08:02:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 050292065F for ; Tue, 7 Jul 2020 08:02:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 050292065F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AC4E46B0095; Tue, 7 Jul 2020 04:02:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4F686B0098; Tue, 7 Jul 2020 04:02:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 918298D0006; Tue, 7 Jul 2020 04:02:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id 767686B0095 for ; Tue, 7 Jul 2020 04:02:06 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3AA7B181AEF09 for ; Tue, 7 Jul 2020 08:02:06 +0000 (UTC) X-FDA: 77010536652.22.lunch20_5a15e1526eb2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 0E82E18038E60 for ; Tue, 7 Jul 2020 08:02:06 +0000 (UTC) X-HE-Tag: lunch20_5a15e1526eb2 X-Filterd-Recvd-Size: 4722 Received: from huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 08:02:05 +0000 (UTC) Received: from dggemi402-hub.china.huawei.com (unknown [172.30.72.54]) by Forcepoint Email with ESMTP id 0237E19AA39B59FC9F90; Tue, 7 Jul 2020 16:01:59 +0800 (CST) Received: from DGGEMI525-MBS.china.huawei.com ([169.254.6.177]) by dggemi402-hub.china.huawei.com ([10.3.17.135]) with mapi id 14.03.0487.000; Tue, 7 Jul 2020 16:01:53 +0800 From: "Song Bao Hua (Barry Song)" To: Mike Rapoport , Roman Gushchin CC: "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Linuxarm , Mike Kravetz , Jonathan Cameron Subject: RE: [PATCH v2] mm/hugetlb: avoid hardcoding while checking if cma is enable Thread-Topic: [PATCH v2] mm/hugetlb: avoid hardcoding while checking if cma is enable Thread-Index: AQHWVAymBZ1xGYd9mEm2J3l6HgJP0Kj68WaAgABDWoCAAIvS8A== Date: Tue, 7 Jul 2020 08:01:52 +0000 Message-ID: References: <20200707031156.29932-1-song.bao.hua@hisilicon.com> <20200707033631.GA164297@carbon.dhcp.thefacebook.com> <20200707073735.GB9449@kernel.org> In-Reply-To: <20200707073735.GB9449@kernel.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.126.200.119] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 0E82E18038E60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: > -----Original Message----- > From: Mike Rapoport [mailto:rppt@kernel.org] > Sent: Tuesday, July 7, 2020 7:38 PM > To: Roman Gushchin > Cc: Song Bao Hua (Barry Song) ; > akpm@linux-foundation.org; linux-mm@kvack.org; > linux-kernel@vger.kernel.org; Linuxarm ; Mike > Kravetz ; Jonathan Cameron > > Subject: Re: [PATCH v2] mm/hugetlb: avoid hardcoding while checking if cm= a > is enable >=20 > On Mon, Jul 06, 2020 at 08:36:31PM -0700, Roman Gushchin wrote: > > On Tue, Jul 07, 2020 at 03:11:56PM +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 hugep= ages > using cma") > > > Cc: Roman Gushchin > > > Cc: Mike Kravetz > > > Cc: Jonathan Cameron > > > Signed-off-by: Barry Song > > > --- > > > -v2: add hugetlb_cma_enabled() helper to improve readability accordi= ng > to Roman > > > > > > mm/hugetlb.c | 16 +++++++++++++++- > > > 1 file changed, 15 insertions(+), 1 deletion(-) > > > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > > index 57ece74e3aae..d5e98ed86bb9 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) > > > +{ > > > + if (IS_ENABLED(CONFIG_CMA)) { > > > + int node; > > > + > > > + for_each_online_node(node) { > > > + if (hugetlb_cma[node]) > > > + return true; > > > + } > > > + } > > > + > > > + return false; > > > +} > > > + > > > > Can you, please, change it to a more canonical > > > > #ifdef CONFIG_CMA > > bool __init hugetlb_cma_enabled(void) > > { > > int node; > > > > for_each_online_node(node) > > if (hugetlb_cma[node]) > > return true; > > > > return false; > > } > > #else > > bool __init hugetlb_cma_enabled(void) > > { > > return false; > > } > > #endif > > > > or maybe just > > > > 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; > > } >=20 > This one please. Yep. Patch v3 is just the one you prefer: https://marc.info/?l=3Dlinux-mm&m=3D159409465228477&w=3D2 >=20 > > ? > > > > Please, feel free to add > > Acked-by: Roman Gushchin after that. > > > > Thank you! > > >=20 > -- > Sincerely yours, > Mike. Thanks Barry