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,URIBL_BLOCKED, 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 3B230C433ED for ; Mon, 19 Apr 2021 03:45:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD7A961090 for ; Mon, 19 Apr 2021 03:45:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD7A961090 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4A16D6B006E; Sun, 18 Apr 2021 23:45:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 450216B0070; Sun, 18 Apr 2021 23:45:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 318116B0071; Sun, 18 Apr 2021 23:45:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 15B2C6B006E for ; Sun, 18 Apr 2021 23:45:03 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BE0F7181AEF1F for ; Mon, 19 Apr 2021 03:45:02 +0000 (UTC) X-FDA: 78047725644.28.26B5EDF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id 8B3B2E000114 for ; Mon, 19 Apr 2021 03:45:01 +0000 (UTC) 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 97FD931B; Sun, 18 Apr 2021 20:45:01 -0700 (PDT) Received: from [10.163.74.113] (unknown [10.163.74.113]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1C1883F800; Sun, 18 Apr 2021 20:44:57 -0700 (PDT) Subject: Re: [PATCH V2] mm/page_alloc: Ensure that HUGETLB_PAGE_ORDER is less than MAX_ORDER To: David Hildenbrand , linux-mm@kvack.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, "linuxppc-dev @ lists . ozlabs . org" , "linux-ia64@vger.kernel.org" , Vlastimil Babka , Michal Hocko , Mel Gorman , Christoph Lameter References: <1618199302-29335-1-git-send-email-anshuman.khandual@arm.com> <09284b9a-cfe1-fc49-e1f6-3cf0c1b74c76@arm.com> <162877dd-e6ba-d465-d301-2956bb034429@redhat.com> From: Anshuman Khandual Message-ID: Date: Mon, 19 Apr 2021 09:15:49 +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: <162877dd-e6ba-d465-d301-2956bb034429@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8B3B2E000114 X-Stat-Signature: g9ie5zfdqbifnuc1w8p1dpracwdnhzsn Received-SPF: none (arm.com>: No applicable sender policy available) receiver=imf05; identity=mailfrom; envelope-from=""; helo=foss.arm.com; client-ip=217.140.110.172 X-HE-DKIM-Result: none/none X-HE-Tag: 1618803901-37325 Content-Transfer-Encoding: quoted-printable 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 4/12/21 2:17 PM, David Hildenbrand wrote: > On 12.04.21 10:06, Anshuman Khandual wrote: >> + 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 migh= t lead >>> to an warning during boot. A similar problem got fixed on arm64 platf= orm >>> 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 e= arlier >>> 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/ >>> >>> =C2=A0 mm/page_alloc.c | 11 +++++++++-- >>> =C2=A0 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) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (pageblock_order) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return; >>> =C2=A0 -=C2=A0=C2=A0=C2=A0 if (HPAGE_SHIFT > PAGE_SHIFT) >>> +=C2=A0=C2=A0=C2=A0 if (HPAGE_SHIFT > PAGE_SHIFT) { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * pageblock_order m= ust always be less than >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * MAX_ORDER. So doe= s HUGETLB_PAGE_ORDER if >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * that is being ass= igned here. >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BUILD_BUG_ON(HUGETLB_PAGE= _ORDER >=3D 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 actu= ally >> detected this problem. >> >> But wondering why this assert is not holding true ? and how these plat= forms >> 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_pag= e_info *info) >> { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long request= ed =3D 1UL << order; >> >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (WARN_ON_ONCE(orde= r >=3D MAX_ORDER)) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 return 0; >> .... >> >> Can pageblock_order really exceed MAX_ORDER - 1 ? >=20 > Ehm, for now I was under the impression that such configurations wouldn= 't exist. >=20 > And originally, HUGETLB_PAGE_SIZE_VARIABLE was introduced to handle hug= epage sizes that all *smaller* than MAX_ORDER - 1: See d9c234005227 ("Do = not depend on MAX_ORDER when grouping pages by mobility") Right. >=20 >=20 > However, looking into init_cma_reserved_pageblock(): >=20 > =C2=A0=C2=A0=C2=A0=C2=A0if (pageblock_order >=3D MAX_ORDER) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i =3D pageblock_nr_pages; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ... > =C2=A0=C2=A0=C2=A0=C2=A0} >=20 >=20 > But it's kind of weird, isn't it? Let's assume we have MAX_ORDER - 1 co= rrespond to 4 MiB and pageblock_order correspond to 8 MiB. >=20 > Sure, we'd be grouping pages in 8 MiB chunks, however, we cannot even a= llocate 8 MiB chunks via the buddy. So only alloc_contig_range() could re= ally grab them (IOW: gigantic pages). Right. >=20 > Further, we have code like deferred_free_range(), where we end up calli= ng __free_pages_core()->...->__free_one_page() with pageblock_order. Woul= dn't we end up setting the buddy order to something > MAX_ORDER -1 on tha= t path? Agreed. >=20 > Having pageblock_order > MAX_ORDER feels wrong and looks shaky. >=20 Agreed, definitely does not look right. Lets see what other folks might have to say on this. + Christoph Lameter