From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 112D826FA5B for ; Wed, 8 Apr 2026 22:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775687155; cv=none; b=EVfZT6pBkOHfzxIWOrzOcZGp+4gpf1il6WwUx39nAnrWpGQlkQyFBJHVSPu40SRT5E5YXBUdB02WD2PlyTbu1l1Q2wd2DvsGPBSmTIxU7niH35KM2ptVhV2L72vmlRHvQov13biTNPZLTgKwFyppCTtbR6Ghh0GYROqCuTIXhcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775687155; c=relaxed/simple; bh=Z70k03OIJkrVFJaM5h1C7JB7eC7wdxXQGbOGlyBUPgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hTYz0dIZDXQhuIAELfqC6/Il6gqQAYLbtP7gjeL41JhH/KkaiTEA9opxOKxGGyNPcTVy8P29KVhnNrNsSmHNrQVLdaGrdLqGErndoCj3QOt6dc21UO5TfiUn0Resy1UJ4h0kwJzvjqzM5GEZ523NYzjpb+a999LGJ02Pn8TiTtk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IPEXiYnN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IPEXiYnN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775687153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tCrP0/yiPFGIZwByrE4JJ2I8Uf5Ye8WtA9EuaL562tY=; b=IPEXiYnNXIzBSV+U6teIuZo7KziU4Q1VAZ6eXdc4IqzR9IBncNJQKfMLd2hW9sCUFclTqq WSC/ZDeKnA3dIEstLL0bssIIKkeWrZ6PLNyTIbqg+L8KYyxvCQaMz4fx6jaozeVL0O+/aZ 0MBJ6kTMhNjI1u/2WtQu0QPMVQWW2/4= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-fR8apmNbM0SY-v41upfTEQ-1; Wed, 08 Apr 2026 16:23:20 -0400 X-MC-Unique: fR8apmNbM0SY-v41upfTEQ-1 X-Mimecast-MFC-AGG-ID: fR8apmNbM0SY-v41upfTEQ_1775679797 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CE48A1800345; Wed, 8 Apr 2026 20:23:16 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 44FEA180036E; Wed, 8 Apr 2026 20:23:15 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 01/10] docs: tmpfs: remove implementation detail reference Date: Wed, 8 Apr 2026 16:22:56 -0400 Message-ID: <9a0bed627137a1a0055900114ac6d4abd3a9720c.1775679721.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" The tmpfs.rst doc references the has_transparent_hugepage() helper, which is an implementation detail in the kernel and not relevant for users wishing to properly configure THP support for tmpfs. Remove it. Acked-by: David Hildenbrand (Red Hat) Reviewed-by: Baolin Wang Signed-off-by: Luiz Capitulino --- Documentation/filesystems/tmpfs.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/tmpfs.rst b/Documentation/filesystem= s/tmpfs.rst index d677e0428c3f..46fc986c3388 100644 --- a/Documentation/filesystems/tmpfs.rst +++ b/Documentation/filesystems/tmpfs.rst @@ -109,9 +109,8 @@ noswap Disables swap. Remounts must respect the origin= al settings. =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 tmpfs also supports Transparent Huge Pages which requires a kernel -configured with CONFIG_TRANSPARENT_HUGEPAGE and with huge supported for -your system (has_transparent_hugepage(), which is architecture specific). -The mount options for this are: +configured with CONFIG_TRANSPARENT_HUGEPAGE and with huge pages +supported for your system. The mount options for this are: =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D huge=3Dnever Do not allocate huge pages. This is the default. --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 543593914F0 for ; Wed, 8 Apr 2026 20:24:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679888; cv=none; b=iBY49hoL4msnDW74M9ESQsVP5uRB9lCqTv1ewEzooJlY6MEFWkp+o9i6WVJeMaz/QssMq8TeGY00g5UNHRDbv9ih/yWps/6kVpOslyKBf5F0j924n2PtZ/97oo3/UJZh8p3tKchRpG8Tg2smZsRcRMdDQKXnkCFn9Iu/Y/qtMoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679888; c=relaxed/simple; bh=WgkWPNzZ6WrMMJYY/tvvEUQikW+isoaT0eNS17u6Fvo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HfLZJ86dneywBI71yS0JjiuZWZjmWgWNC2KNl5umYDuKjnFqOBz9zd5nlDTsrKj98SOmJwpGDS/4V4VR/s+tF8koU2BnbuOG+GsF3S/V3qnFpBmszNuis/V/2vXTidbTE7KX/ZKxjIYDwu1vAvpitrIeJQOaYHGPq7Xhz9CzTk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DMgs2VZK; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DMgs2VZK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775679886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JFnc/hoWnWNjlce2sdwxKTuBgL3PkWnTdvy+3P6vOl8=; b=DMgs2VZKv3vUGvwWF9Yo7p1mjgHmZ2ly7E7RcB2dUUMoF7lDZVboEhA32xapmYX6UoYj64 1Mdm/97YON2QOS9Zum0HgZ0vZEZNbFaXEqaFLRBQTtCusMn2AL+fCoxoFAxhtSKr7fhwAI 0VtQD1mtj0rjqEYBRQKlkMo+rWpbzqM= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-322-t3WLZ3LtOAihF6-7EypfWg-1; Wed, 08 Apr 2026 16:23:20 -0400 X-MC-Unique: t3WLZ3LtOAihF6-7EypfWg-1 X-Mimecast-MFC-AGG-ID: t3WLZ3LtOAihF6-7EypfWg_1775679799 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1A681956060; Wed, 8 Apr 2026 20:23:18 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1A62D1800671; Wed, 8 Apr 2026 20:23:16 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 02/10] mm: introduce pgtable_has_pmd_leaves() Date: Wed, 8 Apr 2026 16:22:57 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Currently, we have two helpers that check for PMD-sized pages but have different names and slightly different semantics: - has_transparent_hugepage(): the name suggests it checks if THP is enabled, but when CONFIG_TRANSPARENT_HUGEPAGE=3Dy and the architecture implements this helper, it actually checks if the CPU supports PMD-sized pages - thp_disabled_by_hw(): the name suggests it checks if THP is disabled by the hardware, but it just returns a cached value acquired with has_transparent_hugepage(). This helper is used in fast paths This commit introduces a new helper called pgtable_has_pmd_leaves() which is intended to replace both has_transparent_hugepage() and thp_disabled_by_hw(). pgtable_has_pmd_leaves() has very clear semantics: it returns true if the CPU supports PMD-sized pages and false otherwise. It always returns a cached value, so it can be used in fast paths. The new helper requires an initialization step which is performed by init_arch_has_pmd_leaves(). We call init_arch_has_pmd_leaves() early during boot in start_kernel() right after parse_early_param() but before parse_args(). This allows early_param() handlers to change CPU flags if needed (eg. parse_memopt() in x86-32) while also allowing users to use the API from __setup() handlers. The next commits will convert users of both has_transparent_hugepage() and thp_disabled_by_hw() to pgtable_has_pmd_leaves(). Signed-off-by: Luiz Capitulino --- include/linux/pgtable.h | 15 +++++++++++++++ init/main.c | 1 + mm/memory.c | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index a50df42a893f..c4c5282f795c 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -2192,6 +2192,21 @@ static inline const char *pgtable_level_to_str(enum = pgtable_level level) } } =20 +#ifdef CONFIG_MMU +extern bool __arch_has_pmd_leaves; +static inline bool pgtable_has_pmd_leaves(void) +{ + return __arch_has_pmd_leaves; +} +void __init init_arch_has_pmd_leaves(void); +#else +static inline bool pgtable_has_pmd_leaves(void) +{ + return false; +} +static inline void __init init_arch_has_pmd_leaves(void) { } +#endif + #endif /* !__ASSEMBLY__ */ =20 #if !defined(MAX_POSSIBLE_PHYSMEM_BITS) && !defined(CONFIG_64BIT) diff --git a/init/main.c b/init/main.c index 1cb395dd94e4..07f2ddbf9677 100644 --- a/init/main.c +++ b/init/main.c @@ -1044,6 +1044,7 @@ void start_kernel(void) print_kernel_cmdline(saved_command_line); /* parameters may set static keys */ parse_early_param(); + init_arch_has_pmd_leaves(); after_dashes =3D parse_args("Booting kernel", static_command_line, __start___param, __stop___param - __start___param, diff --git a/mm/memory.c b/mm/memory.c index c65e82c86fed..5ee312c30f2d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -177,6 +177,14 @@ static int __init init_zero_pfn(void) } early_initcall(init_zero_pfn); =20 +bool __arch_has_pmd_leaves __read_mostly; +EXPORT_SYMBOL(__arch_has_pmd_leaves); + +void __init init_arch_has_pmd_leaves(void) +{ + __arch_has_pmd_leaves =3D has_transparent_hugepage(); +} + void mm_trace_rss_stat(struct mm_struct *mm, int member) { trace_rss_stat(mm, member); --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EA1436CDF8 for ; Wed, 8 Apr 2026 22:13:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775686397; cv=none; b=afIyiGwC2IamNynamJJFuDEbjGWaZXF50NRQKNgfRvUyNmD6CGuyx77tC7pziGAcywrcXbH1QWol1hzPUgoTrHIj8KJlO6atGPmS/z2aWdYhl/ALmX2gFo+YtlfaEgUmIqzI9beQtQujnKxNrHUN+TFDWFyonAZp3NTm+2VCdc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775686397; c=relaxed/simple; bh=xr1jshCH2k+Vu/tx4foKxPV/100Z30kwL1ZLsYvrouQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TfUEYNArAPkm6wQXbvI3F/rKh9LYbpZ/SkqlRVabN+n/cu3Z0QhvVkznNpm9MPWid2ID/9OFD+SmuuiHtAscQFUDU2PnhpiqJspB9TsuoAQo8bu6/T/uINDb4TrfaRK0SlnZYkUjrptBDSYOSxbNK2k7FTtQEd4DVkGa7ZKGTOI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=H0t0gU6J; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H0t0gU6J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775686395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jgcYXNV9AndVyM0eXgkCwf75FkwR80fy6ED6RTnrjIA=; b=H0t0gU6Je7JE2nJCvk6q/GY7lu/82OMgvz4+ahMjSC74P1oCLN3XwAMn5EYhnPSFzg+xE1 3GWYmHztS4EELvJmMhbf6qP9A/YlHYNGM126sI3Ohiaaeo6wzZaEnHrLfAiPcecnv4Y8iT Zwnov7Nw5T/poB+vREQcBcAowLgK0OE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-391-Ou9jisOEPRKsGiMinPWqKQ-1; Wed, 08 Apr 2026 16:23:21 -0400 X-MC-Unique: Ou9jisOEPRKsGiMinPWqKQ-1 X-Mimecast-MFC-AGG-ID: Ou9jisOEPRKsGiMinPWqKQ_1775679800 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 277821800620; Wed, 8 Apr 2026 20:23:20 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D8F6C180075D; Wed, 8 Apr 2026 20:23:18 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 03/10] drivers: dax: use pgtable_has_pmd_leaves() Date: Wed, 8 Apr 2026 16:22:58 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" dax_align_valid() uses has_transparent_hugepage() to check if PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead. Acked-by: David Hildenbrand (Red Hat) Signed-off-by: Luiz Capitulino --- drivers/dax/dax-private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h index c6ae27c982f4..97b577f4107b 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -119,7 +119,7 @@ static inline bool dax_align_valid(unsigned long align) { if (align =3D=3D PUD_SIZE && IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGE= PAGE_PUD)) return true; - if (align =3D=3D PMD_SIZE && has_transparent_hugepage()) + if (align =3D=3D PMD_SIZE && pgtable_has_pmd_leaves()) return true; if (align =3D=3D PAGE_SIZE) return true; --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46C9133A9D6 for ; Wed, 8 Apr 2026 20:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679967; cv=none; b=oqxozpJtksgDS9v+39BXf0opfKuvLLiqqXLCJQIM89K1swQHE9UHAfUM/CU+Gkk/svNj7LnmaZ71vXH8BWz7rEDAaus6Bd4lMXhj1WCz/s5CXqKQKJ4ozvfYndB3lExghm2ZRiGNmKGiIYIJQbqxV8pH/niD2YdmfRdhy6NfP94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679967; c=relaxed/simple; bh=8OOXRsh6icF1s+Qw85I/0fWIl3fhaJ0yvKsKG9RB43Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hPSvlEi74qK9B1pJNCTd/+BDSOuLEwBQz+ZNYww3XOhFbgZb+jdxAJpIKwEV5xlJgjAXsS6IhleAPIViX0R3l6G9yUmFb4tLfY+B0E8fEAEm27f/2CUVIRnzqCIKPwgGM4JTZ71aT21xrvZ+BHSQLo4VtA3Kw5Y3unvMs6xxUeg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=KJzRcB+k; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KJzRcB+k" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775679965; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TBg+N1vPihTVzt5Os9wJA+I+ybP1ihgxx5kCeaXYvp0=; b=KJzRcB+kT7s+qp3ifb+jbqSkAwwg5Lf6EGDP+p2NxVRozRz+nCmRX1nUpVmJl63Oda3GST 6NpORY4GTMg9UZ+43TxviuevYZf/Mbtbdzvy737NcD1OSUW/LjkKrYXPwo2CtsBE2q7AkK 3K3E/ClTDMspdRTAbG7d9Y7Xjxb3U/w= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-146-7scCV4SDNpGdAdTAdm9izg-1; Wed, 08 Apr 2026 16:23:25 -0400 X-MC-Unique: 7scCV4SDNpGdAdTAdm9izg-1 X-Mimecast-MFC-AGG-ID: 7scCV4SDNpGdAdTAdm9izg_1775679801 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7558C1956050; Wed, 8 Apr 2026 20:23:21 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 59F8B180036E; Wed, 8 Apr 2026 20:23:20 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 04/10] drivers: nvdimm: use pgtable_has_pmd_leaves() Date: Wed, 8 Apr 2026 16:22:59 -0400 Message-ID: <0309be4a7133ba8d043380f0c3614af764f6e3c9.1775679721.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" nd_pfn_supported_alignments() and nd_pfn_default_alignment() use has_transparent_hugepage() to check if THP is supported with PMD-sized pages. Use pgtable_has_pmd_leaves() instead. Also, check for IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) to preserve the current implementation semantics. Signed-off-by: Luiz Capitulino --- drivers/nvdimm/pfn_devs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 8fa9c16aba7e..457eb54e7ab6 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -94,7 +94,8 @@ static unsigned long *nd_pfn_supported_alignments(unsigne= d long *alignments) =20 alignments[0] =3D PAGE_SIZE; =20 - if (has_transparent_hugepage()) { + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && + pgtable_has_pmd_leaves()) { alignments[1] =3D HPAGE_PMD_SIZE; if (has_transparent_pud_hugepage()) alignments[2] =3D HPAGE_PUD_SIZE; @@ -109,7 +110,8 @@ static unsigned long *nd_pfn_supported_alignments(unsig= ned long *alignments) static unsigned long nd_pfn_default_alignment(void) { =20 - if (has_transparent_hugepage()) + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && + pgtable_has_pmd_leaves()) return HPAGE_PMD_SIZE; return PAGE_SIZE; } --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FCDB38F947 for ; Wed, 8 Apr 2026 20:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679910; cv=none; b=s/zU/REhuCZhjVw5/5CDCdy0VLkjMWNQCrgSVt2/QDfhSCsJ+wcw3sfCspCi2wIcIeg+Oq8S4lX8LzwCYgzL8X+iG3TVA39yFSWCc4JJD+bcwVl94pKr04Ch8NpCRp7XGTeAO/e5wsQhoP7+TkVNzdTGeYdKBvArks11y3+pXbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679910; c=relaxed/simple; bh=cyZcikY1KhdSe/t5yWAiMe2ex84dhHxjPf9mrV8guWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KLVpKbMvs26+xV/J3vSvihoFpK52dxto9BZggNSzPv762tjUe0grEjPx2lhk90bGM7ij1nitHZiJ/5ayi1yRT+4JjPh1hdFyn7sRsvPUkzHa/51Adwnu4DDNQdaubUgP95xTFXYEhQR/5OnLbOuW1TY/oh+7QR1+x6gFqPEOnxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BuSccy0A; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BuSccy0A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775679908; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ocXpUd1XebeFjlQJT4jQORXT8cqN1+0QrAJ22mdd8PQ=; b=BuSccy0A5//varDCSFDEnUDSnj0lZM1tPq4cANY8ebn4PBgug5GF0RqTNw5+bBWMYn7R5W 1aMxFDVZl3KAserLImbF8DTee37czU4hgeyVuw8PV2aeM5IPs9KMKTlYz5x2HiGWQfnYZz nyyXcnKS2ZYNxj847RnbKK5VO864pFo= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-W-6NM3x0Paa9CMaDurZEow-1; Wed, 08 Apr 2026 16:23:25 -0400 X-MC-Unique: W-6NM3x0Paa9CMaDurZEow-1 X-Mimecast-MFC-AGG-ID: W-6NM3x0Paa9CMaDurZEow_1775679802 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C91E21800617; Wed, 8 Apr 2026 20:23:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ADDBA1800671; Wed, 8 Apr 2026 20:23:21 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 05/10] mm: debug_vm_pgtable: use pgtable_has_pmd_leaves() Date: Wed, 8 Apr 2026 16:23:00 -0400 Message-ID: <18d82575497d06a4d18605ae33f9c22e08a3209e.1775679721.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" debug_vm_pgtable calls has_transparent_hugepage() in multiple places to check if PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead. Signed-off-by: Luiz Capitulino --- mm/debug_vm_pgtable.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c index 83cf07269f13..b3e30baaeceb 100644 --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -177,7 +177,7 @@ static void __init pmd_basic_tests(struct pgtable_debug= _args *args, int idx) unsigned long val =3D idx, *ptr =3D &val; pmd_t pmd; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD basic (%pGv)\n", ptr); @@ -222,7 +222,7 @@ static void __init pmd_advanced_tests(struct pgtable_de= bug_args *args) pmd_t pmd; unsigned long vaddr =3D args->vaddr; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 page =3D (args->pmd_pfn !=3D ULONG_MAX) ? pfn_to_page(args->pmd_pfn) : NU= LL; @@ -283,7 +283,7 @@ static void __init pmd_leaf_tests(struct pgtable_debug_= args *args) { pmd_t pmd; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD leaf\n"); @@ -688,7 +688,7 @@ static void __init pmd_protnone_tests(struct pgtable_de= bug_args *args) if (!IS_ENABLED(CONFIG_NUMA_BALANCING)) return; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD protnone\n"); @@ -737,7 +737,7 @@ static void __init pmd_soft_dirty_tests(struct pgtable_= debug_args *args) if (!pgtable_supports_soft_dirty()) return; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD soft dirty\n"); @@ -754,7 +754,7 @@ static void __init pmd_leaf_soft_dirty_tests(struct pgt= able_debug_args *args) !IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION)) return; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD swap soft dirty\n"); @@ -825,7 +825,7 @@ static void __init pmd_softleaf_tests(struct pgtable_de= bug_args *args) swp_entry_t arch_entry; pmd_t pmd1, pmd2; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD swap\n"); @@ -906,7 +906,7 @@ static void __init pmd_thp_tests(struct pgtable_debug_a= rgs *args) { pmd_t pmd; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD based THP\n"); @@ -997,7 +997,7 @@ static void __init destroy_args(struct pgtable_debug_ar= gs *args) } =20 if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - has_transparent_hugepage() && + pgtable_has_pmd_leaves() && args->pmd_pfn !=3D ULONG_MAX) { debug_vm_pgtable_free_huge_page(args, args->pmd_pfn, HPAGE_PMD_ORDER); args->pmd_pfn =3D ULONG_MAX; @@ -1249,7 +1249,7 @@ static int __init init_args(struct pgtable_debug_args= *args) } =20 if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - has_transparent_hugepage()) { + pgtable_has_pmd_leaves()) { page =3D debug_vm_pgtable_alloc_huge_page(args, HPAGE_PMD_ORDER); if (page) { args->pmd_pfn =3D page_to_pfn(page); --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57D7726F29B for ; Wed, 8 Apr 2026 20:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679811; cv=none; b=mlKkcwqV9CBCUt5UDIz3jW2XDCQfv/YHqEr4HZSIB9IoeeJUYw95ycGvPPC9PwQSk1tw6F1Sl0xGZSgj/nAx6qqYYRK74s+mU0Wp+XckSzTji++XnJhJFWbtD6DZPiWLaXyWq4H70HLGopJ7I6pLxpu1JHkF82+qLMYJo0dI8/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679811; c=relaxed/simple; bh=Tc/awDkzU9qcgltmqzKtUgiM8h9RbSxXQ2gu/CkEEuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=naonLXSNDQ4JtiwFjJ0wMLPfmU7Dahcepwjf8KVA1XiI4/T42Mm8GIZpJAukW1X/a8Iwbn+03E09Ptdm9uX9WUTDuhJfAD6pDveRYi1SANBkd+Sx3Nzt3ZsJxcKVK98b8vrkl15pZad647Ae0sH03EDTwDcwK90Qmg2ILen4BWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TgNgpJuW; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TgNgpJuW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775679809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dpd53IYBKPxfvsuuiOqR/eqPWf1cD9+LMYnfXG431mU=; b=TgNgpJuW/PrSgM5qVETFUIIyi6WEnlfAsSp9NEstUnJCxc9e5bR2EArhxRJ4suu/94J8Jc YQIXtZWt0DaBUZSxIZTOTf+XTnDSKK/xPJ7iYv9Op8DByg4V/IhOguaimUqGemKfS2R6w7 0we1/OCMm4Vj1MQmDbLhUDZmZfgw7BA= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-246-CwFTT27VPcaMhy004THKQg-1; Wed, 08 Apr 2026 16:23:25 -0400 X-MC-Unique: CwFTT27VPcaMhy004THKQg-1 X-Mimecast-MFC-AGG-ID: CwFTT27VPcaMhy004THKQg_1775679804 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 65E6A18005BB; Wed, 8 Apr 2026 20:23:24 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0BF50180075C; Wed, 8 Apr 2026 20:23:22 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 06/10] mm: shmem: drop has_transparent_hugepage() usage Date: Wed, 8 Apr 2026 16:23:01 -0400 Message-ID: <020a4fe05e8ac52ca47c27b0fbb6a07c163a118f.1775679721.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Shmem uses has_transparent_hugepage() in the following ways: - shmem_parse_one() and shmem_parse_huge(): Check if THP is built-in and if the CPU supports PMD-sized pages - shmem_init(): Since the CONFIG_TRANSPARENT_HUGEPAGE guard is outside the code block calling has_transparent_hugepage(), the has_transparent_hugepage() call is exclusively checking if the CPU supports PMD-sized pages While it's necessary to check if CONFIG_TRANSPARENT_HUGEPAGE is enabled in all cases, shmem can determine mTHP size support at folio allocation time. Therefore, drop has_transparent_hugepage() usage while keeping the CONFIG_TRANSPARENT_HUGEPAGE checks. Signed-off-by: Luiz Capitulino --- mm/shmem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index b40f3cd48961..6f8b20d77e07 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -689,7 +689,7 @@ static int shmem_parse_huge(const char *str) else return -EINVAL; =20 - if (!has_transparent_hugepage() && + if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && huge !=3D SHMEM_HUGE_NEVER && huge !=3D SHMEM_HUGE_DENY) return -EINVAL; =20 @@ -4664,8 +4664,7 @@ static int shmem_parse_one(struct fs_context *fc, str= uct fs_parameter *param) case Opt_huge: ctx->huge =3D result.uint_32; if (ctx->huge !=3D SHMEM_HUGE_NEVER && - !(IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - has_transparent_hugepage())) + !IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) goto unsupported_parameter; ctx->seen |=3D SHMEM_SEEN_HUGE; break; @@ -5451,7 +5450,7 @@ void __init shmem_init(void) #endif =20 #ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY) + if (shmem_huge > SHMEM_HUGE_DENY) SHMEM_SB(shm_mnt->mnt_sb)->huge =3D shmem_huge; else shmem_huge =3D SHMEM_HUGE_NEVER; /* just in case it was patched */ --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AED4391518 for ; Wed, 8 Apr 2026 20:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679814; cv=none; b=md5LF8b+YXr8vaJgi0/pYox6ikvPDw8rUzfGoX3wrqO9nT5H/Hsq2bzrrSqSS8+ROwA7/i/eRZIf2DwfpMAdMHbxCW0ZQJPZxztfP1V5SbOxbylES9gMDkSVwaHYe6r1aTM585qhcZ8oc6+Sq3RXPM18Ov3GnySNp0OM8x7A3AM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679814; c=relaxed/simple; bh=b72ntyP0ytf/9QXLnj+zUCqmiR5iD+p1szq8ZBupPHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TD0jysfpPwSCuvySmHbhHFs/3nFQGS5R4BfnDkIl6qiHggZYhSMmBPw8MU0mSrCvPNm9igDzybylCyQA3aPxw7bIT/kxxeBSiL5tNx1FxTk+4PQvVvBR2DSUVZHnY8LBac6+HCWazaFXqSq/to9KiYTLlmk9C7kteVo9gjvBhjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LBCdAQHh; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LBCdAQHh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775679811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sMILsKyKkjAgwbk1mi7gAYhxxmVLpdhMMj3vgFOlQbU=; b=LBCdAQHhypqLSGp4h1kmHQOVbfQykRVpCpV5uJqCyXTcmmDLaBIJQuhNpWcKVaW8711DRi BGyd7sb/WovgFXEWcY0sr4gQQAnCejE6HYpATncLFqmiiwTRWf6E4McXIaypTCgNzgoB4G D3npFiWPGD57msmETgjcnAQ6q0zuZ68= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-KmQ_8gqlOUio8jhAtiEmXw-1; Wed, 08 Apr 2026 16:23:28 -0400 X-MC-Unique: KmQ_8gqlOUio8jhAtiEmXw-1 X-Mimecast-MFC-AGG-ID: KmQ_8gqlOUio8jhAtiEmXw_1775679805 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B697D1956052; Wed, 8 Apr 2026 20:23:25 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9C9BB1800673; Wed, 8 Apr 2026 20:23:24 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 07/10] treewide: rename has_transparent_hugepage() to arch_has_pmd_leaves() Date: Wed, 8 Apr 2026 16:23:02 -0400 Message-ID: <4f640655f26b4cc2056a62bebfd570686dd6dc3c.1775679721.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Now that all the has_transparent_hugepage() callers have been converted to pgtable_has_pmd_leaves(), rename has_transparent_hugepage() to arch_has_pmd_leaves() since that's what the helper checks for. arch_has_pmd_leaves() is supposed to be called only by init_arch_has_pmd_leaves(). The remaining exception is hugepage_init() which will be converted in a future commit. Signed-off-by: Luiz Capitulino --- arch/mips/include/asm/pgtable.h | 4 ++-- arch/mips/mm/tlb-r4k.c | 4 ++-- arch/powerpc/include/asm/book3s/64/hash-4k.h | 2 +- arch/powerpc/include/asm/book3s/64/hash-64k.h | 2 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 10 +++++----- arch/powerpc/include/asm/book3s/64/radix.h | 2 +- arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++-- arch/s390/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable.h | 4 ++-- include/linux/pgtable.h | 4 ++-- mm/huge_memory.c | 2 +- mm/memory.c | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtabl= e.h index fa7b935f947c..a97b788315e2 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -615,8 +615,8 @@ unsigned long io_remap_pfn_range_pfn(unsigned long pfn,= unsigned long size); /* We don't have hardware dirty/accessed bits, generic_pmdp_establish is f= ine.*/ #define pmdp_establish generic_pmdp_establish =20 -#define has_transparent_hugepage has_transparent_hugepage -extern int has_transparent_hugepage(void); +#define arch_has_pmd_leaves arch_has_pmd_leaves +extern int arch_has_pmd_leaves(void); =20 static inline int pmd_trans_huge(pmd_t pmd) { diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 24fe85fa169d..c423b5784337 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -434,7 +434,7 @@ void add_wired_entry(unsigned long entrylo0, unsigned l= ong entrylo1, =20 #ifdef CONFIG_TRANSPARENT_HUGEPAGE =20 -int has_transparent_hugepage(void) +int arch_has_pmd_leaves(void) { static unsigned int mask =3D -1; =20 @@ -450,7 +450,7 @@ int has_transparent_hugepage(void) } return mask =3D=3D PM_HUGE_MASK; } -EXPORT_SYMBOL(has_transparent_hugepage); +EXPORT_SYMBOL(arch_has_pmd_leaves); =20 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/in= clude/asm/book3s/64/hash-4k.h index 8e5bd9902bed..6744c2287199 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h @@ -165,7 +165,7 @@ extern void hash__pgtable_trans_huge_deposit(struct mm_= struct *mm, pmd_t *pmdp, extern pgtable_t hash__pgtable_trans_huge_withdraw(struct mm_struct *mm, p= md_t *pmdp); extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp); -extern int hash__has_transparent_hugepage(void); +extern int hash__arch_has_pmd_leaves(void); #endif =20 #endif /* !__ASSEMBLER__ */ diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/i= nclude/asm/book3s/64/hash-64k.h index 7deb3a66890b..9392aba5e5dc 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h @@ -278,7 +278,7 @@ extern void hash__pgtable_trans_huge_deposit(struct mm_= struct *mm, pmd_t *pmdp, extern pgtable_t hash__pgtable_trans_huge_withdraw(struct mm_struct *mm, p= md_t *pmdp); extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp); -extern int hash__has_transparent_hugepage(void); +extern int hash__arch_has_pmd_leaves(void); #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 #endif /* __ASSEMBLER__ */ diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/in= clude/asm/book3s/64/pgtable.h index 1a91762b455d..e4d9b884af5c 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1121,14 +1121,14 @@ static inline void update_mmu_cache_pud(struct vm_a= rea_struct *vma, { } =20 -extern int hash__has_transparent_hugepage(void); -static inline int has_transparent_hugepage(void) +extern int hash__arch_has_pmd_leaves(void); +static inline int arch_has_pmd_leaves(void) { if (radix_enabled()) - return radix__has_transparent_hugepage(); - return hash__has_transparent_hugepage(); + return radix__arch_has_pmd_leaves(); + return hash__arch_has_pmd_leaves(); } -#define has_transparent_hugepage has_transparent_hugepage +#define arch_has_pmd_leaves arch_has_pmd_leaves =20 static inline int has_transparent_pud_hugepage(void) { diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/incl= ude/asm/book3s/64/radix.h index da954e779744..c884a119cbd9 100644 --- a/arch/powerpc/include/asm/book3s/64/radix.h +++ b/arch/powerpc/include/asm/book3s/64/radix.h @@ -298,7 +298,7 @@ extern pmd_t radix__pmdp_huge_get_and_clear(struct mm_s= truct *mm, pud_t radix__pudp_huge_get_and_clear(struct mm_struct *mm, unsigned long addr, pud_t *pudp); =20 -static inline int radix__has_transparent_hugepage(void) +static inline int radix__arch_has_pmd_leaves(void) { /* For radix 2M at PMD level means thp */ if (mmu_psize_defs[MMU_PAGE_2M].shift =3D=3D PMD_SHIFT) diff --git a/arch/powerpc/mm/book3s64/hash_pgtable.c b/arch/powerpc/mm/book= 3s64/hash_pgtable.c index ac2a24d15d2e..f7933c52cca9 100644 --- a/arch/powerpc/mm/book3s64/hash_pgtable.c +++ b/arch/powerpc/mm/book3s64/hash_pgtable.c @@ -370,7 +370,7 @@ pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *m= m, return old_pmd; } =20 -int hash__has_transparent_hugepage(void) +int hash__arch_has_pmd_leaves(void) { =20 if (!mmu_has_feature(MMU_FTR_16M_PAGE)) @@ -399,7 +399,7 @@ int hash__has_transparent_hugepage(void) =20 return 1; } -EXPORT_SYMBOL_GPL(hash__has_transparent_hugepage); +EXPORT_SYMBOL_GPL(hash__arch_has_pmd_leaves); =20 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtabl= e.h index 1c3c3be93be9..e638d914fbad 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1776,8 +1776,8 @@ static inline int pmd_trans_huge(pmd_t pmd) return pmd_leaf(pmd); } =20 -#define has_transparent_hugepage has_transparent_hugepage -static inline int has_transparent_hugepage(void) +#define arch_has_pmd_leaves arch_has_pmd_leaves +static inline int arch_has_pmd_leaves(void) { return cpu_has_edat1() ? 1 : 0; } diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 1662c5a8f445..8fe95270b713 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -314,8 +314,8 @@ static inline int pud_trans_huge(pud_t pud) } #endif =20 -#define has_transparent_hugepage has_transparent_hugepage -static inline int has_transparent_hugepage(void) +#define arch_has_pmd_leaves arch_has_pmd_leaves +static inline int arch_has_pmd_leaves(void) { return boot_cpu_has(X86_FEATURE_PSE); } diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index c4c5282f795c..4b52a3abeab5 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -2222,8 +2222,8 @@ static inline void __init init_arch_has_pmd_leaves(vo= id) { } #endif #endif =20 -#ifndef has_transparent_hugepage -#define has_transparent_hugepage() IS_BUILTIN(CONFIG_TRANSPARENT_HUGEPAGE) +#ifndef arch_has_pmd_leaves +#define arch_has_pmd_leaves() IS_BUILTIN(CONFIG_TRANSPARENT_HUGEPAGE) #endif =20 #ifndef has_transparent_pud_hugepage diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b298cba853ab..9e4889d1673f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -908,7 +908,7 @@ static int __init hugepage_init(void) int err; struct kobject *hugepage_kobj; =20 - if (!has_transparent_hugepage()) { + if (!arch_has_pmd_leaves()) { transparent_hugepage_flags =3D 1 << TRANSPARENT_HUGEPAGE_UNSUPPORTED; return -EINVAL; } diff --git a/mm/memory.c b/mm/memory.c index 5ee312c30f2d..87a65f6eabfb 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -182,7 +182,7 @@ EXPORT_SYMBOL(__arch_has_pmd_leaves); =20 void __init init_arch_has_pmd_leaves(void) { - __arch_has_pmd_leaves =3D has_transparent_hugepage(); + __arch_has_pmd_leaves =3D arch_has_pmd_leaves(); } =20 void mm_trace_rss_stat(struct mm_struct *mm, int member) --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 007C23DB636 for ; Wed, 8 Apr 2026 20:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775680747; cv=none; b=nH9sPL5nDnwOaf0hf35LqY2o+eQ2cQxtpSL6unDEuyXErq29K8m+XhIVmIjawyciRXuZfqWDR8euWaReX/zc9AVMJm4bGZxQT6XIgoK+zpoE4Ld66ad15I0gOcz1sKyS4bTNfux/BARhShqhtXtt4OeQhG2RrAWesTDXpBPyE2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775680747; c=relaxed/simple; bh=L/bRT1T8vdtz6U6KXcEidtC0So3piDUr9vzBhuqebrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jMv/eVGEUcjvVREoV1InTSYd5WtcBvlbGVk7ym1NIsVK9U0avN9x5OSro/4UYN1SOytZUyIkI5tn2iz+MvFdgii+18txjb3Hza5vi37VQPbUWR9UbAAD5EZsnftzR2VAW9Yp9WBiB31FjyA2BI4MWpyUPp7KeCfDiw4WvunbSYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fC3BS80n; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fC3BS80n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775680745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q5DLMjRaVolqsbGTCRhcQShr1myO/MYUO5PjIwdLZWU=; b=fC3BS80nLtShmP5QT1BAFImZwcwCWINw4jnO7Rp0rySUthawzsHQrNFwvU0PGiDVStAf0c 1dYf8iC57HW0CWjlAx5c0He4Q8/Ikr9zNrtxKFB5hIRWyXUlQmwU2gpEMck5s6J5/XpLDP jDI4ZD2ICF1xnaKarYwlrqtd2FCzfcE= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-393-9S6wRMOHNjqFBwrQOGi0LQ-1; Wed, 08 Apr 2026 16:23:28 -0400 X-MC-Unique: 9S6wRMOHNjqFBwrQOGi0LQ-1 X-Mimecast-MFC-AGG-ID: 9S6wRMOHNjqFBwrQOGi0LQ_1775679807 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 17F7F18005B6; Wed, 8 Apr 2026 20:23:27 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EE09C180075B; Wed, 8 Apr 2026 20:23:25 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 08/10] mm: replace thp_disabled_by_hw() with pgtable_has_pmd_leaves() Date: Wed, 8 Apr 2026 16:23:03 -0400 Message-ID: <9432a2398caef7261ca44355fb7b786bb20bc15e.1775679721.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Despite its name, thp_disabled_by_hw() just checks whether the architecture supports PMD-sized pages. It returns true when TRANSPARENT_HUGEPAGE_UNSUPPORTED is set in transparent_hugepage_flags, this only occurs if the architecture implements arch_has_pmd_leaves() and that function returns false. Since pgtable_has_pmd_leaves() provides the same semantics, use it instead. Signed-off-by: Luiz Capitulino --- include/linux/huge_mm.h | 7 ------- mm/huge_memory.c | 6 ++---- mm/memory.c | 2 +- mm/shmem.c | 2 +- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index a4d9f964dfde..e291a650b10f 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -47,7 +47,6 @@ vm_fault_t vmf_insert_folio_pud(struct vm_fault *vmf, str= uct folio *folio, bool write); =20 enum transparent_hugepage_flag { - TRANSPARENT_HUGEPAGE_UNSUPPORTED, TRANSPARENT_HUGEPAGE_FLAG, TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG, TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, @@ -352,12 +351,6 @@ static inline bool vma_thp_disabled(struct vm_area_str= uct *vma, return mm_flags_test(MMF_DISABLE_THP_EXCEPT_ADVISED, vma->vm_mm); } =20 -static inline bool thp_disabled_by_hw(void) -{ - /* If the hardware/firmware marked hugepage support disabled. */ - return transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_UNSUPPORTE= D); -} - unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); unsigned long thp_get_unmapped_area_vmflags(struct file *filp, unsigned lo= ng addr, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9e4889d1673f..86e489c0a150 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -125,7 +125,7 @@ unsigned long __thp_vma_allowable_orders(struct vm_area= _struct *vma, if (!vma->vm_mm) /* vdso */ return 0; =20 - if (thp_disabled_by_hw() || vma_thp_disabled(vma, vm_flags, forced_collap= se)) + if (!pgtable_has_pmd_leaves() || vma_thp_disabled(vma, vm_flags, forced_c= ollapse)) return 0; =20 /* khugepaged doesn't collapse DAX vma, but page fault is fine. */ @@ -908,10 +908,8 @@ static int __init hugepage_init(void) int err; struct kobject *hugepage_kobj; =20 - if (!arch_has_pmd_leaves()) { - transparent_hugepage_flags =3D 1 << TRANSPARENT_HUGEPAGE_UNSUPPORTED; + if (!pgtable_has_pmd_leaves()) return -EINVAL; - } =20 /* * hugepages can't be allocated by the buddy allocator diff --git a/mm/memory.c b/mm/memory.c index 87a65f6eabfb..29cb4ea33ba0 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5427,7 +5427,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct fo= lio *folio, struct page *pa * PMD mappings if THPs are disabled. As we already have a THP, * behave as if we are forcing a collapse. */ - if (thp_disabled_by_hw() || vma_thp_disabled(vma, vma->vm_flags, + if (!pgtable_has_pmd_leaves() || vma_thp_disabled(vma, vma->vm_flags, /* forced_collapse=3D*/ true)) return ret; =20 diff --git a/mm/shmem.c b/mm/shmem.c index 6f8b20d77e07..613393eae5a9 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1839,7 +1839,7 @@ unsigned long shmem_allowable_huge_orders(struct inod= e *inode, vm_flags_t vm_flags =3D vma ? vma->vm_flags : 0; unsigned int global_orders; =20 - if (thp_disabled_by_hw() || (vma && vma_thp_disabled(vma, vm_flags, shmem= _huge_force))) + if (!pgtable_has_pmd_leaves() || (vma && vma_thp_disabled(vma, vm_flags, = shmem_huge_force))) return 0; =20 global_orders =3D shmem_huge_global_enabled(inode, index, write_end, --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 801BD38F94A for ; Wed, 8 Apr 2026 20:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679816; cv=none; b=TcjHJRnJMmL0KsvZ7C1xKfd8tVMYUuVl7Q8KEASqYGBleC8YQ9KICg2y6ZHeTm/uIkTjE/VuspPoQTbGVpMWOl2940aDsDPlof+BXEv7G+Lh3wBJCHZiFR3YJ9Ivzyq0jnc4h+PbIYebYdkL51JPEGTpcRfhhxE/77hnyl9vsZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679816; c=relaxed/simple; bh=iArTyi2V/4c9LLoSsOUqpFzZcNSNLXWOzYr1MEiSCFk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RkY9U1sTQ9EmOJoOfBmk7+uK+RC4FN2uBxIiqDmbkfkGdJ+Qx6IzNg6/z1b7T2NxVYTC/sdckHMIj2mpoR8IxfY11WJRy68PiOBQObT0yCtc2ll2IjBKs9EcjqceNN1I0kWz8/sZT4XR3d+2MQFLuL0rXD5IBeILPjiJi/WzL2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZQuFmBoU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZQuFmBoU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775679814; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+7hGKGZGeLjF560FpYHuHn8OsBr5eDLDlL3Qi8Vk24g=; b=ZQuFmBoUGHw8TJTY78oF+bZh6TCO9PQeO3j9R8uh6tAhfYLz2UpxKkHLbW9cfYGDo/TXK+ Zq8hfJiS3lNeZAi5zFvnUb5vzLG1Ai0sRpyHdVjKoEPsLvDgltCafEB2QAFDX2MCKJXUY1 AEBTyQth1JDzLQ28SuW72R4+mBuRONI= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-2BpvvUxYPdC4kJPgcnusLw-1; Wed, 08 Apr 2026 16:23:30 -0400 X-MC-Unique: 2BpvvUxYPdC4kJPgcnusLw-1 X-Mimecast-MFC-AGG-ID: 2BpvvUxYPdC4kJPgcnusLw_1775679808 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9CAA51955F16; Wed, 8 Apr 2026 20:23:28 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4FFE2180075B; Wed, 8 Apr 2026 20:23:27 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 09/10] mm: thp: always enable mTHP support Date: Wed, 8 Apr 2026 16:23:04 -0400 Message-ID: <6dea717fe8c86003e7da33c9a7623b834649d5ee.1775679721.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" If PMD-sized pages are not supported on an architecture (ie. the arch implements arch_has_pmd_leaves() and it returns false) then the current code disables all THP, including mTHP. This commit fixes this by allowing mTHP to be always enabled for all archs. When PMD-sized pages are not supported, its sysfs entry won't be created and their mapping will be disallowed at page-fault time. Similarly, this commit implements the following changes for shmem: - In shmem_allowable_huge_orders(): drop the pgtable_has_pmd_leaves() check so that mTHP sizes are considered - In shmem_alloc_and_add_folio(): don't consider PMD and PUD orders when PMD-sized pages are not supported by the CPU Signed-off-by: Luiz Capitulino --- mm/huge_memory.c | 13 ++++++++----- mm/shmem.c | 4 +++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 86e489c0a150..6de3d8ebc35c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -118,6 +118,9 @@ unsigned long __thp_vma_allowable_orders(struct vm_area= _struct *vma, else supported_orders =3D THP_ORDERS_ALL_FILE_DEFAULT; =20 + if (!pgtable_has_pmd_leaves()) + supported_orders &=3D ~(BIT(PMD_ORDER) | BIT(PUD_ORDER)); + orders &=3D supported_orders; if (!orders) return 0; @@ -125,7 +128,7 @@ unsigned long __thp_vma_allowable_orders(struct vm_area= _struct *vma, if (!vma->vm_mm) /* vdso */ return 0; =20 - if (!pgtable_has_pmd_leaves() || vma_thp_disabled(vma, vm_flags, forced_c= ollapse)) + if (vma_thp_disabled(vma, vm_flags, forced_collapse)) return 0; =20 /* khugepaged doesn't collapse DAX vma, but page fault is fine. */ @@ -787,7 +790,7 @@ static int __init hugepage_init_sysfs(struct kobject **= hugepage_kobj) * disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - if (!anon_orders_configured) + if (!anon_orders_configured && pgtable_has_pmd_leaves()) huge_anon_orders_inherit =3D BIT(PMD_ORDER); =20 *hugepage_kobj =3D kobject_create_and_add("transparent_hugepage", mm_kobj= ); @@ -809,6 +812,9 @@ static int __init hugepage_init_sysfs(struct kobject **= hugepage_kobj) } =20 orders =3D THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE_DEFAULT; + if (!pgtable_has_pmd_leaves()) + orders &=3D ~(BIT(PMD_ORDER) | BIT(PUD_ORDER)); + order =3D highest_order(orders); while (orders) { thpsize =3D thpsize_create(order, *hugepage_kobj); @@ -908,9 +914,6 @@ static int __init hugepage_init(void) int err; struct kobject *hugepage_kobj; =20 - if (!pgtable_has_pmd_leaves()) - return -EINVAL; - /* * hugepages can't be allocated by the buddy allocator */ diff --git a/mm/shmem.c b/mm/shmem.c index 613393eae5a9..b49a30475cb0 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1839,7 +1839,7 @@ unsigned long shmem_allowable_huge_orders(struct inod= e *inode, vm_flags_t vm_flags =3D vma ? vma->vm_flags : 0; unsigned int global_orders; =20 - if (!pgtable_has_pmd_leaves() || (vma && vma_thp_disabled(vma, vm_flags, = shmem_huge_force))) + if (vma && vma_thp_disabled(vma, vm_flags, shmem_huge_force)) return 0; =20 global_orders =3D shmem_huge_global_enabled(inode, index, write_end, @@ -1947,6 +1947,8 @@ static struct folio *shmem_alloc_and_add_folio(struct= vm_fault *vmf, =20 if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) orders =3D 0; + else if (!pgtable_has_pmd_leaves()) + orders &=3D ~(BIT(PMD_ORDER) | BIT(PUD_ORDER)); =20 if (orders > 0) { suitable_orders =3D shmem_suitable_orders(inode, vmf, --=20 2.53.0 From nobody Thu Apr 9 09:01:39 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90C533914F0 for ; Wed, 8 Apr 2026 20:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679817; cv=none; b=mO12VDS+kqz9bUyqY7VPFJa3S4lzifeDuZlgioj4SPFFwQw7k5YX2xpghkqEY8fv6chrd7z61m6HZFzCOKk2RFmGZTCuJs5Z8zW9VcP6OliNMkPNItvaQaSLcO3F3BfAzj+TgIa1fg9CJiD8+p64CX0YI/Q1yjFYp/UkPkokwqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775679817; c=relaxed/simple; bh=S6DQtHxrjDJFmVb3FZEmTutPQAWxrjtors1RlQD01RU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PyrQPWiVr0erROZMaiJL0jeBpeGlU1HCyJ4EmlFUcjxjPTg3bhIZv1MdMlx0xTAFBbWNgGQotj5MUjpPdUDrWu7/WBr4PUuiN0ioFv3sy4AuOn/Q1ZF5jmY82vHxvHby2fIIHekszcK7rX+gqn/gTTRKmmvF5r/UjkaO16BYb/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LRme6iKL; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LRme6iKL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775679815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WtFsGlXVCNZRVs1NDyUPzRrR7AVvNvSaLq5qYA3VmaU=; b=LRme6iKLATe11hCx/6qHaXf4YRayCsdQyNbq2f3dE6Semekorx+1QZj4s1HrBCOZn1sb9I ak6O6R+jXz+l0Z5KahwlHamIYcy2Nq3ux4b2M9ks/LSsZL7ZoKEZX0o4DDHmkFQQhMpO8y tlXETDPl2I0Ko4699sV/XRueShHv+5Q= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-aSJQ2lfzPeqXC-V-aCP5oQ-1; Wed, 08 Apr 2026 16:23:32 -0400 X-MC-Unique: aSJQ2lfzPeqXC-V-aCP5oQ-1 X-Mimecast-MFC-AGG-ID: aSJQ2lfzPeqXC-V-aCP5oQ_1775679810 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EC4EE1955E8C; Wed, 8 Apr 2026 20:23:29 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.88.140]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D3043180036E; Wed, 8 Apr 2026 20:23:28 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH v3 10/10] mm: thp: x86: cleanup PSE feature bit usage Date: Wed, 8 Apr 2026 16:23:05 -0400 Message-ID: <16fe2db0becab98db70f53e4ce1422450a9f40ee.1775679721.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Historically, THP support on x86 checked the PSE feature bit to enable THP. On 64-bit, this check is redundant since PSE is always enabled by default for compatibility. On 32-bit, PSE can enable 2 MiB or 4 MiB page sizes so it must be checked. To clean this up, this commit: 1. Drops arch_has_pmd_leaves() from common x86 code. For 64-bit, we assume PMD-sized pages are always supported 2. Checks for PSE only on 32-bit by implementing arch_has_pmd_leaves() Signed-off-by: Luiz Capitulino --- arch/x86/include/asm/pgtable.h | 6 ------ arch/x86/include/asm/pgtable_32.h | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 8fe95270b713..f45568f9513c 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -314,12 +314,6 @@ static inline int pud_trans_huge(pud_t pud) } #endif =20 -#define arch_has_pmd_leaves arch_has_pmd_leaves -static inline int arch_has_pmd_leaves(void) -{ - return boot_cpu_has(X86_FEATURE_PSE); -} - #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP static inline bool pmd_special(pmd_t pmd) { diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtab= le_32.h index acea0cfa2460..1db3214cfb45 100644 --- a/arch/x86/include/asm/pgtable_32.h +++ b/arch/x86/include/asm/pgtable_32.h @@ -44,6 +44,12 @@ do { \ flush_tlb_one_kernel((vaddr)); \ } while (0) =20 +#define arch_has_pmd_leaves arch_has_pmd_leaves +static inline int arch_has_pmd_leaves(void) +{ + return boot_cpu_has(X86_FEATURE_PSE); +} + #endif /* !__ASSEMBLER__ */ =20 /* --=20 2.53.0