From patchwork Tue Dec 3 02:32:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13891649 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 6DF26E6C5E5 for ; Tue, 3 Dec 2024 02:32:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B94106B007B; Mon, 2 Dec 2024 21:32:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B44426B0083; Mon, 2 Dec 2024 21:32:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A33266B0085; Mon, 2 Dec 2024 21:32:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 861E86B007B for ; Mon, 2 Dec 2024 21:32:21 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 099E2A04F5 for ; Tue, 3 Dec 2024 02:32:21 +0000 (UTC) X-FDA: 82852073304.12.DE7D593 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 623872000F for ; Tue, 3 Dec 2024 02:32:13 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; 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; 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=1733193125; 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=cF5F3mFiyNgb7ha4h8WO2xRagEcq8bFAAcWItreQ+Qc=; b=5hvkIHymT18Sp/I0KaP+npWzSui6RtznKSfBJWu0jqpfciKiNBPDYRW/X/pZ87ga42onLj JNXXe5x3Kg5jKtqRRCy0IU1bJh+Ovi9dw/A25rcYCGUXTG9jeDC3i359UGfIxD01hceMpy zKvJSPyaMicKQQDYXA/TyikwOiMCkk0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; 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; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733193125; a=rsa-sha256; cv=none; b=zaQbmgO9pZ5a8e+vg+2B+iu4NzQHZEPnmrR6bhzsUGiCkF8CPqPciQDM+XqqOZ65xvd4nf Gtq7Cw6IaWwWRcagG+ZPDcMPkuzaefe79V9U4Q1xf3Wlxpz4YXvLLK7fiduXlEVcCw6Fu2 eJ9bwELeqXoaoBUtPIXi3S0L4mF0wRQ= 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 63C1FFEC; Mon, 2 Dec 2024 18:32:46 -0800 (PST) Received: from a077893.arm.com (unknown [10.163.48.101]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4C1B13F71E; Mon, 2 Dec 2024 18:32:15 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Muchun Song , Andrew Morton , Oscar Salvador , linux-kernel@vger.kernel.org Subject: [PATCH V2] mm/hugetlb: Make __NR_USED_SUBPAGE check conditional Date: Tue, 3 Dec 2024 08:02:07 +0530 Message-Id: <20241203023207.123416-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 623872000F X-Rspam-User: X-Stat-Signature: ehzmfqi6bjx1kbt84ntpbdskmoi4jjzs X-HE-Tag: 1733193133-905841 X-HE-Meta: U2FsdGVkX197pZJt5FGt63Bs5M4Jz6nIP6l3Wce3eOVruc9cVgTryFkbe9VGifJZkoVIB6tNDHkDVSXp+Gb+VD3RYhd3t7vy3cKchawV0A5VUHas1U7DDY0ZpYkwhWM8T72N+iXa7uQbKfEGVDJBplKNNBiyZVSOK7SZJHGs+ijqUKiVINoetmv73dEORiVXwVYpvloP15wI3tX9hCswnw+iwZ3Y1Sy/2Yb/7/DWgoHS2ju4dnuALinD37VGcdWHf8wWfSz0yMPJ/o3xkduPSjLRs9Aj4a2vzgKQldvOfkyPWXPApXZM6Xqm6DBPivDNF2bz5dccEK4W2qkh2vOqrJH/d6rAs6K4HrlNBb8A7oJEPK4rpQvhazGK44RsJSQI1fnnZul6vviv7Rw8s3aug/zoGvRFJbgsIKY8REiIaYpORcOOq/TMqcC7eE3LWOvktU56CtAPz3tKTAw2PLaM4dkOhLA/BfJCTWF5uxfXhlrys558p6H9V2RXtksBipwoJGZZw9RM/4CFjjJwCZph4SamvJ36DO2qsxdxCKIxdkjuVRd+0Iqt3myddLWshXkAUuWYP2Bi951D3XljMYKIn1yN9eHtS7Bsk8U8wbKIPwQc7iveYrWSqmaOGzZyErVcM/VvwhTUIoj6eKtsDynFnZdZsBpOAkc/qCMxCcMozzjqVL8hNXncsbZr7vYnW8aSfn6OjboILeSVqJiJPReleHP3dtqnBTz5Ad0/V4iu/hrHoSKEqeM72IMncwIzhrP4GdVO38Y/upftFmC2Q6wKWP4vKMPMMBUFfilMfAsec1j2HBrEa9ZLmq8ZLk2wJh4n4D9mkY0N3cibnoKbVW7+kZtU9+s/45wtH0HrmhZs+3iqflfnmeVVVp/rVcMU7eFxIKolytrbojzj4TmYs+gr5U6BtNiVsDGWpCJcMcx8Zafpv3+7tqzN1LQJdnxE28QK5lPtEs/fUuzPdYvnUrH uWLrv5d7 CYQOOS+65EU9qPNx4GJNlew75DK8C6b6MK5CdOKFbU5jGitkrJsgJERESe+a4lkD81k7YvPjd3V898ORIA+uePySf0fk9n//1u8VwXQmivhhS+g6ODFYDG8ScTumj29/BTMv2R/6SwTnywRx6kJXE+ZalPGxDqKBM/xW7oMvoi7bze51DzopLl9/GNDcvLY/VRaE3VZg6CczI45Mmj+dIWZSU/6hjfAPbz/sXAUGJs1mNRo/CJpLvRmxWQhUJSLwxGSJFdm3pJc2QBc5bNn/owvUAIyDGtVYKQJpS5rSyA+ZvGljlD01lSJheTDEGP+k/DaHYUwdazg1vgKP18DUpo/zgLQ== 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: Oscar Salvador Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This patch applies on v6.13-rc1 Changes in V2: - Fixed #ifdef with CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP per Oscar Changes in V1: https://lore.kernel.org/all/20241202090728.78935-1-anshuman.khandual@arm.com/ mm/hugetlb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index ea2ed8e301ef..e6a5b21e3578 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 CONFIG_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;