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=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 2C635C433E0 for ; Thu, 9 Jul 2020 18:58:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D326220774 for ; Thu, 9 Jul 2020 18:58:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="kDRGkOob" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D326220774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 522186B0002; Thu, 9 Jul 2020 14:58:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D3426B0005; Thu, 9 Jul 2020 14:58:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E8F46B0006; Thu, 9 Jul 2020 14:58:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 2787F6B0002 for ; Thu, 9 Jul 2020 14:58:28 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B06592C07 for ; Thu, 9 Jul 2020 18:58:27 +0000 (UTC) X-FDA: 77019448254.26.rock42_300dfba26ec8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 8DD051804B655 for ; Thu, 9 Jul 2020 18:58:27 +0000 (UTC) X-HE-Tag: rock42_300dfba26ec8 X-Filterd-Recvd-Size: 5333 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 9 Jul 2020 18:58:26 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 069IuwdK144135; Thu, 9 Jul 2020 18:58:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=lAxMFBw8USCvsXQY7vici6b5KYUftXCRohJuxNlvVx0=; b=kDRGkOobmtj7/7wczdW3a1ASfm9DA581KShS++JghppkZPqYkP00siEAyfqrizahVFHF HWI19oHZM5pHS58kW2e+NuSJnXqRujD3daMWRUiFArmal1DA/duwONtm7vQ0izIXGzjf 5nLnV4x/SnfsVa/K1BXkCtIvNezetROpCBrAA3pIa0ED9xvl3rG6Mf8ekskajfAs+ZIB ktR8nbf33GWhV4mslKDDMbWs/I0zdIpdX4SbsSH56ZRlK18cZl0X0HHUAn0lLM7i4WWV up+clViGLeEdi/NK+IxjJhm44R97b3Vmd61wPZpedHJPBBMJUCkrtTadxrbRG2jzs+Nm +A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 325y0akmc5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 09 Jul 2020 18:58:15 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 069IdNxV184628; Thu, 9 Jul 2020 18:58:15 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 325k3hryqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Jul 2020 18:58:15 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 069IwCel013417; Thu, 9 Jul 2020 18:58:12 GMT Received: from [192.168.2.112] (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 Jul 2020 11:58:12 -0700 Subject: Re: [PATCH v3] mm/hugetlb: avoid hardcoding while checking if cma is enable To: "Song Bao Hua (Barry Song)" , Roman Gushchin Cc: Andrew Morton , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Linuxarm , Jonathan Cameron References: <20200707040204.30132-1-song.bao.hua@hisilicon.com> <20200707125641.dbd2ccd63f525aa5870069d8@linux-foundation.org> <9066e009-5ed2-1992-d70d-fd27b4bf5871@oracle.com> <20200708184615.GA251665@carbon.dhcp.thefacebook.com> From: Mike Kravetz Message-ID: Date: Thu, 9 Jul 2020 11:58:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9677 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007090129 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9677 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 priorityscore=1501 spamscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007090130 X-Rspamd-Queue-Id: 8DD051804B655 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: Looks like this produced a warning in linux-next. I suspect it is due to the combination CONFIG_HUGETLB_PAGE && !CONFIG_CMA. Instead of adding the routine hugetlb_cma_enabled() to scan the hugetlb_cma array, could we just use a boolean as follows? It can simply be set in hugetlb_cma_reserve when we reserve CMA. -- Mike Kravetz diff --git a/mm/hugetlb.c b/mm/hugetlb.c index fab4485b9e52..92cb882cf287 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -46,6 +46,7 @@ unsigned int default_hstate_idx; struct hstate hstates[HUGE_MAX_HSTATE]; static struct cma *hugetlb_cma[MAX_NUMNODES]; +static bool hugetlb_cma_enabled = false; /* * Minimum page order among possible hugepage sizes, set to a proper value @@ -2571,7 +2572,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; } @@ -5708,6 +5709,7 @@ void __init hugetlb_cma_reserve(int order) reserved += size; pr_info("hugetlb_cma: reserved %lu MiB on node %d\n", size / SZ_1M, nid); + hugetlb_cma_enabled = true; if (reserved >= hugetlb_cma_size) break;