From patchwork Mon Dec 2 09:07:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13890157 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 7A5EFD10DCF for ; Mon, 2 Dec 2024 09:07:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F15C96B0082; Mon, 2 Dec 2024 04:07:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EC5586B0083; Mon, 2 Dec 2024 04:07:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB3DF6B0085; Mon, 2 Dec 2024 04:07:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BE1186B0082 for ; Mon, 2 Dec 2024 04:07:39 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 670251205CE for ; Mon, 2 Dec 2024 09:07:39 +0000 (UTC) X-FDA: 82849440660.21.4E545BA Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf25.hostedemail.com (Postfix) with ESMTP id 236A5A0004 for ; Mon, 2 Dec 2024 09:07:28 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733130450; 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=On2XITVQ4HZ6YTDdOZs9uxUJnuYRb4dBBBuhpOr5Jn4=; b=UB02OnIusqHGMeMCxM8P1OtI+Twihn+Vg+M4DKHVyKpnelwYA674jdW1Qn/JsIJKXAh0NO G3hET2Xhsp9Rnt4azk51b4ca86uhwz2HH6uItz/xQuRHjPiYSjJUGP/NqxhaPQVjtOnaYx Y+AJ/4aqEgExwUohQ0VjWLnZCYXfkzM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733130450; a=rsa-sha256; cv=none; b=7A1iov0h4RseZCodZPGTbGYjzMse1ooKnFG2i8mvZV65jVhWwUcucSSKYT1xW4BCANx9B/ A/KM02J1Lh2MadtKo2605QtMWwhEJlaLnCs1MmqUfJMA7e49mprHA/v06pg5RxdRlQAUOT QdQUNZJlJLRmTl4r8kv4+WhwlzkfUXk= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 0CFCB1063; Mon, 2 Dec 2024 01:08:05 -0800 (PST) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.16.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A190C3F71E; Mon, 2 Dec 2024 01:07:34 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH] mm/hugetlb: Make __NR_USED_SUBPAGE check conditional Date: Mon, 2 Dec 2024 14:37:28 +0530 Message-Id: <20241202090728.78935-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 236A5A0004 X-Stat-Signature: ph6m871x41jsqkoarudwcamj4jyqw4a8 X-Rspam-User: X-HE-Tag: 1733130448-49167 X-HE-Meta: U2FsdGVkX19d5r6S2HzKLZR8Br0AL7pVjG23xskJWPvdeHuByeu6+HFj/ww+y4FGk8bkXCkyaZmXvFM8x21eY25LOoGxyHuSe1oRlIM9NrGHblp3+Uk1cgQPIu+zPVlZND6lmyQ0gG6VL20impGWCQJY/roB/PA0pm7g9+soe9M4KqOX+LYYE1t7lTM9dDwBLUfDE/FNJscejQuSax6O8lO7BkmpkjY2B42xJ4w0D5bTgIWMJ9cuqNpobDtOPVIzAXo0Yz1xbGGJFdqi1nWYT7focmncOLmsWfTNxP63QdRjJW4GOGDNZ6bvNhuxDiJbejzGk9wP2NV9cSWtnpBvVb1h1/1LoNPcMhLb9GftACGEcgN324CU1tBTqAxjomV17pp6dD6qn9wMRHPdPEKNcx8WsEC+Sh5cO9QI2NjtPmA4DTG6upUTFm/C/TaRbjm0+IXtQZsC2PdRrnhhRC0HGHfz1y4r4TXYBTHIahc0+OiebcvCgbF0MLTntqzvUcq284jL1hoSxi5vkZeQOZ2EfIsCIb37zWUZNp1l84GYMWb/1jTmUNkMXe8HQWuoogBJ8fasF7LTSEdd2BCQlkucZzBGWFk9G6ML905nhmnFEgaKkDxn+yTdQ0rK1HIAnJCbVFHG6PO2zl0SrA1F2C0tj6G5hu51UhkfmwIolV28Un/x42xLYNOyzWGw2j4w0r6qEVdaBX/oXCURBlI/16gPQnTCWX/VBZYr0YfqjFU1bglai4KBuAVw/kBm4hn3DY3RKxX4V+znQ9avIWZPGSTfpPB54azt/xUpWBRiyflQGOq8RnXUqVeoatRMfhbwhFqwWr7FS0WFT6wccm/lSk93S2MUpL4T+D0yf+VY9nOuJtw9pMl++EC5FfqSfM8fZERCxiYgkHVTBf0ObA0N3ewvaSkxsJ6I19In7Fz8PakLyRRVygSvHo8ANreK0MieQ9T4b1NGY4NjFm9QYf1lsjZ n1baB4Ka sqSN77xCNyf0BJcyA4jLVIVXQX0TC2LFFEVYHaDiO0kDC6Wy9S3HF5p6Ak04Dv3Q9zB+I4Odjw2p7zM26LwbNsERlufqv3ojA6lju/IZDO2rYGQgd1ipYWn4XHheE6KBLJwVaI5wR5S/QAXiBrRcCA8jrhPWcMNjqumy3lczZE2Kx5jAd897i95+A44AZqaB1st1b4mDj/0oLurb6qmig0edzL87YjFTdJgu6nP7jN1Hnm4P8kkXIH8tY/kL2w2b1F1DtIpiuvMLJBJZK6ovuQoMo9JIAGQMSPcrHezBK+NT8bUODKaxsoD2TbhTSB4gaY0P8/9Px03ImhAS4FAqTyS68Jw== 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: The HugeTLB order check against __NR_USED_SUBPAGE is required only when HUGETLB_PAGE_OPTIMIZE_VMEMMAP is enabled. Hence BUG_ON() trigger should happen only when applicable. Cc: Muchun Song Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This patch applies on v6.13-rc1 mm/hugetlb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ea2ed8e301ef..b7443c7f3e0c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4513,11 +4513,13 @@ void __init hugetlb_add_hstate(unsigned int order) struct hstate *h; unsigned long i; - if (size_to_hstate(PAGE_SIZE << order)) { + if (size_to_hstate(PAGE_SIZE << order)) return; - } + BUG_ON(hugetlb_max_hstate >= HUGE_MAX_HSTATE); +#ifdef HUGETLB_PAGE_OPTIMIZE_VMEMMAP BUG_ON(order < order_base_2(__NR_USED_SUBPAGE)); +#endif h = &hstates[hugetlb_max_hstate++]; __mutex_init(&h->resize_lock, "resize mutex", &h->resize_key); h->order = order;