From patchwork Fri Feb 9 05:42:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13550877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F77BC4828F for ; Fri, 9 Feb 2024 05:42:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05CA16B0078; Fri, 9 Feb 2024 00:42:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 00C526B007E; Fri, 9 Feb 2024 00:42:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E646A6B0080; Fri, 9 Feb 2024 00:42:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D74B56B0078 for ; Fri, 9 Feb 2024 00:42:39 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 621B3C043D for ; Fri, 9 Feb 2024 05:42:39 +0000 (UTC) X-FDA: 81771170838.22.9463CAB Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 89DD620013 for ; Fri, 9 Feb 2024 05:42:37 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707457358; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=GO3ZiHJ1lWtACiQRt36gsRlwOBJdlYiM1hIVC0h9HoA=; b=ZbyA1W6psbGQ/klY++ifxyJlFvK4s0TpxbMCfuZbeOrwo6ORR+rc1/8EZFSl56RFDK4sMG GVE7rEmw5bK8AvIRhVqLCaT7QqLJHSwfmW/F0MAdLluD41voAbKnfdyuJvXnjNxU/UJ28l xPpapb2SKtif/9VMo2YoJ8BT49cLlHo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707457358; a=rsa-sha256; cv=none; b=5nT/4lHe8u/WOO7mvrpFhcM/aLNvLE0mYTizcgfecIPRc3NhqygaubVJIDmw8+jdnDixlJ syoMD4pWFw71YFA5YuqVqmpkYarTsUOKyv38kojzRaNZc2ffxSmCIA8P5bX5MPU7RUy1M8 GRlmawGiiMLhO580z3vtUBnVpCxym/4= 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 8B737DA7; Thu, 8 Feb 2024 21:43:18 -0800 (PST) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.40.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 169583F762; Thu, 8 Feb 2024 21:42:32 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Michael Ellerman , Nicholas Piggin , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/hugetlb: Move page order check inside hugetlb_cma_reserve() Date: Fri, 9 Feb 2024 11:12:21 +0530 Message-Id: <20240209054221.1403364-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 89DD620013 X-Stat-Signature: 9kwmke9xs4k35as861poffi7ft8aeqi8 X-HE-Tag: 1707457357-117585 X-HE-Meta: U2FsdGVkX195Zfr5Ej2vsIecz1eiw21urJiIgC1ia4X8o+yUGRDqJfJNFwPmwuN8DCWdwW062dxqu96J38skH8n+6t9z3U1K3kGiGj7VIpdh9L7UXTKWkrG6gLVpcaCtSKny8zuu3Ic0Tq56V+WakBoAN1DuldIV/G8kcCsjqh786Walq8vAkTvJxCVoeooQ/kqP1lkVc/1RNWf6m4tg73y1bpRppkQaA4HASNJkmte6M/n54y+vb0rxzMjuAgp4Li53s+3zU44NODW4bOj0t7vGcg422vpaxmLlWrwmwiAPUJPZY3j9h66Qzg86mALSGP8mWMUTA1UgKAmUKHxMHE7Z8pcCZMt/iC16RIpr245sjlf3jc+/K3gw4I9c2yalSHI9kLBKh+kcoWX98A3ccZuV1UqOlyOJBZWWhLKV8X2E+XHo4MVgyJHTv7hekqpsDU9U9A5ogtVuBg2oAMdd7WJwKlm1HimksZGY0xGN1W9MdFEgUT5SXTdhp4HgXxh8rfr711Yk1M85gkQ3LsTPdPPJrnCOacA1DGt+jZzWGXe2t9XLx28+Cdm3Af9WinAIz4kHQ2I6YAS7G80nv8DdQ00O0QIXQYVchZtQEBSKKbGFqtf8Cg45Ynf1SiX6xkLJIpqnMprVXd4nAniqXji/a3DrFDZ8jYRjPk7DhiyaLTguuMR3ot3SPhPrsZ3n8sGmqBdkfrTtLwu9Jqssxf8aG90V3YJGg+jMUpUjoNeZFfKyOVBYEUDUg/sBQ+vrO21CKnYNq7lRfLHCky0AaKve7OXidvULtF2BN4Sjc6DhIhflfxRMAw257vYlFLztVZ6PSetISvSTP6/Pdjt0APTLxtszOKQ833H349ufRkO51JxgRa3UoTUlsgk66pwt+OiqplzjeXEWiWeXbYou3qa5aCqytKISesyMY6NlJl4bRWkX4BaLrx6OmHkvIb60+0aBtRxyaTMrxhKXlooIKp5 jEt+0hSr N1TtZpXb9ue6gQaOhPjFrr3ZxZMI+UKL/oQZE+DNpTkuv44MspQUjmOXMSFN7IO/Zx0sAIS5+eEae+7uiqM4VU9DOluHPbX8XStsrfR9XwzxYcxQ+tGnJmnuTWn3plva+9+uRm32ya5ivdiy3rEaS+/NpMObmvWcWfZ6GigIuqztaNgrGYQrzIHjVdsW1FqHwGMSTnI+4Ad5x8osKdaJDnWa/cIxef5vIK37v82xCgjvRSVlaY0QhjljoFwJl/eSF6ulipeT0GuoPK9bhu6AEi2idHHjQV2YcLytj3e4zGUDdzZANZRNfSmTx2cCrScaT/6u7DyPduawe7s41GJ/hiYsF+dC/4/Pn9D2zYGCpZJQkpTDBuQC/eSgDUx9H2ZyMS4/BXi7MF1Ki47RRuqx7HZ+tpx/l6EvFZg2ut0j9ZL50N6NnEcG4nngtJKCEBdVCwntKaLc38PlX2ymeeEO+qZHTIQ== 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: List-Subscribe: List-Unsubscribe: All platforms could benefit from page order check against MAX_PAGE_ORDER before allocating a CMA area for gigantic hugetlb pages. Let's move this check from individual platforms to generic hugetlb. Cc: Catalin Marinas Cc: Will Deacon Cc: Michael Ellerman Cc: Nicholas Piggin Cc: linux-arm-kernel@lists.infradead.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual Reviewed-by: Jane Chu Reviewed-by: David Hildenbrand --- This applies on v6.8-rc3 arch/arm64/mm/hugetlbpage.c | 7 ------- arch/powerpc/mm/hugetlbpage.c | 4 +--- mm/hugetlb.c | 7 +++++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 8116ac599f80..6720ec8d50e7 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -45,13 +45,6 @@ void __init arm64_hugetlb_cma_reserve(void) else order = CONT_PMD_SHIFT - PAGE_SHIFT; - /* - * HugeTLB CMA reservation is required for gigantic - * huge pages which could not be allocated via the - * page allocator. Just warn if there is any change - * breaking this assumption. - */ - WARN_ON(order <= MAX_PAGE_ORDER); hugetlb_cma_reserve(order); } #endif /* CONFIG_CMA */ diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 0a540b37aab6..16557d008eef 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -614,8 +614,6 @@ void __init gigantic_hugetlb_cma_reserve(void) */ order = mmu_psize_to_shift(MMU_PAGE_16G) - PAGE_SHIFT; - if (order) { - VM_WARN_ON(order <= MAX_PAGE_ORDER); + if (order) hugetlb_cma_reserve(order); - } } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index cf9c9b2906ea..345b3524df35 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7699,6 +7699,13 @@ void __init hugetlb_cma_reserve(int order) bool node_specific_cma_alloc = false; int nid; + /* + * HugeTLB CMA reservation is required for gigantic + * huge pages which could not be allocated via the + * page allocator. Just warn if there is any change + * breaking this assumption. + */ + VM_WARN_ON(order <= MAX_PAGE_ORDER); cma_reserve_called = true; if (!hugetlb_cma_size)