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.2 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 C4A21C433E0 for ; Fri, 12 Feb 2021 09:39:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 41F1B64E38 for ; Fri, 12 Feb 2021 09:39:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41F1B64E38 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C17AB8D002F; Fri, 12 Feb 2021 04:39:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC7D18D0015; Fri, 12 Feb 2021 04:39:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB7098D002F; Fri, 12 Feb 2021 04:39:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 925B68D0015 for ; Fri, 12 Feb 2021 04:39:51 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4DF66180ACEEC for ; Fri, 12 Feb 2021 09:39:51 +0000 (UTC) X-FDA: 77809118982.23.run29_1e029ea27620 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 326B737604 for ; Fri, 12 Feb 2021 09:39:51 +0000 (UTC) X-HE-Tag: run29_1e029ea27620 X-Filterd-Recvd-Size: 8932 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 12 Feb 2021 09:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613122790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VJIh+57vZZX62sUHqf9Qg0OO0KLGj7Jhm7EDFFjgYrE=; b=bxSWt59IXe7Ph68jERmrp8ud+1hNqgsKdIFfEMhkrxDMjiOgbS4hOg4JEUdHM9yxleZSY+ 0esU68H67mH2u8XubGEln94mzlDqvlxpEA94VJakwlZq/yzphj1tg3LWmhk9tiqJ9FKLoh c4UjjRuOtyfyrjgEnWpTLly7X4AcdrM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-s08ifoYOOVywTnddxRfoeQ-1; Fri, 12 Feb 2021 04:39:45 -0500 X-MC-Unique: s08ifoYOOVywTnddxRfoeQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 185691936B66; Fri, 12 Feb 2021 09:39:44 +0000 (UTC) Received: from [10.36.114.178] (ovpn-114-178.ams2.redhat.com [10.36.114.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id 298E65D74A; Fri, 12 Feb 2021 09:39:41 +0000 (UTC) To: Anshuman Khandual , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, akpm@linux-foundation.org, will@kernel.org Cc: Robin Murphy , Marek Szyprowski , Christoph Hellwig , Mark Rutland , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <1613024531-19040-1-git-send-email-anshuman.khandual@arm.com> <683c812a-ce3d-ef74-10d1-eaf8a3ae93d4@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Subject: Re: [PATCH 0/3] mm/page_alloc: Fix pageblock_order with HUGETLB_PAGE_SIZE_VARIABLE Message-ID: Date: Fri, 12 Feb 2021 10:39:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 12.02.21 08:02, Anshuman Khandual wrote: >=20 > On 2/11/21 2:07 PM, David Hildenbrand wrote: >> On 11.02.21 07:22, Anshuman Khandual wrote: >>> The following warning gets triggered while trying to boot a 64K page = size >>> without THP config kernel on arm64 platform. >>> >>> WARNING: CPU: 5 PID: 124 at mm/vmstat.c:1080 __fragmentation_index+0x= a4/0xc0 >>> Modules linked in: >>> CPU: 5 PID: 124 Comm: kswapd0 Not tainted 5.11.0-rc6-00004-ga0ea7d620= 02 #159 >>> Hardware name: linux,dummy-virt (DT) >>> [=C2=A0=C2=A0=C2=A0 8.810673] pstate: 20400005 (nzCv daif +PAN -UAO -= TCO BTYPE=3D--) >>> [=C2=A0=C2=A0=C2=A0 8.811732] pc : __fragmentation_index+0xa4/0xc0 >>> [=C2=A0=C2=A0=C2=A0 8.812555] lr : fragmentation_index+0xf8/0x138 >>> [=C2=A0=C2=A0=C2=A0 8.813360] sp : ffff0000864079b0 >>> [=C2=A0=C2=A0=C2=A0 8.813958] x29: ffff0000864079b0 x28: 000000000000= 0372 >>> [=C2=A0=C2=A0=C2=A0 8.814901] x27: 0000000000007682 x26: ffff8000135b= 3948 >>> [=C2=A0=C2=A0=C2=A0 8.815847] x25: 1fffe00010c80f48 x24: 000000000000= 0000 >>> [=C2=A0=C2=A0=C2=A0 8.816805] x23: 0000000000000000 x22: 000000000000= 000d >>> [=C2=A0=C2=A0=C2=A0 8.817764] x21: 0000000000000030 x20: ffff0005ffcb= 4d58 >>> [=C2=A0=C2=A0=C2=A0 8.818712] x19: 000000000000000b x18: 000000000000= 0000 >>> [=C2=A0=C2=A0=C2=A0 8.819656] x17: 0000000000000000 x16: 000000000000= 0000 >>> [=C2=A0=C2=A0=C2=A0 8.820613] x15: 0000000000000000 x14: ffff8000114c= 6258 >>> [=C2=A0=C2=A0=C2=A0 8.821560] x13: ffff6000bff969ba x12: 1fffe000bff9= 69b9 >>> [=C2=A0=C2=A0=C2=A0 8.822514] x11: 1fffe000bff969b9 x10: ffff6000bff9= 69b9 >>> [=C2=A0=C2=A0=C2=A0 8.823461] x9 : dfff800000000000 x8 : ffff0005ffcb= 4dcf >>> [=C2=A0=C2=A0=C2=A0 8.824415] x7 : 0000000000000001 x6 : 0000000041b5= 8ab3 >>> [=C2=A0=C2=A0=C2=A0 8.825359] x5 : ffff600010c80f48 x4 : dfff80000000= 0000 >>> [=C2=A0=C2=A0=C2=A0 8.826313] x3 : ffff8000102be670 x2 : 000000000000= 0007 >>> [=C2=A0=C2=A0=C2=A0 8.827259] x1 : ffff000086407a60 x0 : 000000000000= 000d >>> [=C2=A0=C2=A0=C2=A0 8.828218] Call trace: >>> [=C2=A0=C2=A0=C2=A0 8.828667]=C2=A0 __fragmentation_index+0xa4/0xc0 >>> [=C2=A0=C2=A0=C2=A0 8.829436]=C2=A0 fragmentation_index+0xf8/0x138 >>> [=C2=A0=C2=A0=C2=A0 8.830194]=C2=A0 compaction_suitable+0x98/0xb8 >>> [=C2=A0=C2=A0=C2=A0 8.830934]=C2=A0 wakeup_kcompactd+0xdc/0x128 >>> [=C2=A0=C2=A0=C2=A0 8.831640]=C2=A0 balance_pgdat+0x71c/0x7a0 >>> [=C2=A0=C2=A0=C2=A0 8.832327]=C2=A0 kswapd+0x31c/0x520 >>> [=C2=A0=C2=A0=C2=A0 8.832902]=C2=A0 kthread+0x224/0x230 >>> [=C2=A0=C2=A0=C2=A0 8.833491]=C2=A0 ret_from_fork+0x10/0x30 >>> [=C2=A0=C2=A0=C2=A0 8.834150] ---[ end trace 472836f79c15516b ]--- >>> >>> This warning comes from __fragmentation_index() when the requested or= der >>> is greater than MAX_ORDER. >>> >>> static int __fragmentation_index(unsigned int 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 struct contig_page_info *info) >>> { >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long reque= sted =3D 1UL << order; >>> >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (WARN_ON_ONCE(or= der >=3D MAX_ORDER)) <=3D=3D=3D=3D=3D Triggered 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=C2=A0 return 0; >>> >>> Digging it further reveals that pageblock_order has been assigned a v= alue >>> which is greater than MAX_ORDER failing the above check. But why this >>> happened ? Because HUGETLB_PAGE_ORDER for the given config on arm64 i= s >>> greater than MAX_ORDER. >>> >>> The solution involves enabling HUGETLB_PAGE_SIZE_VARIABLE which would= make >>> pageblock_order a variable instead of constant HUGETLB_PAGE_ORDER. Bu= t that >>> change alone also did not really work as pageblock_order still got as= signed >>> as HUGETLB_PAGE_ORDER in set_pageblock_order(). HUGETLB_PAGE_ORDER ne= eds to >>> be less than MAX_ORDER for its appropriateness as pageblock_order oth= erwise >>> just fallback to MAX_ORDER - 1 as before. While here it also fixes a = build >>> problem via type casting MAX_ORDER in rmem_cma_setup(). >> >> I'm wondering, is there any real value in allowing FORCE_MAX_ZONEORDER= to be "11" with ARM64_64K_PAGES/ARM64_16K_PAGES? >=20 > MAX_ORDER should be as high as would be required for the current config= . > Unless THP is enabled, there is no need for it to be any higher than 11= . > But I might be missing historical reasons around this as well. Probably > others from arm64 could help here. Theoretically yes, practically no. If nobody cares about a=20 configuration, no need to make the code more complicated for that=20 configuration. >=20 >> >> Meaning: are there any real use cases that actually build a kernel wit= hout TRANSPARENT_HUGEPAGE and with ARM64_64K_PAGES/ARM64_16K_PAGES? >=20 > THP is always optional. Besides kernel builds without THP should always > be supported. Assuming that all builds will have THP enabled, might not > be accurate. >=20 >> >> As builds are essentially broken, I assume this is not that relevant? = Or how long has it been broken? >=20 > Git blame shows that it's been there for some time now. But how does > that make this irrelevant ? A problem should be fixed nonetheless. When exactly did I say not to fix it? I'm saying if nobody uses it, we=20 might be able to simplify. >=20 >> >> It might be easier to just drop the "TRANSPARENT_HUGEPAGE" part from t= he FORCE_MAX_ZONEORDER config. >> >=20 > Not sure if it would be a good idea to unnecessarily have larger MAX_OR= DER > value for a given config. But I might be missing other contexts here. My point is: keep it simple if there is no need to make it complicated.=20 If these arm64 variants are the only cases where we run into that issue=20 and nobody uses them ("hat it's been there for some time now"), why make=20 stuff complicated? The current code seems to assume that HUGETLB_PAGE_ORDER <=3D MAX_ORDER.=20 Instead of changing that for optimizing an unused use case (it is=20 broken), just simplify the arm64 conditions. I'd even say add a /* * Some code assumes that HUGETLB_PAGE_ORDER <=3D MAX_ORDER. For now, on= ly * !TRANSPARENT_HUGEPAGE could lead in archs creating such setups. * Forbid it for now; anybody that has a valid use case has to sanitize * the code. */ BUILD_BUG_ON(HUGETLB_PAGE_ORDER <=3D MAX_ORDER); But again, if there are valid use cases then sure, let's make the code=20 fully compatible with HUGETLB_PAGE_ORDER > MAX_ORDER. BTW: can we be sure that you caught all issues? For example: #define COMPACTION_HPAGE_ORDER HUGETLB_PAGE_ORDER I'm not sure if it will work as expected if HUGETLB_PAGE_ORDER >=20 MAX_ORDER ... fill_contig_page_info() will never find any suitable free=20 blocks ... --=20 Thanks, David / dhildenb