From nobody Wed Feb 11 03:42:09 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 7E42131159C for ; Mon, 9 Feb 2026 22:14:52 +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=1770675293; cv=none; b=IJ4DaAjVGAcRZ1iA6g+k7ed9Ktrj9S05G5o2ShsyAXidN0a6QLMOd/71s9sklPk4paSQe00QJ4FkNHJVIgWkO6rSJ5LLBtoR2mqdgSgqz22dnMIOKdDjaOvbCbatzw9o8zEb/Os+1D1WQaSCkslBDCuZ20iKlFde9Bl+DxciYpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675293; c=relaxed/simple; bh=Z70k03OIJkrVFJaM5h1C7JB7eC7wdxXQGbOGlyBUPgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CVaMP7aC4kxpLkAzrit/I/UgDRXsYP1+Zccx7JiehHHjWv5ECksiB9EDoiSMCSXwx2RsmH7yu9neiEgM09irlLBX3U6Q/WNLEtwNzJTwl9tics0YhSS0uMnGU3u6f3aSSx18oUSIHjac5i8nGf34PRJN5ukPPrft2BOu18uHcZY= 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=g+pecRsg; 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="g+pecRsg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675291; 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=g+pecRsgF7h0IFCfWKL+6VfbN3uqhQRSEmExNlfHQlaGLjgFLM5Z9Anym2u5WiKXkIzn6P YOGpdXHYHKZZ/Qv7GgEXpsUfpvKHDAHHH9ntEeiQxjt0Wahk+szPSFxmaVOocFjaPBP5DB H7/KmPN/GR88VYoe7DS6WNowW55Yavc= 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-281-dHUkiJnaMmCWJ_7CR1KXrg-1; Mon, 09 Feb 2026 17:14:48 -0500 X-MC-Unique: dHUkiJnaMmCWJ_7CR1KXrg-1 X-Mimecast-MFC-AGG-ID: dHUkiJnaMmCWJ_7CR1KXrg_1770675287 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 8687D1956088; Mon, 9 Feb 2026 22:14:46 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E09CD18004BB; Mon, 9 Feb 2026 22:14:44 +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 v2 01/11] docs: tmpfs: remove implementation detail reference Date: Mon, 9 Feb 2026 17:14:23 -0500 Message-ID: <7f674469671346b18bfda22fadde7b6fb4df0e0e.1770675272.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 Wed Feb 11 03:42:09 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 D9EAD311979 for ; Mon, 9 Feb 2026 22:14: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=1770675295; cv=none; b=fcZkIgoVFQZpIz1C6eyD6D1aFctBvzdgWL8H9h5nvvELxHxzmrfocr43bS8oU07sT1884tjag3GaaSOyeA4NGfwvMnoQCCE4h3liTelAv3NbSL15wbgJ7CRQIdZUw9Y6Vdmwhclh5oWqMHHVsbRWBDn9o0UtmXZoMVC4suK1GaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675295; c=relaxed/simple; bh=Xim7z9ude0Zoty6IkIGXRqDnjc7Xbawb1ub+f64UUdk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ehflV7AAk6MOfyAsDDkrVIkz6zUbocxHEXJxlfhPJGoXkER8499YDt/Q7FvaKHjX1s0uT/H9d+D522fF5j8TumDTdgdLQC8ACncH0zs40xtm2DPLbHQycRoqBpNBLyaoFWOnQ7VZsU0zWTp7bHij9Q2C5qW+31+2eKCqjiGuvSI= 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=GoztIG9S; 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="GoztIG9S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675292; 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=rGs9hCTZyZ7Pjx1oR/68kmPjlLwJFnt3KGvTvJCfD2s=; b=GoztIG9SpB8rWsVfhZzwp04Z/GV6lW6esLcsI7DJj/a4mbqq5ZZHdUZWpo/s6bzCTRm5SE 6umq0bZkFjMVocM9qa6ALHXUnYzwHXxd1yUXXEL+Q8H8G/0SVZfouppUfbBOJMal2vdzPq 4/Tv6MWlyCeRW8CUeXXX/+n6unE17TU= 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-652-FgOUuNvCPre4UmMlbkiGkw-1; Mon, 09 Feb 2026 17:14:49 -0500 X-MC-Unique: FgOUuNvCPre4UmMlbkiGkw-1 X-Mimecast-MFC-AGG-ID: FgOUuNvCPre4UmMlbkiGkw_1770675288 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 5A5E11800464; Mon, 9 Feb 2026 22:14:48 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C6ACA1800464; Mon, 9 Feb 2026 22:14:46 +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 v2 02/11] mm: introduce pgtable_has_pmd_leaves() Date: Mon, 9 Feb 2026 17:14:24 -0500 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() very early during boot in start_kernel() so that users of the API can call it 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 | 7 +++++++ init/main.c | 1 + mm/memory.c | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 652f287c1ef6..6733f90a1da4 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -2017,6 +2017,13 @@ static inline const char *pgtable_level_to_str(enum = pgtable_level level) } } =20 +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); + #endif /* !__ASSEMBLY__ */ =20 #if !defined(MAX_POSSIBLE_PHYSMEM_BITS) && !defined(CONFIG_64BIT) diff --git a/init/main.c b/init/main.c index b84818ad9685..ad1209fffcde 100644 --- a/init/main.c +++ b/init/main.c @@ -1036,6 +1036,7 @@ void start_kernel(void) smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ early_numa_node_init(); boot_cpu_hotplug_init(); + init_arch_has_pmd_leaves(); =20 print_kernel_cmdline(saved_command_line); /* parameters may set static keys */ diff --git a/mm/memory.c b/mm/memory.c index da360a6eb8a4..4c25a3c453c6 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 Wed Feb 11 03:42:09 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 3FAF63112DC for ; Mon, 9 Feb 2026 22:14:55 +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=1770675296; cv=none; b=VqQohms8N9mRniE+L9Xm2REpVl1eB5WUjKhmlml5gmEltfs+hqj4+u+s2pBhxNhGUAAcFcKL1jFBOg5pxzNSiCKMJ6eAI9tsMsLwoQBYfrq3niZU7YXbFxIfk9iwHWHQjKqDKe+LyNeoD5bbPmxI8YXv5JPsOnu5/FES2Nmjzjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675296; c=relaxed/simple; bh=xr1jshCH2k+Vu/tx4foKxPV/100Z30kwL1ZLsYvrouQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HqwYpg+ATQrDe6NN40njyDewMLOC7j/ZLdDTW57lZuoNFiKhYtbh5kMR/Mhl6mRxA8WbOrY2eKce2pNq8BMu8kMastJNzpyOFPTbjUrGD4xVWGLclNvUa/c/d07Qq2CH28g/4vQkkM7iOOuPP8orv/nhWzIO/HbsA1JSZl2No1o= 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=Ha+zn/wI; 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="Ha+zn/wI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675294; 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=Ha+zn/wIvnYNLlweqse8qkOAUNHDct7NDI5Xz8WBnVbRIfgv8KONRcRU3BhEkf6cvnqLy/ gAu5iEANWmjqup/1y/eh0ceKf+51Eezr76VBvlYEE1nGmdnM9okotD/tN6h3PGx8l23l3s 6bSFRQpjVbeDbmDvdskIH8cn5rWHlsM= 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-515-BcyOFAXXPr-Qtb6-F_-Nvg-1; Mon, 09 Feb 2026 17:14:51 -0500 X-MC-Unique: BcyOFAXXPr-Qtb6-F_-Nvg-1 X-Mimecast-MFC-AGG-ID: BcyOFAXXPr-Qtb6-F_-Nvg_1770675289 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 D03831956088; Mon, 9 Feb 2026 22:14:49 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8E52018004BB; Mon, 9 Feb 2026 22:14:48 +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 v2 03/11] drivers: dax: use pgtable_has_pmd_leaves() Date: Mon, 9 Feb 2026 17:14:25 -0500 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 Wed Feb 11 03:42:09 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 A61FB3126A0 for ; Mon, 9 Feb 2026 22:14:54 +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=1770675295; cv=none; b=ta1gk5JAPN/6A0/JYWMM7GVQvVpMARjcMMoaoUcgCaE/cp5PvsWopJOcunX6eKKBMDkps34/WXc2d9S2CEZuIG7lYN6vav9FZYv2gWhj1jGdfXe6w1KvKhllLn8ppo871Nh/CKpF5kL70NjD7H+OipxygaAuNgM+UwhxUcUaPnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675295; c=relaxed/simple; bh=MekWNW6lGnfaa9quRhK4hdUbD1ntDcrXLM4mm4Mv1DI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lVesrvoxuUz2szatn/xb0Y+ka8Q+FaNk+NGkPEncs13p1FEV68Qv35ylbpPH9jAbIKQ1ohx9PFnQNs6+UAYs7y0oXrwYUbmkh+jkZhLQKWb84/WA43j5sY0MRLwY9loti8wxlTHOfw2HaHkjSCMnf5pA7nn2JDxe1lwbtQlqqh0= 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=J5gFIn8u; 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="J5gFIn8u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675293; 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=OiFiUMpX2KB1Jv/lqdujtPm172YWQGONs7yMm/FtBvY=; b=J5gFIn8uh8dZobxmTp3RZexhYiaUULZg6zrU1AAmLlvwsKO9nZriOU7aloSovTRJwokMDg iuA3FOG3tMH5brwsGBuS1sZpJdWTZ9asbphQheVfZ/B+XofG2MlCimYp61YyFZLsPB34om 9qV1RPdWmENW3IIzGcgDwNiKGKr3nOg= 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-100-N0_AAJneNLm9RMcrR_haJw-1; Mon, 09 Feb 2026 17:14:52 -0500 X-MC-Unique: N0_AAJneNLm9RMcrR_haJw-1 X-Mimecast-MFC-AGG-ID: N0_AAJneNLm9RMcrR_haJw_1770675291 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 49F0F1956089; Mon, 9 Feb 2026 22:14:51 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1296F18003F6; Mon, 9 Feb 2026 22:14:49 +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 v2 04/11] drivers: i915 selftest: use pgtable_has_pmd_leaves() Date: Mon, 9 Feb 2026 17:14:26 -0500 Message-ID: <5f829c4198fe72ac71e3e62426e12d475501ae51.1770675272.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" igt_can_allocate_thp() uses has_transparent_hugepage() to check if THP is supported with PMD-sized pages. However, has_transparent_hugepage() is being replaced by an API that has clearer semantics. Thus, replace has_transparent_hugepage() with pgtable_has_pmd_leaves() and a check for IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE), this makes the intent of the check very clear. Signed-off-by: Luiz Capitulino --- drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c b/drivers/gpu/= drm/i915/gem/selftests/huge_pages.c index bd08605a1611..dcd1f1141513 100644 --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c @@ -1316,7 +1316,9 @@ typedef struct drm_i915_gem_object * =20 static inline bool igt_can_allocate_thp(struct drm_i915_private *i915) { - return i915->mm.gemfs && has_transparent_hugepage(); + return i915->mm.gemfs && + IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && + pgtable_has_pmd_leaves(); } =20 static struct drm_i915_gem_object * --=20 2.53.0 From nobody Wed Feb 11 03:42:09 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 4CF7D311587 for ; Mon, 9 Feb 2026 22:14:57 +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=1770675302; cv=none; b=XSCpYQ52MxRu1mf26jJGrmNaFAqL6qPGtaeis/sMwuWu3JDtztCklXsYSUx/19xq6+1e/KYJpgYIiXLflsvzAkEzTRli8XtE0YT+dDtnXaLKpCCZrawZg9fj9ZnTdy0S5CkU+G4Rct8tHFfy6HntLWzsciGl768zqBPqBCcJttc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675302; c=relaxed/simple; bh=Y1YWCa56+uIQhFhz9NyaD5rWviaM26lSFArxsQQAdXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dg26EM5LbkpjqIu4bIawR7QwuAmV20XMi27Z9fxm1PqKQfs1WV3leg4sxHwj6G2QbvLXcf8iDvKuyLyiDw3BoGMo1IGWY+FZ/QjZvjw+L4TiMQmz82yvkxbZPT/zerWhFtrCM9UZzJqluXL9np4l7HjyrxEvtAsOtrdk8vcQ3BA= 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=R2nu04Yo; 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="R2nu04Yo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675297; 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=cfMwxb5ebBgIfUxMHIxl0ciZs5Chtdyy20TmiqAu9rY=; b=R2nu04Yo2tR4f+f34/zZcUfFPsxN17K9ibm+FVz9A0Rzrl8jVl3BE/I5V0UPuGADrcbA3+ BySLDrhjGqmmuQyUaUiqWwF51qBxywS86BvineJ2CJbM4Gc4GPfHN8tL/ZlrN4vTuMgWRU fymWrNb2qdTM42ALIZdFTFuZ8l4r7Do= 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-581-mn0I_KVsOKyBbU8sB_W-ZQ-1; Mon, 09 Feb 2026 17:14:54 -0500 X-MC-Unique: mn0I_KVsOKyBbU8sB_W-ZQ-1 X-Mimecast-MFC-AGG-ID: mn0I_KVsOKyBbU8sB_W-ZQ_1770675292 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 CFC8918004BB; Mon, 9 Feb 2026 22:14:52 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 807B018003F6; Mon, 9 Feb 2026 22:14:51 +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 v2 05/11] drivers: nvdimm: use pgtable_has_pmd_leaves() Date: Mon, 9 Feb 2026 17:14:27 -0500 Message-ID: <3142e595b73685be8bf4a4657fdf10b28377acb8.1770675272.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. However, has_transparent_hugepage() is being replaced by an API that has clearer semantics. Thus, replace has_transparent_hugepage() usage in both functions with pgtable_has_pmd_leaves() and a check for IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE), this makes the intent of the check very clear. 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 42b172fc5576..7ee8ec50e72d 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 Wed Feb 11 03:42:09 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 00183311956 for ; Mon, 9 Feb 2026 22:15:02 +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=1770675304; cv=none; b=tVkAq0gUJNvR3Ifh8q4u0pKvej2sCpmC9KelUDYSXdkaarGeoCnFa3AFMs3eAw+L06OcXsOOlS3Fxfqlrnz88XeOMT+iQB0Kp8SUn9r9dSuCPdTAPgwTe6vlLdpniuQO/ev3OT3+SwS2idlohFSkyRfP2C2AXu/05EtAS4DBL9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675304; c=relaxed/simple; bh=RiWHLgD50Ke40s5nBYStCDkEWNd09RyDs9esamQFk8M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PLIw5fWFgVFqdr1ij13nT4hQo1BlywF03P9uUHTFbtC9fgl6qbIQ24c5oD73UWEdULad1r2a7VAgQ76xmcnxUCTMjwunsgCa05b05HzTvGHRhZDSmK7sNjyxk8xFcmzEhp/PVd9G/XWZGOcUVWRa259eJPPutTbu56NK84ixwfc= 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=WindTSqn; 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="WindTSqn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675301; 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=2aDuQebwrriItiELVe5G4jyMPSkZ29l0d0nlGBuor6U=; b=WindTSqnzOzLSmy8xKdviuI954yzm1AuPKpysNoqSbY6DreYUnvy1bMnM5yl8nb4/Pib1y yNot44vQx5Cnh3IXKvq9pJv0bv+UM4B1ZAHlm8J2Q9p5csvjELrqdxuhEioJZLxDznB+zR OOU548y7o2afEgAAI1GoMPXmHPlrjo0= 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-172-YejKFO9-NpWpR8uJ1wiC4g-1; Mon, 09 Feb 2026 17:14:57 -0500 X-MC-Unique: YejKFO9-NpWpR8uJ1wiC4g-1 X-Mimecast-MFC-AGG-ID: YejKFO9-NpWpR8uJ1wiC4g_1770675294 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 7F6721956080; Mon, 9 Feb 2026 22:14:54 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 128E218003F6; Mon, 9 Feb 2026 22:14:52 +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 v2 06/11] mm: debug_vm_pgtable: use pgtable_has_pmd_leaves() Date: Mon, 9 Feb 2026 17:14:28 -0500 Message-ID: <5bf68bdcb28bb0462ccf8c2995cd8ebc07d79cee.1770675272.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 ae9b9310d96f..ec02bafd9d45 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"); @@ -993,7 +993,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) { if (args->is_contiguous_page) { free_contig_range(args->pmd_pfn, (1 << HPAGE_PMD_ORDER)); @@ -1253,7 +1253,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 Wed Feb 11 03:42:09 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 4CFF831159C for ; Mon, 9 Feb 2026 22:14:59 +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=1770675303; cv=none; b=cKq8cE10auTk39P28BqIroYK6gw+bUZ9Memy5yCq2Hg0gwAyFjSj0YMZ4Lbp1CIHFL7Do30KNe8JX+R0U907fk+g0LxNLRXjGZ8uyn6MchhXNA23SMDEv5YDrfIBRoh/jvGxiLcYUc41V/KZ2dN86IY1Rs54s/q33vKJnTpC5Mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675303; c=relaxed/simple; bh=xFm3Mvuiaek3TQObiEg+n/ibmgn1WObQdw7k5y1quJ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=boo94S177NuloHZQWeFAgH7H027IXD3KTxztkSCjVirJtMJfD+ARjUMDDP5OIyz9ZfTtbl8Vpg3TU0XBltw9/y7FzcnG97jRDWxAivQgzoAtuOkYcYDyhoBQ51pvD3zkrGeBRukD7eiBZT6pvwA8pXKNgcUOcmCN1VF/NqhDNdQ= 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=GhHud+P1; 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="GhHud+P1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675298; 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=zhOcvH5cMErbpuFO1qD4X5xOtlaPVDROEke9rfA1j/w=; b=GhHud+P1+wv2hLrqgeis51PzPOC0kLyaOTEDBA000OsAUK+zgX0nY6yRw8tVvDOhD8ZBUB 1y5P6LTz6/CzOq03K+jvmbi3w0oVTAhROzE0C5O1S3sKOnygfoJb0TSURe2PDrvKwTEqD7 T54Ha/+cJINmBTo7Jj5e4hkkEFK8ilQ= 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-445--ENewiPxMw6ecghvTqURYA-1; Mon, 09 Feb 2026 17:14:57 -0500 X-MC-Unique: -ENewiPxMw6ecghvTqURYA-1 X-Mimecast-MFC-AGG-ID: -ENewiPxMw6ecghvTqURYA_1770675295 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 C93D71800465; Mon, 9 Feb 2026 22:14:55 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B554918003F6; Mon, 9 Feb 2026 22:14:54 +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 v2 07/11] mm: shmem: drop has_transparent_hugepage() usage Date: Mon, 9 Feb 2026 17:14:29 -0500 Message-ID: <66846ee3aec32c04d20bc7e0e823ba21d4ef278c.1770675272.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 performs two kinds of has_transparent_hugepage() usage: 1. shmem_parse_one() and shmem_init(): since the calls to has_transparent_hugepage() are protected by #ifdef CONFIG_TRANSPARENT_HUGEPAGE, this actually checks if the CPU supports PMD-sized pages. This is irrelevant for shmem as it supports mTHP 2. shmem_parse_huge(): This is checking if THP is enabled and on architectures that implement has_transparent_hugepage(), this also checks if the CPU supports PMD-sized pages While it's necessary to check if CONFIG_TRANSPARENT_HUGEPAGE is enabled, 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 Reviewed-by: Baolin Wang --- mm/shmem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 79af5f9f8b90..32529586cd78 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 @@ -4678,8 +4678,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; @@ -5463,7 +5462,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 Wed Feb 11 03:42:09 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 00110311955 for ; Mon, 9 Feb 2026 22:15:01 +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=1770675304; cv=none; b=gPnFvJBvvCzrnu5pfbTDeiXve+ImbiYePtTOvIZ9RjsiAcU3PXcFI3ul+PJ0khQfVsMIJCnDsaIdIzI3ilPDB8MX4rMmtLk3z2SqcGSy1uNFLl5Rmdh/UkJBDpKgeBAde3pE1OCcIx7f6XBnWZ8QbINBW+bscQr8qYXoNoN7A5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675304; c=relaxed/simple; bh=g2ZUfnQ90K8F/wOicNi6g6uXseELYapyoOUYrz7GrKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nEnRbiwZDBlI6RawlbppE/VIdYylOWGw2dWXyUae70uFZGMmzRICxw7aOrh+RLaWYFVlq0ICYH1EUgfhmH8FAu/SahT6cWpX/iZh4dWZB5tcM8sC0w+WBewgIP2W2OEk0sR5b6WkZlVRzj6CBlYinat1JfcwAzrp10cG1MWhlM8= 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=WqHVEDYy; 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="WqHVEDYy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675300; 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=F02NDJ/4e/AhBShhBicj4QcAadjr+UPg+7jj9VQCrJM=; b=WqHVEDYyyb5ETCpAdijAxq+8El2bykes0lBuYlBxtMCElnRmxESi6c8H/GlWNefLqAOI/Y QF8o6hCrDrIDfYQpSE7GlWWdwLfve6bTrm91KQIPwPBkIyeapISRCJIqAd42uZJxLRwbVM F9rxmYP2W1XF2wCL/UaLPEqeq0BR3rE= 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-379-RqLU3oj3OsqVPV6ncdbptA-1; Mon, 09 Feb 2026 17:14:58 -0500 X-MC-Unique: RqLU3oj3OsqVPV6ncdbptA-1 X-Mimecast-MFC-AGG-ID: RqLU3oj3OsqVPV6ncdbptA_1770675297 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 3383B18005BC; Mon, 9 Feb 2026 22:14:57 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1379618003F6; Mon, 9 Feb 2026 22:14:55 +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 v2 08/11] treewide: rename has_transparent_hugepage() to arch_has_pmd_leaves() Date: Mon, 9 Feb 2026 17:14:30 -0500 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" Now that all 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 only temporary 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 9c06a612d33a..0080724a7df5 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 44a662536148..4fcc8195a130 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -432,7 +432,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 @@ -448,7 +448,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 aac8ce30cd3b..6ed036b3d3c2 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1094,14 +1094,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 82d31177630b..1dec64bf0c75 100644 --- a/arch/powerpc/mm/book3s64/hash_pgtable.c +++ b/arch/powerpc/mm/book3s64/hash_pgtable.c @@ -366,7 +366,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)) @@ -395,7 +395,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 bca9b29778c3..4398855d558e 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1866,8 +1866,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 e33df3da6980..08d109280e36 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -313,8 +313,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 6733f90a1da4..b4d10ea9e45a 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -2039,8 +2039,8 @@ void __init init_arch_has_pmd_leaves(void); #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 40cf59301c21..b80a897b9b6f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -905,7 +905,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 4c25a3c453c6..9794429df015 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 Wed Feb 11 03:42:09 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 29B87311946 for ; Mon, 9 Feb 2026 22:15:02 +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=1770675304; cv=none; b=rn/EGYv/XLb6/Pm/aYxVn5exZQJP0z6xYyccRSlApR2e6RWCxM2VfXVFHQ0L3IoufweW0Ewwm4tCNtL8RD7HEToFib9Ehej9KUFp9LnvtLTm17OkWQczjSYrfCMK+zSp6JnUTxjFqN78+Zf/v65AnxnomaPhGb+AcqYkqbRhfvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675304; c=relaxed/simple; bh=xPa/fA4XpsR78dMIU3NBRTTvwCrvEcRVBBHohgczIqs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p5yzLRmAF1CUXfhg7RLOLWVbLhVI1TUbgJOGLDBwfQTNCqiLp7vdps0e7qsEl2razkCL/uHh9sfeNonwGvLgDEZsbr3Vfghb4L+8JGte9+NHof89JKWmrskIeUEBHYM92kIT9AqSrzloftdFx6Tz/e46gnAvWiS2/XCzBybJNcA= 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=dNsP5AOE; 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="dNsP5AOE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675302; 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=67cjgvmN4wcDxnHIeyr7N4NSsVtUrHJXnKrlVxHMIvo=; b=dNsP5AOEknqc4IUb2w/x2UzHBvPEup1c+DPSdhMDnAMg/OFjWczZFZGzhf0UEmCTdDhaNF 5nUksjJ1Nw1oAeYa7Ac/iZGoZ6FEPpqbDV+T7mcHI83PPMq83JHUx4K1j+iU7tau7MnuLC fEFvxNTt9GDFvQJJPfn/FF/h5PG1TtU= 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-121-TLr_Jra7Oci7mr7xmIMOiQ-1; Mon, 09 Feb 2026 17:15:00 -0500 X-MC-Unique: TLr_Jra7Oci7mr7xmIMOiQ-1 X-Mimecast-MFC-AGG-ID: TLr_Jra7Oci7mr7xmIMOiQ_1770675299 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 0A6361955E77; Mon, 9 Feb 2026 22:14:59 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B5F72180066C; Mon, 9 Feb 2026 22:14:57 +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 v2 09/11] mm: replace thp_disabled_by_hw() with pgtable_has_pmd_leaves() Date: Mon, 9 Feb 2026 17:14:31 -0500 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" 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 b80a897b9b6f..1e5ea2e47f79 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -122,7 +122,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. */ @@ -905,10 +905,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 9794429df015..1e9dbec7e6eb 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5386,7 +5386,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 32529586cd78..1c98e84667a4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1827,7 +1827,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 Wed Feb 11 03:42:09 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 E65463128D9 for ; Mon, 9 Feb 2026 22:15:08 +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=1770675312; cv=none; b=CL3is6zxTg6P1qnOVOfJatkTpKOtdkUz6fTmfpgqUKpv7egDBs2LGTv4F8mlszdlcWOCzcnVV95BB/cfjHcDvKBrtV4FAvSPKW2KduPY5OTpYZ1Ys8NPyOqCFd/UFjn8j7eV3pVB+qaeAHfQVMbcP8eP2g8EN5ZB0hUDmNIbwL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675312; c=relaxed/simple; bh=QjcZsWJkHw2nS4fd8VsYpxiv5WXYGzsI7ynnHdy+An0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eXZjHCBc4ifRhElosiRRn5aVXvsuYuvrkcJho22AF8Vy4Lt0NlHMl4w+7Fw13aJv0qdykGra0PJdj+NO84orazHAedFlv93u5l+jX+7B6nbaGBGhr/NHac++bCjorDJwAEooRxdHnba2zg9TnKQs0EXPxMwG0zEyhPBN2dY1CWw= 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=LMfapYIG; 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="LMfapYIG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675306; 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=+HpD3amJN83e1nK4/UYx8PNBs97+doRf6FtLNeMX5c0=; b=LMfapYIGW7ZPY77+aTbiHwrqDEpejA3SUjHh9169VcsW8RzuMdcNgMNKnnFvc3CxmFjBri CXHPEIzVzV1g3fn160yqFK0hmobposZg5oDLjXsrCh/bitFRQG83KVssYc0CYG8FRUQDnZ CxFS2JwViNLxb2KzGPTiBHOJIaW6EBU= 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-446-_cUmsVACN5G5gKmJRBu_YA-1; Mon, 09 Feb 2026 17:15:02 -0500 X-MC-Unique: _cUmsVACN5G5gKmJRBu_YA-1 X-Mimecast-MFC-AGG-ID: _cUmsVACN5G5gKmJRBu_YA_1770675301 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 E4D961955F12; Mon, 9 Feb 2026 22:15:00 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 47B0818003F6; Mon, 9 Feb 2026 22:14:59 +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 v2 10/11] mm: thp: always enable mTHP support Date: Mon, 9 Feb 2026 17:14:32 -0500 Message-ID: <29e8dfc2772af4b6e0db24134ca3563ec422b91a.1770675272.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 | 11 +++++++---- mm/shmem.c | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1e5ea2e47f79..882331592928 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -115,6 +115,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; @@ -122,7 +125,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. */ @@ -806,6 +809,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); @@ -905,9 +911,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 1c98e84667a4..cb325d1e2d1e 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1827,7 +1827,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, @@ -1935,6 +1935,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 Wed Feb 11 03:42:09 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 E64BA311C21 for ; Mon, 9 Feb 2026 22:15:08 +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=1770675323; cv=none; b=P3ijUgQiEIkZ3P6ToEVFeFqmM4VMELtvEuTrCj2ADVCBdVivqP+2RlJMlxAgK2VgIpBx/MLR/0V+diWrApUwdUrFW633MnxLHB5ymDRtfvNiYDqsJbyT3GFlAO7VbDISCSiCa+Qjcm73jYcZjU9PkZtxyymscd9YGJYVrDZTEcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770675323; c=relaxed/simple; bh=c+dQoUKxCKQJ3RMdjtHRktAK00Nsp9a+z0lb5WyAZig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DmYgg/RxQ48yxOd6xnZbpy98P7J/VQtmmKyg6blMMaH1GdVjL4ywlijG/0l1SaTO4HJpuBic06h37GC7mkanmz8X0vsJv2ni/krHnlY9jzntQBbhHdRvXeZTlHAEo+X3l6JfcIADzlNPLddkyQR5RvuIIZ+KQ5+VAKtrY8Z1DMc= 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=ZkViLxYi; 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="ZkViLxYi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770675308; 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=k0qxewW2YSQTThSWCJkjfHByvyqMVZJcNKxWE2448z8=; b=ZkViLxYiwzqCG5lNTQ/OpV59wHqoPURgBIicYcMqckJYEOMvxsWe1oEN7+fQQRKaylvSUh AoxKZPlprdRewRQhG+h97/oUstlcOzv0EwbnE8+urJbfTb+JLqAddMrQWIgoYWC4O4B3i5 FHC2WOZUjxL/e0+YBCU3gkryHLrvcuM= 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-456--g__dwcwP3G8CSOQpiOS9Q-1; Mon, 09 Feb 2026 17:15:03 -0500 X-MC-Unique: -g__dwcwP3G8CSOQpiOS9Q-1 X-Mimecast-MFC-AGG-ID: -g__dwcwP3G8CSOQpiOS9Q_1770675302 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 40DB61956095; Mon, 9 Feb 2026 22:15:02 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.66]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2595318003F6; Mon, 9 Feb 2026 22:15:01 +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 v2 11/11] mm: thp: x86: cleanup PSE feature bit usage Date: Mon, 9 Feb 2026 17:14:33 -0500 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" 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 08d109280e36..55b88de5178f 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -313,12 +313,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 b612cc57a4d3..3bd51cfa431e 100644 --- a/arch/x86/include/asm/pgtable_32.h +++ b/arch/x86/include/asm/pgtable_32.h @@ -45,6 +45,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