From nobody Fri Dec 19 17:14:31 2025 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 57FD6306B15 for ; Thu, 6 Nov 2025 21:29:22 +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=1762464563; cv=none; b=aRI9Pwzx9VTsu+tDCaERpHcdwrkkWVlWLL8AdxfI47M5W3sg2BclsOUMUkn02ZSN37oYVskuI3n6RsPWhlrm5+kWacxvuBhmYFZjn8X3LIf9jU8RsiRa51lKCyDAgn4R6ol6/ybttm4DfU5YWbJxf8pxeMQi0MNK9SC+kHNEh4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464563; c=relaxed/simple; bh=/GBxVAq5xmr+3KXl3Ok17RMalYATBJK95ryBBuy5VaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tRYFmmll/Ap7/AVNh6LGRDekEKWjh/E+I8b5W0HDmp+FTNVR+do7xv5NVqcSJrKSMVimezsn02vnGxZx4pUye068VUbK55lpoCdYpBwV+ZM52gTHvs9vUYxkwI8YQUiKkRdkO3ssgKMHHZBTqazrIEicMb9/GEXL+haAPSqVw60= 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=HtAbrImh; 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="HtAbrImh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464561; 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=g+gqNXzwQrUwJSMxzoqSc1CwBu2yw1frjOj1IBpGl38=; b=HtAbrImh01omTfEt8zRF6b6U1FqxEx6bPFWX/a+4IowFeyTae/8+pOEYk16ioRqNvZ5vHt t7Cmogvp3vMRl7HRvyhZC4/Fht7d2GP4SFe6ABkuAQ6jWWwdZEaII1ddbWDl8YHxFqswLG l2aO6TuNNMPat47SufH+2LyUW7p8F3M= 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-526-k61oNvIsPW2_VCtk-ZibCA-1; Thu, 06 Nov 2025 16:29:18 -0500 X-MC-Unique: k61oNvIsPW2_VCtk-ZibCA-1 X-Mimecast-MFC-AGG-ID: k61oNvIsPW2_VCtk-ZibCA_1762464557 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 8C3C719560A1; Thu, 6 Nov 2025 21:29:16 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 05AF419560BA; Thu, 6 Nov 2025 21:29:14 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 01/10] docs: tmpfs: remove implementation detail reference Date: Thu, 6 Nov 2025 16:28:48 -0500 Message-ID: <707886a5ce4afa4c54456ab2ad8dfe5ba0d86086.1762464515.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.0 on 10.30.177.12 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. Signed-off-by: Luiz Capitulino Acked-by: David Hildenbrand (Red Hat) --- 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.51.1 From nobody Fri Dec 19 17:14:31 2025 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 7394130748C for ; Thu, 6 Nov 2025 21:29:24 +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=1762464566; cv=none; b=Zh5zamQEhZrK55kS9BzfwCxQWthIqUbmKk2VJr2vUmc6qjwuuEMdO/gJrRGyywRoTHi59FKIlT7bcgX4TYjah+x/Onj8VWDobRqnLWfSnrnpVRGmZJT6kbR9bWCHeFadsUcCU/9AVhflpe/yQwfvUzxyCxuiYdqDHsbzIAzNppk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464566; c=relaxed/simple; bh=hpAbJa4FrRw64WEVicBwSTMoiNiDFlcvF/Gja/aj4jg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RcCjPvQXFQM94f1mnrOwAayybNWA0sTU3BcC5VAJthc493iKTco9npjrT/P10JlauwIc25dVqzTbqzNa4waPGWHmeFalqxIQFNrhO+Ux9L7R4BReK19Rldi3WVx78yQOao/kJXp1TnIvl/BIsLsSIWIgOAAVtImp8EBp7qoxrTA= 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=gNQsYRa2; 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="gNQsYRa2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464563; 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=zUO+xVShs8OiZifdHLWjxbQxTWazvLbIeIkNNKtnLDQ=; b=gNQsYRa20nMYBLf15LkURgy9l7qsNG/YeF1F5BXkgmwOcIUjrqneALa6dP4S2Kh9ms0IdF 791eKSdq00+/GFMzAPjXBQUAGImUUFRyDVkYcI0CAKjwaivKUT0JSzsZF42BrSegZCD+g7 iIDZxN5XJBJ9sz6wx5kjbh+i67c0X6Q= 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-184-5_-hiZhPM0Ofg5aLSYqB9Q-1; Thu, 06 Nov 2025 16:29:20 -0500 X-MC-Unique: 5_-hiZhPM0Ofg5aLSYqB9Q-1 X-Mimecast-MFC-AGG-ID: 5_-hiZhPM0Ofg5aLSYqB9Q_1762464558 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 B988A1956094; Thu, 6 Nov 2025 21:29:17 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C160519560B2; Thu, 6 Nov 2025 21:29:16 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 02/10] mm: introduce pgtable_has_pmd_leaves() Date: Thu, 6 Nov 2025 16:28:49 -0500 Message-ID: <50fc95b4c806eb4bfcdb578f2ce8d634faf93d57.1762464515.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.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" This is a new helper which can be used to check if the architecture supports PMD-sized pages. It's intended to replace two existing helpers: - has_transparent_hugepages(): it's used to check for PMD-sized pages (not exactly THP support), but it may perform a hardware check so it's not intended to be used in fast paths - thp_disabled_by_hw(): also checks for PMD-sized pages support, but uses a cached value pgtable_has_pmd_leaves() implementation is split in two parts: 1. init_arch_has_pmd_leaves(): runs at boottime as early_initcall as a wrapper to has_transparent_hugepages(). The result is cached 2. pgtable_has_pmd_leaves(): just returns the cached value The next commits will convert users of both has_transparent_hugepages() and thp_disabled_by_hw() to pgtable_has_pmd_leaves(). Signed-off-by: Luiz Capitulino --- include/linux/pgtable.h | 10 ++++++++++ mm/memory.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 32e8457ad535..e4c5f70b0a01 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -2001,6 +2001,16 @@ static inline const char *pgtable_level_to_str(enum = pgtable_level level) } } =20 +/* + * IMPORTANT: pgtable_has_pmd_leaves() can only be called after + * early_initcall, since that's when __arch_has_pmd_leaves is set + */ +extern bool __arch_has_pmd_leaves; +static inline bool pgtable_has_pmd_leaves(void) +{ + return __arch_has_pmd_leaves; +} + #endif /* !__ASSEMBLY__ */ =20 #if !defined(MAX_POSSIBLE_PHYSMEM_BITS) && !defined(CONFIG_64BIT) diff --git a/mm/memory.c b/mm/memory.c index 74b45e258323..7b50f3ec9b37 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -176,6 +176,16 @@ 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); + +static int __init init_arch_has_pmd_leaves(void) +{ + __arch_has_pmd_leaves =3D has_transparent_hugepage(); + return 0; +} +early_initcall(init_arch_has_pmd_leaves); + void mm_trace_rss_stat(struct mm_struct *mm, int member) { trace_rss_stat(mm, member); --=20 2.51.1 From nobody Fri Dec 19 17:14:31 2025 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 BCAAB3074A2 for ; Thu, 6 Nov 2025 21:29:24 +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=1762464566; cv=none; b=HI5qhBVzOUaUdrDQFoSX2UPy5Ftzg6wOYWTFgd/mw5m5zdvyOJP8T4b97bwIY8O1y4rbvHLQU4LVbC/lu/2aix86rRHJhuhdTrHAhJ7FcYunZigDCvte+caWikpGVpylbTIk7FA4z+X4/hSjNcWW51LaAPtjGJCLocvxfZiy+MU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464566; c=relaxed/simple; bh=9EtUQwIJD9ReYdDhxw4/Xq3pMHTHX3dhhzXoMdCb3Jo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UhCLdFRdEwLR9gg9A9AUojmBok+hBIyNgoqGtEyQlTJcga/D1U6jiCL1AIsIz82fEZIljXQQ42CE1Ak5wyvyS7e7Y8yy7uIAnaycUSZtVURmbi6IRnXG8Qia6xRb2XLeUy4r4W3yKHlIf4zutEKr3hBDFUTU2VnLy3X/BHm1UC4= 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=R4M+wk+j; 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="R4M+wk+j" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464563; 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=skkktfIpg+zUdGSPDhLSirEh2xW0AQxE26iLGr0oL6Q=; b=R4M+wk+jveCYtqigMzlYqfc4ONU7sm/tHImNnAnYnEWiNTcuJ7q5K5I9Hq1UmcjleLg5Uw NaMzORSspopyI1kkc3hSO3AmYds6kubN7FRO+RcNOwyXn0swPiNrqQgtUBKywNoAJLRjL9 25WdkseI8eIog5FL6P535QswSlV+0wE= 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-302-T0ZVoLT1MG67aUGFddE1ww-1; Thu, 06 Nov 2025 16:29:20 -0500 X-MC-Unique: T0ZVoLT1MG67aUGFddE1ww-1 X-Mimecast-MFC-AGG-ID: T0ZVoLT1MG67aUGFddE1ww_1762464559 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 25A911800371; Thu, 6 Nov 2025 21:29:19 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0096C19560BA; Thu, 6 Nov 2025 21:29:17 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 03/10] drivers: dax: use pgtable_has_pmd_leaves() Date: Thu, 6 Nov 2025 16:28:50 -0500 Message-ID: <1456ba4c025e9ea01abcadb8c3714c7ef84e0198.1762464515.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.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" dav_align_valid() uses has_transparent_hugepage() to check if PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead. Signed-off-by: Luiz Capitulino Acked-by: David Hildenbrand (Red Hat) --- 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 0867115aeef2..10aeaec9e789 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -117,7 +117,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.51.1 From nobody Fri Dec 19 17:14:31 2025 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 1BE8F3081AE for ; Thu, 6 Nov 2025 21:29:26 +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=1762464568; cv=none; b=udF7Q9EZy3cggeaf1SvlrTjJJGUM/kSOAhB+BwmfAdv+mjTb8HxpQgX84ZD1Sq/2LK74U2pZGiQBZ8w4LdjpcZO6x0zFkNFn7fL6r9KAWMcYE7gHePyuCtPwfD2IPxAh0kEMc0DdQllAjOanOVsunT4AioRjPJ/QYqDBmoXwhBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464568; c=relaxed/simple; bh=tGGgVXSaRpY0JSAHiPTOxSgAae9U1GHb2Wx5eM3LJrE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CoKkTf9gLT0m/PAgbRTbrkbm15MdP6SL+jvYHW5wj8kJU/WxAzhR1lUlD5WYHb16BF1CYZ8mCk1DrtCDX6//MngOTwQBb1IjQ+zUjEhCP+GSZ5hBC9KvYMspVzlPL1V5iiSsy0CnCYYM/8L0UwCcodVG6sKk/9JVdBzYfcQ5guM= 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=TgiegNxT; 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="TgiegNxT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464566; 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=uKmnrwBJh2QsEJ5R8DLB0opqHAQSJh/LYJ/G3AZFd2k=; b=TgiegNxTQgEAONyqlDcSOGj0bGKE+Y1uLUYpcxMA/CsA1iGQgqiTmHoGuh+nW8OFwu5uWw cjXSNs46YOC40AKW/qKLTcnz++bxTv9OhhWRQx6NYYsBbCbrDU+DF0hp/mB9oSbKQ4dUAC ySf2iQlxJbxL2C+BG0QRNFZjaI2iv/I= 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-683-hpWa3tvvNlG9IJXkEFsTig-1; Thu, 06 Nov 2025 16:29:22 -0500 X-MC-Unique: hpWa3tvvNlG9IJXkEFsTig-1 X-Mimecast-MFC-AGG-ID: hpWa3tvvNlG9IJXkEFsTig_1762464560 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 968D7195608F; Thu, 6 Nov 2025 21:29:20 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5A6E919560A7; Thu, 6 Nov 2025 21:29:19 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 04/10] drivers: i915 selftest: use pgtable_has_pmd_leaves() Date: Thu, 6 Nov 2025 16:28:51 -0500 Message-ID: <297c6fa3dfc50c28c05c0974c86a205984d752ed.1762464515.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.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" igt_can_allocate_thp() uses has_transparente_hugepage() to check if PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead. Signed-off-by: Luiz Capitulino --- drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 2 +- 1 file changed, 1 insertion(+), 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..c76aafa36d2b 100644 --- a/drivers/gpu/drm/i915/gem/selftests/huge_pages.c +++ b/drivers/gpu/drm/i915/gem/selftests/huge_pages.c @@ -1316,7 +1316,7 @@ 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 && pgtable_has_pmd_leaves(); } =20 static struct drm_i915_gem_object * --=20 2.51.1 From nobody Fri Dec 19 17:14:31 2025 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 1B56C208AD for ; Thu, 6 Nov 2025 21:30:28 +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=1762464630; cv=none; b=SFeCECAHWH+4jJF8B9i2lm1RZUD/vCWN5t4L6+1ErY8g/t8x17/8qaAUlqGg3VyLRrI5qrfiYFY2msgPeoIwfC8f9/ZMWRUB8OOLTAeGaxFyNhVMiOHu+N7nqKvib33ezr5X+ZR/od0aswgaWCg2WgIX2zHTZliBYrqFTwlbVxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464630; c=relaxed/simple; bh=gXQSaqW18NTCntpvD1CjnWExHP0fGByO6brNawhT13o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kx6Wm8zeFwC7rztCK0PmZ3gxHi6oDkCcHLA9FuLXcDgV4YEIGr8BrRvguhwMhmgV8Tb8MJffmvzAUCYdimGrPtDalpkINJo8ojnRi0PYwWA+wsV5DS1keHyBV0fSp4b5D3srByiB2bI2BpMwBqmnYBtTTMnmVrByQ30Mo0L5R8k= 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=XKJZAVtM; 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="XKJZAVtM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464627; 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=6aaU6mqv/vvlvKAVhD0kXqB0iQKKcZ1RnoZvi1Wj0RE=; b=XKJZAVtM8WL3sIzP0FJ0N6Pv2QqY8R3uADlL5/vGJ6mPZ3+9NVxJA9EJfk7cHk3rhxE2Pe H0yhveCWUIR0jOYd9rUMZChUi8RDdqqDPKiZcGzm1O0KMEYzIwWNPYcsM/eDuLMJKod+s8 2h+kk+8LzdUP+Ezz098ySqQ5HS7TQqo= 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-444-V2B0wT2pOM-hyOkBya2dGQ-1; Thu, 06 Nov 2025 16:29:23 -0500 X-MC-Unique: V2B0wT2pOM-hyOkBya2dGQ-1 X-Mimecast-MFC-AGG-ID: V2B0wT2pOM-hyOkBya2dGQ_1762464562 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 E8EDF1800371; Thu, 6 Nov 2025 21:29:21 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CD14D19560A7; Thu, 6 Nov 2025 21:29:20 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 05/10] drivers: nvdimm: use pgtable_has_pmd_leaves() Date: Thu, 6 Nov 2025 16:28:52 -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.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" nd_pfn_supported_alignments() and nd_pfn_supported_alignments() use has_transparent_hugepage() to check if PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead. Signed-off-by: Luiz Capitulino --- drivers/nvdimm/pfn_devs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 42b172fc5576..989f87f07e0c 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -94,7 +94,7 @@ static unsigned long *nd_pfn_supported_alignments(unsigne= d long *alignments) =20 alignments[0] =3D PAGE_SIZE; =20 - if (has_transparent_hugepage()) { + if (pgtable_has_pmd_leaves()) { alignments[1] =3D HPAGE_PMD_SIZE; if (has_transparent_pud_hugepage()) alignments[2] =3D HPAGE_PUD_SIZE; @@ -109,7 +109,7 @@ 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 (pgtable_has_pmd_leaves()) return HPAGE_PMD_SIZE; return PAGE_SIZE; } --=20 2.51.1 From nobody Fri Dec 19 17:14:31 2025 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 9591F308F14 for ; Thu, 6 Nov 2025 21:29:28 +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=1762464570; cv=none; b=cgb0SxKKSwzvkJa4Ue1fqKGUhX0uLdrQlwtQgu73ZJIoE3J8n6pmQiIKO8nVhJ45Iy73BknMg8cdZfk4b/F4p2SB1Nv7LnVSW3KFQtVVRt9eA8dj9kCbh0XdBPEwtwXJpn91ysZmRm856mkAwBi8E+Ea1E8hCKwUfPeertPfBEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464570; c=relaxed/simple; bh=mZUwhrSjct79OADXPPXT1Fv3AVXEy295G5720Wv1cGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SWCGTz/BQbp+DDRJ1PlUFG1fDZNyAxLgW3TZ6BErgV5rPpESKppy+vbTDCvCs544oEjXXtcmAFdC1W0/s6zFLgmQd86Uhj/dk+b7jJnSfd5AjUzo7k46/b9kK22BB5VTrCgMS+CtOV+hVzZq7boYc2L0DsMOLtzJQKYfRCOzwJU= 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=KhlpPpYa; 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="KhlpPpYa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464567; 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=+Q/SGZoDMzCFiE+HfvZvclHk/fNK+yt1scbMDujY49o=; b=KhlpPpYaeQvE91jwHABnQklOz25O6Bo0J/jM6Pom3kgvNcSzEkzN00Lmo31nURUmrWf0VQ oW9qjhulx7xSWx7n6UvxatijFsuPlw9hSe8Q4Q9aZBaet6qJr7zv2zSk4NfYijD+xL7V8h 7D7evLwP223apBGhA4nF/jeiDJO1byU= 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-610-nUk9SCG5NVKVdyycDf4y2Q-1; Thu, 06 Nov 2025 16:29:24 -0500 X-MC-Unique: nUk9SCG5NVKVdyycDf4y2Q-1 X-Mimecast-MFC-AGG-ID: nUk9SCG5NVKVdyycDf4y2Q_1762464563 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 501C81800357; Thu, 6 Nov 2025 21:29:23 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 29FAE19560B2; Thu, 6 Nov 2025 21:29:22 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 06/10] mm: debug_vm_pgtable: use pgtable_has_pmd_leaves() Date: Thu, 6 Nov 2025 16:28:53 -0500 Message-ID: <237bcb7f3d832457322210cc7f8d1272c4ac88ef.1762464515.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.0 on 10.30.177.12 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 830107b6dd08..241b36c78ac9 100644 --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -170,7 +170,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); @@ -208,7 +208,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; @@ -269,7 +269,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"); @@ -674,7 +674,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"); @@ -721,7 +721,7 @@ static void __init pmd_soft_dirty_tests(struct pgtable_= debug_args *args) if (!IS_ENABLED(CONFIG_MEM_SOFT_DIRTY)) return; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD soft dirty\n"); @@ -738,7 +738,7 @@ static void __init pmd_swap_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"); @@ -801,7 +801,7 @@ static void __init pmd_swap_tests(struct pgtable_debug_= 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"); @@ -881,7 +881,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"); @@ -968,7 +968,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)); @@ -1226,7 +1226,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.51.1 From nobody Fri Dec 19 17:14:31 2025 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 7298F32E12D for ; Thu, 6 Nov 2025 21:29:31 +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=1762464573; cv=none; b=t6W5M+3+riDIEnT2dnGIKJfOE9UjRtF9ZTboD/IlfvkJltYlzsNND20IM4AiXKATbW3y5kr+xWIicHAuddLTQLEgmiuWJbRcloTWi39aJ88V7vHXW5JauZiJzWnxi8SkXRQpxBky3t08LDPnL2qKMQojCtv9yD+9g6mvJixueW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464573; c=relaxed/simple; bh=5RZkoJNqvdAIMPNqKgX7xIBRev8Oxa45/VMhXF9JQus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=POSBHo3TJ+N0lNkwRFaBXQyAOYX/rxOReuIgt5EyfRSUxmoR+gxGFfzw2z/aYTlObgwdruT9PKpkpQj3N6XVsXNudpZMcIkFvl8RD85t9ErLO00bUnO0opUWas4fRoGMHONPkzVW/Z+E02oiYg/tdc+N3JYCIIpiPruOmD3jUqY= 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=GQevbzIM; 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="GQevbzIM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464570; 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=FBljr+WN6jo8BbvNcwYQG53rmJXeLFNVvjGUHCqr4HA=; b=GQevbzIM2uQuiJ2xOWi/HQ1hQxZtglOkhbgQMgp5IgxI9xhLokceySENIPMS2nhhwDMzq4 OYOTR9/zCPVtT2hvU/+kQxSTjDYG40kDxWVlVKvfL0PBggtjfXfPTy4QQWlykim1Xl3WA6 nICGLL0JaTfjJWcHXElGk3On3XB8o/k= 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-128-WXTMg0QmNGeR0iOyZVa33A-1; Thu, 06 Nov 2025 16:29:25 -0500 X-MC-Unique: WXTMg0QmNGeR0iOyZVa33A-1 X-Mimecast-MFC-AGG-ID: WXTMg0QmNGeR0iOyZVa33A_1762464564 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 9F62B180045C; Thu, 6 Nov 2025 21:29:24 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 856B319560A7; Thu, 6 Nov 2025 21:29:23 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 07/10] treewide: rename has_transparent_hugepage() to arch_has_pmd_leaves() Date: Thu, 6 Nov 2025 16:28:54 -0500 Message-ID: <9b56da53df2f0da40be68de9a7208d527b144afa.1762464515.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.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Now that the majority of 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(), except for two exeptions: 1. shmem: shmem code runs very early during boot so it can't use pgtable_has_pmd_leaves() 2. hugepage_init(): just a temporary exception, this function 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 +- mm/shmem.c | 6 +++--- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtabl= e.h index ae73ecf4c41a..fb9539002392 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -616,8 +616,8 @@ int io_remap_pfn_range(struct vm_area_struct *vma, unsi= gned long vaddr, /* 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 347126dc010d..eb16ddedb40c 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -430,7 +430,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 @@ -446,7 +446,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 b7100c6a4054..68fe444ace56 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1881,8 +1881,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 e4c5f70b0a01..02a2772ec548 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -2026,8 +2026,8 @@ static inline bool pgtable_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 1d1b74950332..9bfa11aa2cbc 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -904,7 +904,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 7b50f3ec9b37..6702c9187114 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -181,7 +181,7 @@ EXPORT_SYMBOL(__arch_has_pmd_leaves); =20 static int __init init_arch_has_pmd_leaves(void) { - __arch_has_pmd_leaves =3D has_transparent_hugepage(); + __arch_has_pmd_leaves =3D arch_has_pmd_leaves(); return 0; } early_initcall(init_arch_has_pmd_leaves); diff --git a/mm/shmem.c b/mm/shmem.c index b9081b817d28..48312b7727a7 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -672,7 +672,7 @@ static int shmem_parse_huge(const char *str) else return -EINVAL; =20 - if (!has_transparent_hugepage() && + if (!arch_has_pmd_leaves() && huge !=3D SHMEM_HUGE_NEVER && huge !=3D SHMEM_HUGE_DENY) return -EINVAL; =20 @@ -4646,7 +4646,7 @@ static int shmem_parse_one(struct fs_context *fc, str= uct fs_parameter *param) ctx->huge =3D result.uint_32; if (ctx->huge !=3D SHMEM_HUGE_NEVER && !(IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - has_transparent_hugepage())) + arch_has_pmd_leaves())) goto unsupported_parameter; ctx->seen |=3D SHMEM_SEEN_HUGE; break; @@ -5430,7 +5430,7 @@ void __init shmem_init(void) #endif =20 #ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY) + if (arch_has_pmd_leaves() && 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.51.1 From nobody Fri Dec 19 17:14:31 2025 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 1ED8530748B for ; Thu, 6 Nov 2025 21:29:33 +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=1762464574; cv=none; b=pP2ko0t9f900aNigYC2falFnDFV1kl7CvT6StBjxnQl5X2QBxGFWt/9ewAqt43fuOwrsZxIkZbSQPY2g9kGOopTfH86Y27AcurR/kzrknClxasGzzjm5Gz9q1pO0fKAWe+pN77TE4wmcrEWziT7Dpp4gCZECLMaaUgKfl269LMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464574; c=relaxed/simple; bh=mU7IxdG+iZLDR4aUV1SBZiIFq8JqhdTWXMVvXiI3Hfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r0AROJAIrnrjMQX5uIZTGNdWVYlPNayMRYnzeY32AJBH1qx0KR/q8gbbF7PLRVagrLApl+Dzq7hSTkoOro6kcecnHatFyz4FC4VPV9Vy4NKyY3p321MTZbxwM6ZklYIwSSO2e+zHR0wI+OC+5goZfcvSqxftIg9+FORssj7H3PU= 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=Qo4CuCBu; 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="Qo4CuCBu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464572; 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=ShSdFYzhV0Y6APXZPKs3ZiZ210ybMNWShqtHNQeC/jQ=; b=Qo4CuCBuV2KjEpxYB7SKVwH31f4KaOcF/vVSncbnNluQIvwTp6/wgNgVz/DIuC594XIaTA HrjyTVxWpZ+yU8usBOf5NQ9e+cX5jZTuvvHyJ8fsNnYvYjOL9IakgB3PYxUCYb702hlrMV 0elxKjVfyZSvWZ5G9zfBkPUUwgRhv1M= 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-312-iG6epfEWMK268t0-mdSp6A-1; Thu, 06 Nov 2025 16:29:27 -0500 X-MC-Unique: iG6epfEWMK268t0-mdSp6A-1 X-Mimecast-MFC-AGG-ID: iG6epfEWMK268t0-mdSp6A_1762464565 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 CB79B1800473; Thu, 6 Nov 2025 21:29:25 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D47B419560A7; Thu, 6 Nov 2025 21:29:24 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 08/10] mm: replace thp_disabled_by_hw() with pgtable_has_pmd_leaves() Date: Thu, 6 Nov 2025 16:28:55 -0500 Message-ID: <83ee5e3b09ae9c0496790d70c5e47f71fd03e868.1762464515.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.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Despite its name, thp_disabled_by_hw() only checks whether the architecture supports PMD-sized pages. It returns true when TRANSPARENT_HUGEPAGE_UNSUPPORTED is set, which occurs if the architecture implements arch_has_pmd_leaves() and that function returns false. Since pgtable_has_pmd_leaves() provide 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 f327d62fc985..63d75a2897dd 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 9bfa11aa2cbc..0f016ea7082d 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. */ @@ -904,10 +904,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 6702c9187114..68d10a63276d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5345,7 +5345,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 48312b7727a7..406617a1fab8 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1780,7 +1780,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.51.1 From nobody Fri Dec 19 17:14:31 2025 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 7DFB4332904 for ; Thu, 6 Nov 2025 21:29:32 +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=1762464574; cv=none; b=De8404cm8zjt49OhQj8JBzXDFvp8VTifqZxc+hJxQsNZZ8sTUatU3mmSG1ziWOJWmIoYIyb8n52OaofklS43JhpSx/S+jrytV3A3Nt6WNQF7UFABsJouHJzVl0pEMnyLZKTznDxKvsosDdK0yaN0hhiAhbzs65Y5onBWNIgAev0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464574; c=relaxed/simple; bh=1T2wx5QuXjfi7mAYAugKsmzVMKvg5fYYqzV1rTTj+O4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qrZU9aavY0HcnA47heIq+vRVZP1Y3NjfQEN3cX151XOAZKAPSInQR+9+W3Byyewd5wZRufs0NA31HwKtaPzLhv3E8fb3mSvIl2FhBBKG9Dps4XG8wh+fKJoV+47VN4fjaF02XmAT2epWR7BsJeoofDEX9K3DuSiXZW7aAfILRyI= 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=T8zF3VNl; 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="T8zF3VNl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464571; 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=g/LNaSNalss2cwlG3Ezg158HR0y6d2DV+kb4sHUe3rY=; b=T8zF3VNlhF6KoPb4jaguI3ktVGLykAVt2ItmgBCvPX3isg+Cf0hVruJgXWtd3hO6nhiZrE fAMSq3RdwyB6R+8YKM34tKQyE5OALXx3NbfEByEQ8BjEC6RtvioknjKCy3I8/DpqaLZzjU qAXWncoAU5m4jLJvmTWFw9NOqnnl2Kk= 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-392-R36kOmdkMjmfZ5rrC7oMwA-1; Thu, 06 Nov 2025 16:29:28 -0500 X-MC-Unique: R36kOmdkMjmfZ5rrC7oMwA-1 X-Mimecast-MFC-AGG-ID: R36kOmdkMjmfZ5rrC7oMwA_1762464567 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 0208D195608F; Thu, 6 Nov 2025 21:29:27 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0C17819560A7; Thu, 6 Nov 2025 21:29:25 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 09/10] mm: thp: always enable mTHP support Date: Thu, 6 Nov 2025 16:28:56 -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.0 on 10.30.177.12 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. Signed-off-by: Luiz Capitulino --- mm/huge_memory.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0f016ea7082d..4117833c53ef 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); + 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. */ @@ -805,6 +808,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); + order =3D highest_order(orders); while (orders) { thpsize =3D thpsize_create(order, *hugepage_kobj); @@ -904,9 +910,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 */ --=20 2.51.1 From nobody Fri Dec 19 17:14:31 2025 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 9132633556F for ; Thu, 6 Nov 2025 21:29:33 +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=1762464575; cv=none; b=TrGBiV357tzhNX0qoA0vDKoJxjG+VemRRUj/fRmvNcePHUjxXvkMRYklzSXj3aycZG2F8rWQXtRT8D+hvoe7X9G62b6s1EKADJQ0K4sAG40iB/5QNi2bJjIa8b1vQt6+Jo96NgdE62ZC0DqVxGog62S3ovmJIn1caH/cbfU19ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464575; c=relaxed/simple; bh=t+C1/W4eMUuxtuOqHeiLxENPjKXRT7ASZ83M/f+4/UY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gR+H+CiofUkvSStQUQ3h++8q+No24Zdh2B9Bktz46z8x1DOwyvkVvmo9JH32cY7VJIGD0W3dQA1o8XDBa34Jr7lpnEpKCoT1mWqQtNLHayGbQif5+4/hJJDW6zgtCipzFD0BFF7F9+1GOhBd6AAv56iUsz03venE6uT6/ipj/OM= 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=Aa+VQPSG; 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="Aa+VQPSG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464572; 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=cXoXvGh7icUa4ulh0/ArAKzgINifhHLmj8YOfBJ+Zu0=; b=Aa+VQPSGfVxqE5UQiDUNjAgQgsXN+PYID4xaocx1aEljev5WEjv2leS79yA46dErPOJ4r0 p5vq9bPBMtD3mI2TeUKYzQQI1lY3zXs8QzXiuWb+heDUoWB8tKNLUwQR8v8awfu38FIryK 1PyLzTR4fzqG2G9/0AlVg9SnM/iWgNA= 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-609-DMJVGKR3MuiElvV9x0B0jQ-1; Thu, 06 Nov 2025 16:29:29 -0500 X-MC-Unique: DMJVGKR3MuiElvV9x0B0jQ-1 X-Mimecast-MFC-AGG-ID: DMJVGKR3MuiElvV9x0B0jQ_1762464568 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 32FA1195609F; Thu, 6 Nov 2025 21:29:28 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3657B19560A7; Thu, 6 Nov 2025 21:29:27 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 10/10] mm: thp: x86: cleanup PSE feature bit usage Date: Thu, 6 Nov 2025 16:28:57 -0500 Message-ID: <8dc0695aa1c1073ec475be18e300ec1046344e84.1762464515.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.0 on 10.30.177.12 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 enables 4MB page support and 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, using 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.51.1