From patchwork Thu Feb 4 07:01:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 12066415 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 31FDEC433DB for ; Thu, 4 Feb 2021 07:01:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B11FC64E35 for ; Thu, 4 Feb 2021 07:01:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B11FC64E35 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 3AC1E6B006C; Thu, 4 Feb 2021 02:01:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 382D66B006E; Thu, 4 Feb 2021 02:01:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 272576B0070; Thu, 4 Feb 2021 02:01:14 -0500 (EST) 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 0CBC26B006C for ; Thu, 4 Feb 2021 02:01:14 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D2E46824999B for ; Thu, 4 Feb 2021 07:01:13 +0000 (UTC) X-FDA: 77779688826.20.lead50_30043d7275da Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id AC7D8180C07AB for ; Thu, 4 Feb 2021 07:01:13 +0000 (UTC) X-HE-Tag: lead50_30043d7275da X-Filterd-Recvd-Size: 4338 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 07:01:13 +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 124CC12FC; Wed, 3 Feb 2021 23:01:12 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.94.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7A96F3F694; Wed, 3 Feb 2021 23:01:08 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, akpm@linux-foundation.org Cc: Anshuman Khandual , Will Deacon , Robin Murphy , Marek Szyprowski , Christoph Hellwig , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [RFC 1/3] mm/page_alloc: Fix pageblock_order when HUGETLB_PAGE_ORDER >= MAX_ORDER Date: Thu, 4 Feb 2021 12:31:22 +0530 Message-Id: <1612422084-30429-2-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1612422084-30429-1-git-send-email-anshuman.khandual@arm.com> References: <1612422084-30429-1-git-send-email-anshuman.khandual@arm.com> 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: With HUGETLB_PAGE_SIZE_VARIABLE enabled, pageblock_order cannot be assigned as HUGETLB_PAGE_ORDER when it is greater than or equal to MAX_ORDER during set_pageblock_order(). Otherwise the following warning is triggered during boot as detected on an arm64 platform. WARNING: CPU: 5 PID: 124 at mm/vmstat.c:1080 __fragmentation_index+0xa4/0xc0 Modules linked in: CPU: 5 PID: 124 Comm: kswapd0 Not tainted 5.11.0-rc6-00004-ga0ea7d62002 #159 Hardware name: linux,dummy-virt (DT) [ 8.810673] pstate: 20400005 (nzCv daif +PAN -UAO -TCO BTYPE=--) [ 8.811732] pc : __fragmentation_index+0xa4/0xc0 [ 8.812555] lr : fragmentation_index+0xf8/0x138 [ 8.813360] sp : ffff0000864079b0 [ 8.813958] x29: ffff0000864079b0 x28: 0000000000000372 [ 8.814901] x27: 0000000000007682 x26: ffff8000135b3948 [ 8.815847] x25: 1fffe00010c80f48 x24: 0000000000000000 [ 8.816805] x23: 0000000000000000 x22: 000000000000000d [ 8.817764] x21: 0000000000000030 x20: ffff0005ffcb4d58 [ 8.818712] x19: 000000000000000b x18: 0000000000000000 [ 8.819656] x17: 0000000000000000 x16: 0000000000000000 [ 8.820613] x15: 0000000000000000 x14: ffff8000114c6258 [ 8.821560] x13: ffff6000bff969ba x12: 1fffe000bff969b9 [ 8.822514] x11: 1fffe000bff969b9 x10: ffff6000bff969b9 [ 8.823461] x9 : dfff800000000000 x8 : ffff0005ffcb4dcf [ 8.824415] x7 : 0000000000000001 x6 : 0000000041b58ab3 [ 8.825359] x5 : ffff600010c80f48 x4 : dfff800000000000 [ 8.826313] x3 : ffff8000102be670 x2 : 0000000000000007 [ 8.827259] x1 : ffff000086407a60 x0 : 000000000000000d [ 8.828218] Call trace: [ 8.828667] __fragmentation_index+0xa4/0xc0 [ 8.829436] fragmentation_index+0xf8/0x138 [ 8.830194] compaction_suitable+0x98/0xb8 [ 8.830934] wakeup_kcompactd+0xdc/0x128 [ 8.831640] balance_pgdat+0x71c/0x7a0 [ 8.832327] kswapd+0x31c/0x520 [ 8.832902] kthread+0x224/0x230 [ 8.833491] ret_from_fork+0x10/0x30 [ 8.834150] ---[ end trace 472836f79c15516b ]--- The above warning happens because pageblock_order exceeds MAX_ORDER, caused by large HUGETLB_PAGE_ORDER on certain platforms like arm64. Lets prevent the scenario by first checking HUGETLB_PAGE_ORDER against MAX_ORDER, before its assignment as pageblock_order. Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 519a60d5b6f7..36473f2fa683 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6798,7 +6798,7 @@ void __init set_pageblock_order(void) if (pageblock_order) return; - if (HPAGE_SHIFT > PAGE_SHIFT) + if ((HPAGE_SHIFT > PAGE_SHIFT) && (HUGETLB_PAGE_ORDER < MAX_ORDER)) order = HUGETLB_PAGE_ORDER; else order = MAX_ORDER - 1;