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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 B5AD2C433B4 for ; Mon, 12 Apr 2021 08:06:06 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4EE4E6103D for ; Mon, 12 Apr 2021 08:06:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EE4E6103D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FJhBh5vN2z3brH for ; Mon, 12 Apr 2021 18:06:04 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arm.com (client-ip=217.140.110.172; helo=foss.arm.com; envelope-from=anshuman.khandual@arm.com; receiver=) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lists.ozlabs.org (Postfix) with ESMTP id 4FJhBJ1ZLkz2yyF for ; Mon, 12 Apr 2021 18:05:42 +1000 (AEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E0D0231B; Mon, 12 Apr 2021 01:05:38 -0700 (PDT) Received: from [10.163.72.17] (unknown [10.163.72.17]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 340B23F73B; Mon, 12 Apr 2021 01:05:36 -0700 (PDT) Subject: Re: [PATCH V2] mm/page_alloc: Ensure that HUGETLB_PAGE_ORDER is less than MAX_ORDER To: linux-mm@kvack.org, akpm@linux-foundation.org References: <1618199302-29335-1-git-send-email-anshuman.khandual@arm.com> From: Anshuman Khandual Message-ID: <09284b9a-cfe1-fc49-e1f6-3cf0c1b74c76@arm.com> Date: Mon, 12 Apr 2021 13:36:10 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1618199302-29335-1-git-send-email-anshuman.khandual@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-ia64@vger.kernel.org" , "linuxppc-dev @ lists . ozlabs . org" , linux-kernel@vger.kernel.org, David Hildenbrand Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" + linuxppc-dev@lists.ozlabs.org + linux-ia64@vger.kernel.org On 4/12/21 9:18 AM, Anshuman Khandual wrote: > pageblock_order must always be less than MAX_ORDER, otherwise it might lead > to an warning during boot. A similar problem got fixed on arm64 platform > with the commit 79cc2ed5a716 ("arm64/mm: Drop THP conditionality from > FORCE_MAX_ZONEORDER"). Assert the above condition before HUGETLB_PAGE_ORDER > gets assigned as pageblock_order. This will help detect the problem earlier > on platforms where HUGETLB_PAGE_SIZE_VARIABLE is enabled. > > Cc: David Hildenbrand > Cc: Andrew Morton > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > Changes in V2: > > - Changed WARN_ON() to BUILD_BUG_ON() per David > > Changes in V1: > > https://patchwork.kernel.org/project/linux-mm/patch/1617947717-2424-1-git-send-email-anshuman.khandual@arm.com/ > > mm/page_alloc.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index cfc72873961d..19283bff4bec 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6875,10 +6875,17 @@ void __init set_pageblock_order(void) > if (pageblock_order) > return; > > - if (HPAGE_SHIFT > PAGE_SHIFT) > + if (HPAGE_SHIFT > PAGE_SHIFT) { > + /* > + * pageblock_order must always be less than > + * MAX_ORDER. So does HUGETLB_PAGE_ORDER if > + * that is being assigned here. > + */ > + BUILD_BUG_ON(HUGETLB_PAGE_ORDER >= MAX_ORDER); Unfortunately the build test fails on both the platforms (powerpc and ia64) which subscribe HUGETLB_PAGE_SIZE_VARIABLE and where this check would make sense. I some how overlooked the cross compile build failure that actually detected this problem. But wondering why this assert is not holding true ? and how these platforms do not see the warning during boot (or do they ?) at mm/vmscan.c:1092 like arm64 did. static int __fragmentation_index(unsigned int order, struct contig_page_info *info) { unsigned long requested = 1UL << order; if (WARN_ON_ONCE(order >= MAX_ORDER)) return 0; .... Can pageblock_order really exceed MAX_ORDER - 1 ? > order = HUGETLB_PAGE_ORDER; > - else > + } else { > order = MAX_ORDER - 1; > + } > > /* > * Assume the largest contiguous order of interest is a huge page. >