From nobody Fri Jul 24 04:41:26 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 E4064311969 for ; Fri, 24 Jul 2026 01:34:49 +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=1784856891; cv=none; b=JHPS7Kwbt0Y7cn++HyVmuUM0tYREXJLN+yFMdvnWbdPMfl2lt3eT5msZO4xuHS6/eMxaKw8qvp8dAjuQhYSZYN53drJTmznmla13e1YIJ3QgwiMSLd/S2s/ARKwoRQoWUcj5oC7HchwAX48UC2wFNQwIqClByQxZHr13uJBOpMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856891; c=relaxed/simple; bh=jjjHMPkdak8lkkYB/pcSbYZxNq0AkW3cx++JKabbUsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dpMp2YGDBA0dQqf1dFuvpAhYm/ZjOjUVduC7axoFdJhiV3cLgZa5DbH9rjBVO8JUO9QLORKMqV4c2mczVjuqErWtB1YGO2uWko6aN75vU2qOo/LnGU2+5EEIGe0tQ1gpIaLNywprrcl/dNwI1wwIJvHJAfVIq6W4+CNVQ1u3M2Y= 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=f+CkimAW; 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="f+CkimAW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856888; 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=aTPhd0YOiSXsclxv5AA53kAUpU9ZSjRHrVegM1KWz8s=; b=f+CkimAWCgKFlSNcyt/k1zuCX4PjuhclCO35SHqV3JocmuxyyQBpwjtkb4EB+xo+1PSinK U2OWEKCUJJ1PIHQpaCMQt/bjtzutYgi2kqE67mX/THqv35zFy9Lg8Crbp7Xj4blyS3WCgl lkzyUfy4IpjwDY1KvqqJO4zMN8kZzLo= 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-440-UQzh6pdIO4SVB24qQpwLsw-1; Thu, 23 Jul 2026 21:34:45 -0400 X-MC-Unique: UQzh6pdIO4SVB24qQpwLsw-1 X-Mimecast-MFC-AGG-ID: UQzh6pdIO4SVB24qQpwLsw_1784856882 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 F1A221830331; Fri, 24 Jul 2026 01:34:40 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F3AE31800594; Fri, 24 Jul 2026 01:34:35 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 01/14] docs: tmpfs: remove implementation detail reference Date: Thu, 23 Jul 2026 21:34:05 -0400 Message-ID: <86170cc663c4bc70db88363f41e3b4dbb93d4a9e.1784856856.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 Reviewed-by: Lance Yang Reviewed-by: Zi Yan Reviewed-by: Dev Jain 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.55.0 From nobody Fri Jul 24 04:41:26 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 53D2A2931D0 for ; Fri, 24 Jul 2026 01:34: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=1784856895; cv=none; b=b/dHcj3PJDMsEK1o59S7MJF0kFt+vKZS5ZZxVftRWCskBY8N6Grs8gZw118O2/jVBoy1y2HsTgUAr7Xjxw6WKqLo9PN4krL61ywnNOTAdL5V2G1InG55akXWfTATn6z++1zM7y45q5C7LXXR/5Y5vfuwqBYaXmh4EwqwxA3TFqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856895; c=relaxed/simple; bh=ju+lLzyGsEqeWJRMLjDiPzMlELuc9NAHsGelr0wNqjk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bZUEuB3nYYuPZiVRCAppAe7dVCFuJMg6Go2JarBEesdpZvPjUHSdMnNaZHnyS3oVivdiKInZ+0i2EvzrIuLF3IyPMv/GuiP3SWvefdb4f9oDrjhVjSgME0IfRD+XWje6dQKBX9DM0iEVT9g06BeejUVPYOW/+he5L0MYLxoq6Vo= 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=StJ14ih3; 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="StJ14ih3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856893; 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=aIh7RPBAnJJFoaMlpLHLjWKSHstbWhClnoICZysb4Os=; b=StJ14ih3BUTj/FBRnZahmlA5xZ/MPNaEwDKcMiPTaVg/ktkhlCf61oKzB9fsEH2tp7p/Rz T2Q68E8jK6ORsquMM3LD8qB3olGXKE0ZcGBDwkQNYzoo52A2zPN5L1jrMoT7Sb1ei6ZfDe NSIhHi4Nzhf1kTkPeZR5tp3zcb0q03Q= 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-154-u5j-uJGsMHWUyqn-nW9p0A-1; Thu, 23 Jul 2026 21:34:49 -0400 X-MC-Unique: u5j-uJGsMHWUyqn-nW9p0A-1 X-Mimecast-MFC-AGG-ID: u5j-uJGsMHWUyqn-nW9p0A_1784856886 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 D9A1D1944CFD; Fri, 24 Jul 2026 01:34:45 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1B5EE180059C; Fri, 24 Jul 2026 01:34:40 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 02/14] mm: shmem: shmem_getattr(): set blksize to highest supported THP order Date: Thu, 23 Jul 2026 21:34:06 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Today, shmem_getattr() sets stat->blksize to PMD size whenever shmem_huge_global_enabled() returns non-zero. While this works fine for the normal THP-enabled case as explained by Baolin in [1], this has two problems: 1. Theoretically, when shmem is configured for within_size, this could set blksize to PMD size even though the allocation may be a smaller mTHP order 2. A future commit will allow shmem THP support to be enabled even when the CPU doesn't support PMD-sized pages. We should not allow blksize to be set to PMD size in this case In order to fix #1 and prepare for #2, this commit sets blksize to the size of the highest supported order returned by shmem_huge_global_enabled(). [1] https://lore.kernel.org/linux-mm/6591a74c-7ef9-4614-9ae9-cb2fbed86ebf= @linux.alibaba.com/ Suggested-by: Baolin Wang Acked-by: Zi Yan Signed-off-by: Luiz Capitulino --- mm/shmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 5071177059a9..19534e21b61f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1287,6 +1287,7 @@ static int shmem_getattr(struct mnt_idmap *idmap, { struct inode *inode =3D path->dentry->d_inode; struct shmem_inode_info *info =3D SHMEM_I(inode); + unsigned int orders; =20 /* Fast-path hint; recalc under info->lock corrects any stale read. */ if (data_race(info->alloced - info->swapped !=3D inode->i_mapping->nrpage= s)) @@ -1303,8 +1304,9 @@ static int shmem_getattr(struct mnt_idmap *idmap, STATX_ATTR_NODUMP); generic_fillattr(idmap, request_mask, inode, stat); =20 - if (shmem_huge_global_enabled(inode, 0, 0, false, NULL, 0)) - stat->blksize =3D HPAGE_PMD_SIZE; + orders =3D shmem_huge_global_enabled(inode, 0, 0, false, NULL, 0); + if (orders) + stat->blksize =3D PAGE_SIZE << highest_order(orders); =20 if (request_mask & STATX_BTIME) { stat->result_mask |=3D STATX_BTIME; --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 BA3453164D8 for ; Fri, 24 Jul 2026 01:35: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=1784856903; cv=none; b=mqt64Nj2cuvcoQRuYVDNsgyhZrCgNuyOflUWQDMb6eFQvmlKOTRV4beJb+kJcUDKw55lT0t9YdTFwbgseOmtwbxBZy+FHw7y8phT9Ia0x8s4Lmkx7RiiyCJ8VcuQ6uYZIvsFA0LEiwzGdwK1WbsDKgsJLzF2tSRUwZ1y5CPj/ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856903; c=relaxed/simple; bh=R8sXGjwypx3n8ig4lTMv4hsid/2uhu29oFnt/e3e2eE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OHbDCJmL2aGjoNgMhoe7KeeVqVL6bK9ggemOib0zjqFkhK3+XRAVgFTNqfZegOaMbyVWTtRmmg3aQZ5zava4mb7a3L3RZX3achSptJ9ckKQI29DtrvO9RAIxSwbIkLGD0DhgBSVkiRjARm/wbTNxO5cJSEx2QD+aUZbSd9rWwkk= 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=BePF9rf+; 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="BePF9rf+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856900; 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=N4WgUO5f7tfhU5uYl7yr/DaojI1yjAABTuJfiV9y+mA=; b=BePF9rf+Y7G6SeZ/AWO/6gxLbJ85jQTpvu7SEmturQAtTIDNvtO1ik+4p4SKSM2IbawG4R ClDNr79NS1EGULDIrOB0B6W3SVWzl7LmjjkLVoAfBNANxTv+LRnHq5h5Mkr4Efl9QonRS1 HgGU79YgWDqtC7q9DEkHs0BOa5Gp5qA= 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-269-fwi8CE4PNeKcdg1fTCl4BQ-1; Thu, 23 Jul 2026 21:34:55 -0400 X-MC-Unique: fwi8CE4PNeKcdg1fTCl4BQ-1 X-Mimecast-MFC-AGG-ID: fwi8CE4PNeKcdg1fTCl4BQ_1784856891 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 5E60919775E4; Fri, 24 Jul 2026 01:34:50 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 193EC1800594; Fri, 24 Jul 2026 01:34:45 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 03/14] mm: introduce pgtable_has_pmd_leaves() Date: Thu, 23 Jul 2026 21:34:07 -0400 Message-ID: <382fb2620d699aed276c8e21e3f5925082c4b5dd.1784856856.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" 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 pgtable_leaf_support_init(). We call pgtable_leaf_support_init() early during boot from mm_core_init(). 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 | 16 ++++++++++++++++ mm/memory.c | 9 +++++++++ mm/mm_init.c | 1 + 3 files changed, 26 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 8c093c119e5a..4c00cf53e183 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include =20 @@ -2313,6 +2314,21 @@ static inline const char *pgtable_level_to_str(enum = pgtable_level level) } } =20 +#ifdef CONFIG_MMU +DECLARE_STATIC_KEY_TRUE(__arch_has_pmd_leaves_key); +static inline bool pgtable_has_pmd_leaves(void) +{ + return static_branch_likely(&__arch_has_pmd_leaves_key); +} +void __init pgtable_leaf_support_init(void); +#else +static inline bool pgtable_has_pmd_leaves(void) +{ + return false; +} +static inline void __init pgtable_leaf_support_init(void) { } +#endif + #endif /* !__ASSEMBLER__ */ =20 #if !defined(MAX_POSSIBLE_PHYSMEM_BITS) && !defined(CONFIG_64BIT) diff --git a/mm/memory.c b/mm/memory.c index 56b244552f13..d6540d6d4ef9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -164,6 +164,15 @@ __setup("norandmaps", disable_randmaps); =20 unsigned long highest_memmap_pfn __read_mostly; =20 +DEFINE_STATIC_KEY_TRUE(__arch_has_pmd_leaves_key); +EXPORT_SYMBOL(__arch_has_pmd_leaves_key); + +void __init pgtable_leaf_support_init(void) +{ + if (!has_transparent_hugepage()) + static_branch_disable(&__arch_has_pmd_leaves_key); +} + void mm_trace_rss_stat(struct mm_struct *mm, int member) { trace_rss_stat(mm, member); diff --git a/mm/mm_init.c b/mm/mm_init.c index 711f821f7b3c..dcc072db4558 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2699,6 +2699,7 @@ void __init mm_core_init(void) { arch_mm_preinit(); init_zero_page_pfn(); + pgtable_leaf_support_init(); =20 /* Initializations relying on SMP setup */ BUILD_BUG_ON(MAX_ZONELISTS > 2); --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 9269F318BB3 for ; Fri, 24 Jul 2026 01:35:04 +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=1784856906; cv=none; b=SIhjbvYRQg2Z0zJ/ps33zLxjwlvOneWBXW3fwJAPfO5bk+lzOkFMv6vHC80LdmoecsmC+dPzkXV0CZtAm8w23nwzYVPLi6V9Ol3A2dgW/QGUGIJyN+vbGq6Tjpmhau74bkPMx8BJD5dTDHAosOTlkaCMkayCG+6VkFUGnz8nXZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856906; c=relaxed/simple; bh=Hk9uSVxa6ozJbm9L9t52BEhmCYjuTfaN5zGghzmGGcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hpeNmnMyReZwPAsghX5xjshmAm3TH68ED12tozbkmQXpOlxqlJYY7WgVG6/ap6Na4FNcU6aDqUY3wiI372+wok0lv45lsdHSOYGq9agZylWgV1KWsWWZ0xAdPm2RQUDixciazgVy0rU1q18MLBPUEJfuWDvqYnHk85UzG74FTc8= 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=MHqPg6LL; 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="MHqPg6LL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856903; 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=tVSG93ZZmpsoCFPChQ51HXQTyyrA3EtBA9ejpbXNmtc=; b=MHqPg6LLewyafOdsLpW6HqPLVgrQVyidGbAmQZ4+qpPKswhvF4irsI97tNzyfwhK5wcDIk VNQorCLsnURee5qI2brY7Mx9cj5a3MO7tJNlhArcV4Ck5YsuY3jpdO9w+aNqIQFQ807Xy9 qi/7A7otpJrxjrmr/pwDdMcbqNeio7Y= 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-207-CWEtSk_2Nz6eK3sn3xADZQ-1; Thu, 23 Jul 2026 21:34:58 -0400 X-MC-Unique: CWEtSk_2Nz6eK3sn3xADZQ-1 X-Mimecast-MFC-AGG-ID: CWEtSk_2Nz6eK3sn3xADZQ_1784856895 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 2626C1977534; Fri, 24 Jul 2026 01:34:55 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 924A3180059C; Fri, 24 Jul 2026 01:34:50 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 04/14] drivers: dax: use pgtable_has_pmd_leaves() Date: Thu, 23 Jul 2026 21:34:08 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" dax_align_valid() uses has_transparent_hugepage() to check if PMD-sized pages are supported, use pgtable_has_pmd_leaves() instead. Acked-by: David Hildenbrand (Red Hat) Signed-off-by: Luiz Capitulino --- drivers/dax/dax-private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h index 81e4af49e39c..35744ff6592a 100644 --- a/drivers/dax/dax-private.h +++ b/drivers/dax/dax-private.h @@ -123,7 +123,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.55.0 From nobody Fri Jul 24 04:41:26 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 DC9AC313546 for ; Fri, 24 Jul 2026 01:35:05 +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=1784856908; cv=none; b=iPGYfRJajuyWXYxH8ylLcLDUn5VLpxZ1hvPbQhO3lxMH3eZuRWMq0DXMSFgcedz8lTYbnojt/ZCXW4xBjvr9yJYu2GJvp9yBbos9ZjhcAbKO1sI/H+VEifxPwZTyVhtvqnVPACbj/IEebC+NaEhe0A6td4PO2OG5a88U+0mRoxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856908; c=relaxed/simple; bh=V/ZoTEkWXOtImTwoEfhGMxCO3nj3l9asJXzzKsI+Wd4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XzMqbS6l/gXbM8vknK63dQwIV4Io0JpMV0E2AEa+kM+ElenZ6y8LG+FIbKm7GRCozZiwl6f1iNiOHmsSJ0VaxroktSlwWaZzAfLj39YFhYsH3MUg1NjiRF/JtfX84JOelAILpJT7SC+B/mLbtm0mK7mGVDbdlK2iubAwexnuX7M= 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=dsjXxARW; 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="dsjXxARW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856904; 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=vWKt08g60DdFG3Icxm2Us7CxOftu08depFwjwgt6DxU=; b=dsjXxARW6THwCmyFVinsf83Dkj1ppHlS9npO8T+FAKiC3ERoekRV/3p3G6iF+aes4UEFAi 8r//JnQLUUgUvTalVfm2sFazTsdx6P3NdBfxbO8NPHR1ziyuZEMwgqFuRG9rtP6W/UB55V Cq1QPQUne1tm9DQ4BSQYBuQdjrx/qkk= 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-279-cG1cyqeGNnapWIvwGoKkEw-1; Thu, 23 Jul 2026 21:35:02 -0400 X-MC-Unique: cG1cyqeGNnapWIvwGoKkEw-1 X-Mimecast-MFC-AGG-ID: cG1cyqeGNnapWIvwGoKkEw_1784856899 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 7644D183130E; Fri, 24 Jul 2026 01:34:59 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 59A301800594; Fri, 24 Jul 2026 01:34:55 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 05/14] drivers: nvdimm: use pgtable_has_pmd_leaves() Date: Thu, 23 Jul 2026 21:34:09 -0400 Message-ID: <726742b1d017f569eaae3df1a543a18aed290988.1784856856.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" nd_pfn_supported_alignments() and nd_pfn_default_alignment() use has_transparent_hugepage() to check if THP is supported with PMD-sized pages. Use pgtable_has_pmd_leaves() instead. Also, check for IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) to preserve the current implementation semantics. Acked-by: Zi Yan Signed-off-by: Luiz Capitulino --- drivers/nvdimm/pfn_devs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 8fa9c16aba7e..457eb54e7ab6 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -94,7 +94,8 @@ static unsigned long *nd_pfn_supported_alignments(unsigne= d long *alignments) =20 alignments[0] =3D PAGE_SIZE; =20 - if (has_transparent_hugepage()) { + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && + pgtable_has_pmd_leaves()) { alignments[1] =3D HPAGE_PMD_SIZE; if (has_transparent_pud_hugepage()) alignments[2] =3D HPAGE_PUD_SIZE; @@ -109,7 +110,8 @@ static unsigned long *nd_pfn_supported_alignments(unsig= ned long *alignments) static unsigned long nd_pfn_default_alignment(void) { =20 - if (has_transparent_hugepage()) + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && + pgtable_has_pmd_leaves()) return HPAGE_PMD_SIZE; return PAGE_SIZE; } --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 65A2D3168EB for ; Fri, 24 Jul 2026 01:35:12 +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=1784856913; cv=none; b=svZxwA7DR9CX9VkZhQOWiknbPgfW+cct9DbGmfpFSadevXxKKrvmBPvi6Ak5pN5U99MF+W5xINwrJhx5OT1jKVxkKzGWUMMxchOH9qnKwXoGPo9juEuLOg9GLbJK1XDfO408MRDz35nCXfBt/HaI2Qfh1FozwrI5kG6qjHuMle4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856913; c=relaxed/simple; bh=4V3DzS2gX3wjcHhnRervOk7hTouQtCPr8g2YJfIu0w8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c/LzUuQA2xBu4jCg78VF5gOvIFbnYp3TIuHrC/sq/qfVeU/3p/N7ZQuQVgfIhJlVY/3g8/YGmr9V6Is1Mtl//aDz7+ZB2Z3MDY6bUqnpZ1i2kouk4CoV5XrQKXjmMtx/cLEfUcenhvG8Atz/pK6D5wpcTFjj78SFfD+TKLIx0ho= 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=UKBLNzqX; 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="UKBLNzqX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856911; 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=jaZuFD7TaK5q+SRf/M6wNF+Sb+xKBaTWhSdcsCrRx7E=; b=UKBLNzqXLhcs0dm8YXu3rlbqyy8OkJ5TZbBreT22yYk9TBMB9K1Y97d5CJsfhT7hW4NCxN DEcHf4+UfQyIT2r1szdVIuDdZCV/gId7TPHI9PSz+u079hHkYSI5Xf7vI6ZD9U2cal5vqf W+nucZXhVHAKJ/CqiZosoAyB8NOZfA0= 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-172-qqWkX9JjOvmV6bXqg4KyxA-1; Thu, 23 Jul 2026 21:35:06 -0400 X-MC-Unique: qqWkX9JjOvmV6bXqg4KyxA-1 X-Mimecast-MFC-AGG-ID: qqWkX9JjOvmV6bXqg4KyxA_1784856903 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5A5601944EB1; Fri, 24 Jul 2026 01:35:03 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AB501180059C; Fri, 24 Jul 2026 01:34:59 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 06/14] mm: debug_vm_pgtable: use pgtable_has_pmd_leaves() Date: Thu, 23 Jul 2026 21:34:10 -0400 Message-ID: <2bd3de77beffbc6130737ffc77a00cb080efcb8c.1784856856.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. Reviewed-by: Lance Yang Reviewed-by: Zi Yan 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 2875fd22d7bb..25038b74c7bc 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_ARCH_HAS_PTE_PROTNONE)) 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_HAS_PMD_SOFTLEAVES)) return; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD swap soft dirty\n"); @@ -825,7 +825,7 @@ static void __init pmd_softleaf_tests(struct pgtable_de= bug_args *args) swp_entry_t arch_entry; pmd_t pmd1, pmd2; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD swap\n"); @@ -906,7 +906,7 @@ static void __init pmd_thp_tests(struct pgtable_debug_a= rgs *args) { pmd_t pmd; =20 - if (!has_transparent_hugepage()) + if (!pgtable_has_pmd_leaves()) return; =20 pr_debug("Validating PMD based THP\n"); @@ -997,7 +997,7 @@ static void __init destroy_args(struct pgtable_debug_ar= gs *args) } =20 if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - has_transparent_hugepage() && + pgtable_has_pmd_leaves() && args->pmd_pfn !=3D ULONG_MAX) { debug_vm_pgtable_free_huge_page(args, args->pmd_pfn, HPAGE_PMD_ORDER); args->pmd_pfn =3D ULONG_MAX; @@ -1249,7 +1249,7 @@ static int __init init_args(struct pgtable_debug_args= *args) } =20 if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && - has_transparent_hugepage()) { + pgtable_has_pmd_leaves()) { page =3D debug_vm_pgtable_alloc_huge_page(args, HPAGE_PMD_ORDER); if (page) { args->pmd_pfn =3D page_to_pfn(page); --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 0988730566A for ; Fri, 24 Jul 2026 01:35:17 +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=1784856919; cv=none; b=QXDm6WeqV1gUWAFv3dvQ0UrFJeEZb3bm7uPyMAecPmBTENv2GtWFoPGlZFWuPFBc9I3bvbiqehEK2dT9pRoijEW567QWRz7F9EUcAPM5Gal8Y1/jsKHZZl3T0eS+nMEl1SNGUl1B9Qi1apt5c+ADvIoJzinMMYmSveRcWnZYyfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856919; c=relaxed/simple; bh=3guI3PGlZEmeKgSTyCX7J09nVz7+nTM1yqTYb2P19Jo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kYQ09xdQKrE4y7DSQ0JBYUNHcSlgLJxMfTVfVCGUhn9W4Ida7Z62xWxRMlm5iu9FlRFeQLV2TW9r3N5Xyopf3c9wtytt78ykhC3UmfrhK3o2u6jtmFCYTYV3xEQxMj2I3J5Ba/5dbhLcrEP1SYTc3fkz4IWqkO2b8hxE3F84hvY= 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=fAf5MjGQ; 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="fAf5MjGQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856917; 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=HYklReB2oAm0GSZc5icymDcgDC+npGwNtMCe2qntLC4=; b=fAf5MjGQ6RdYIgXzE2/q914idPsqm35GBrd4jDOwxAkq2fnkDVOwIZ5l4kcNYllZ5A1prL 0uSCQ6M0gNjz9eTR9KiRRaiSnXPPI2M9uwax7bKOBf6vpdjZWD1Kjz8SgVGM+czaQEotvE 2iclNH4DHDnMwlX+lAosGGxZANK3QyY= 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-655-o0NMr0p_OPOKS36bmNUCzg-1; Thu, 23 Jul 2026 21:35:10 -0400 X-MC-Unique: o0NMr0p_OPOKS36bmNUCzg-1 X-Mimecast-MFC-AGG-ID: o0NMr0p_OPOKS36bmNUCzg_1784856907 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 39204180AAB5; Fri, 24 Jul 2026 01:35:07 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8F84A1800594; Fri, 24 Jul 2026 01:35:03 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 07/14] mm: shmem: allow THP support determination at folio allocation time Date: Thu, 23 Jul 2026 21:34:11 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" In order to enable THP support in shmem today, besides the user configuration required, the CPU must support PMD-sized pages. This is the case because of the following has_transparent_hugepage() usage: - shmem_parse_one() and shmem_parse_huge(): Check if THP is built-in and if the CPU supports PMD-sized pages - shmem_init(): Since the CONFIG_TRANSPARENT_HUGEPAGE guard is outside the code block calling has_transparent_hugepage(), the has_transparent_hugepage() call is exclusively checking if the CPU supports PMD-sized pages While it's necessary to check if CONFIG_TRANSPARENT_HUGEPAGE is enabled in all cases, shmem can determine THP size support at folio allocation time. Therefore, drop the has_transparent_hugepage() usage listed above while keeping the CONFIG_TRANSPARENT_HUGEPAGE checks. Additionally, we need to check if PMD size order is supported in shmem_getattr(). Use pgtable_has_pmd_leaves() for that. Reviewed-by: Baolin Wang Signed-off-by: Luiz Capitulino --- mm/shmem.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 19534e21b61f..68ae606b5c4c 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 @@ -1305,6 +1305,8 @@ static int shmem_getattr(struct mnt_idmap *idmap, generic_fillattr(idmap, request_mask, inode, stat); =20 orders =3D shmem_huge_global_enabled(inode, 0, 0, false, NULL, 0); + if (!pgtable_has_pmd_leaves()) + orders &=3D ~BIT(PMD_ORDER); if (orders) stat->blksize =3D PAGE_SIZE << highest_order(orders); =20 @@ -4589,8 +4591,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; @@ -5385,7 +5386,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.55.0 From nobody Fri Jul 24 04:41:26 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 3482123507B for ; Fri, 24 Jul 2026 01:35:18 +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=1784856920; cv=none; b=GuQ7PgHEpuvDWGdFVm1g5mdkCAHBUPSIaH1jr0vnWWyeaNjS+xihjkrNYBkjz1r6wzO6pYczmSiccEHhsu3MSRtCMkoFC75sIme7pU1f0iEVmhtk6igSvNiC6JHs1JxizMG230EXJ3MfY0xJRov5LeUafQHPmBETZUUxrYC9UOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856920; c=relaxed/simple; bh=cA2KrQssFavCXETqTAJ4+nRVRPEzq2hU+CG0iQp2Adg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sojl6j06lrcSN7+AbWo+5KKddf623ur1BZBdXkpCK65UKJIK5ZS6P3wdJ8/t3OtmHOxy9jSecrO9NA541xup4GrcGbQV3QWQuLeaeLBV7GqXeZM5VYQpFE/QMxuc6EC/RoNu/mlgYWxfafEaTBNjVKnQS3zSMbQWx0dSi4LAmKo= 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=aTRPVWg8; 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="aTRPVWg8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856918; 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=M3fN+U6OLu9RcmoUGqbKd31qZxKwWcR6lqChPGtz0M4=; b=aTRPVWg8BzwBRMmMZIyo6+504c98aISZ67V3vnKHAfh4LvPFWtuI2G7ueZ5I2ZZCxhB8Tt lP9Cq1ARbgohrPdzHrCUNr4twpLCMpFpmIymtyTtT0PvPrmB1aOFrHCj6P4f66NSb15Ljq wZ3WJiOp1YXxTMpt5IrmPur5m9ROZEw= 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-678-wqESUF_APxif9TVu7ateZQ-1; Thu, 23 Jul 2026 21:35:14 -0400 X-MC-Unique: wqESUF_APxif9TVu7ateZQ-1 X-Mimecast-MFC-AGG-ID: wqESUF_APxif9TVu7ateZQ_1784856911 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 3694518007ED; Fri, 24 Jul 2026 01:35:11 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6DF09180059A; Fri, 24 Jul 2026 01:35:07 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 08/14] s390: move has_transparent_hugepage() out of THP guard Date: Thu, 23 Jul 2026 21:34:12 -0400 Message-ID: <3ab69c6a9210d2764f714a093eff731dcb55ed14.1784856856.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" has_transparent_hugepage() definition is guarded by CONFIG_TRANSPARENT_HUGEPAGE, but there's a need to use it when CONFIG_TRANSPARENT_HUGEPAGE=3Dn. Move the definition out of the THP guard. Signed-off-by: Luiz Capitulino --- arch/s390/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtabl= e.h index e882663a58e7..5aa8f621df04 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1825,13 +1825,13 @@ static inline int pmd_trans_huge(pmd_t pmd) { return pmd_leaf(pmd); } +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 #define has_transparent_hugepage has_transparent_hugepage static inline int has_transparent_hugepage(void) { return cpu_has_edat1() ? 1 : 0; } -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 #ifdef CONFIG_PAGE_TABLE_CHECK static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned= long addr, pte_t pte) --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 EC27030566A for ; Fri, 24 Jul 2026 01:35: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=1784856924; cv=none; b=ZK1sglemTNqsrIdrDJ5OrFub2mUTmCUXmrq3GwQEVZZbRlsuIemEKjU9YyubMEGfyXnPBpGRFcRjHV/aEWILBOf+VtDeom/wuAxmZGODz6y7Kc8KRUVoS0ooLyDNa5SoT/qCz0azHKBGJZORebE1lQHa46RCHsq/y8XwXK6/EnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856924; c=relaxed/simple; bh=YFTEwD+SWfywdkGiZdfk/cAlFVzuABKh4ZAt5FV4B94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qvSV8gLvde8iDspPc1nBSC3CuEa6Se3dOFqtxm1wvU5pLMZAE4EILgEvNbieHrZ1FJvODg04+JEXsRykeWiWgqSI8iu+7Ua/W+lf8B4KUlmXryRlHa0e3/cAU9kLxJaEPDO9QXd3+7QtEapm+9Dmq7f91zBFvaVkF3RG0pKj/dI= 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=N8haj5lD; 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="N8haj5lD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856921; 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=cOa/59JmCKeAYJ2ebD2ctA/PG5bDvtBZwPXhXKsPfUM=; b=N8haj5lDVNobB4NymCnMpopWNGu0WDbNByd4S/tlVKfgH0c6qk4qahDkygKXpl48fRRGNW sOCFCPncES2Pp7vy3DoPAtY190tjT9Lx/OLugLRiRVYdUDRB4+w/HXryFzZ4dvjtYsYbH8 nhPLNFXU6VobkxVm4ZZClYWcdAI/a1A= 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-394-Az6f25ZYPI-ycQsqqY49EQ-1; Thu, 23 Jul 2026 21:35:18 -0400 X-MC-Unique: Az6f25ZYPI-ycQsqqY49EQ-1 X-Mimecast-MFC-AGG-ID: Az6f25ZYPI-ycQsqqY49EQ_1784856915 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 0EE1F180A997; Fri, 24 Jul 2026 01:35:15 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6BE68180059A; Fri, 24 Jul 2026 01:35:11 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 09/14] powerpc: move has_transparent_hugepage() out of THP guard Date: Thu, 23 Jul 2026 21:34:13 -0400 Message-ID: <29b33d5aed6d788381f42cba9dcaeb8a83569790.1784856856.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" has_transparent_hugepage() definition is guarded by CONFIG_TRANSPARENT_HUGEPAGE, but there's a need to use it when CONFIG_TRANSPARENT_HUGEPAGE=3Dn. Move the definition out of the THP guard. Signed-off-by: Luiz Capitulino --- 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 | 18 +++++++++--------- arch/powerpc/include/asm/book3s/64/radix.h | 14 +++++++------- arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) 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..79511e6abfca 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h @@ -165,9 +165,9 @@ 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); #endif =20 +extern int hash__has_transparent_hugepage(void); #endif /* !__ASSEMBLER__ */ =20 #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */ 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..a4a44a112ff9 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h @@ -278,9 +278,9 @@ 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); #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 +extern int hash__has_transparent_hugepage(void); #endif /* __ASSEMBLER__ */ =20 #endif /* _ASM_POWERPC_BOOK3S_64_HASH_64K_H */ diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/in= clude/asm/book3s/64/pgtable.h index f4db7d7fbd5c..2a795f6d9263 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1121,15 +1121,6 @@ static inline void update_mmu_cache_pud(struct vm_ar= ea_struct *vma, { } =20 -extern int hash__has_transparent_hugepage(void); -static inline int has_transparent_hugepage(void) -{ - if (radix_enabled()) - return radix__has_transparent_hugepage(); - return hash__has_transparent_hugepage(); -} -#define has_transparent_hugepage has_transparent_hugepage - static inline int has_transparent_pud_hugepage(void) { if (radix_enabled()) @@ -1441,6 +1432,15 @@ static inline bool arch_needs_pgtable_deposit(void) =20 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 +extern int hash__has_transparent_hugepage(void); +static inline int has_transparent_hugepage(void) +{ + if (radix_enabled()) + return radix__has_transparent_hugepage(); + return hash__has_transparent_hugepage(); +} +#define has_transparent_hugepage has_transparent_hugepage + #define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION pte_t ptep_modify_prot_start(struct vm_area_struct *, unsigned long, pte_t= *); void ptep_modify_prot_commit(struct vm_area_struct *, unsigned long, diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/incl= ude/asm/book3s/64/radix.h index da954e779744..50545cf519bd 100644 --- a/arch/powerpc/include/asm/book3s/64/radix.h +++ b/arch/powerpc/include/asm/book3s/64/radix.h @@ -298,22 +298,22 @@ extern pmd_t radix__pmdp_huge_get_and_clear(struct mm= _struct *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__has_transparent_pud_hugepage(void) { - /* For radix 2M at PMD level means thp */ - if (mmu_psize_defs[MMU_PAGE_2M].shift =3D=3D PMD_SHIFT) + /* For radix 1G at PUD level means pud hugepage support */ + if (mmu_psize_defs[MMU_PAGE_1G].shift =3D=3D PUD_SHIFT) return 1; return 0; } +#endif =20 -static inline int radix__has_transparent_pud_hugepage(void) +static inline int radix__has_transparent_hugepage(void) { - /* For radix 1G at PUD level means pud hugepage support */ - if (mmu_psize_defs[MMU_PAGE_1G].shift =3D=3D PUD_SHIFT) + /* For radix 2M at PMD level means thp */ + if (mmu_psize_defs[MMU_PAGE_2M].shift =3D=3D PMD_SHIFT) return 1; return 0; } -#endif =20 struct vmem_altmap; struct dev_pagemap; diff --git a/arch/powerpc/mm/book3s64/hash_pgtable.c b/arch/powerpc/mm/book= 3s64/hash_pgtable.c index d9b5b751d7b7..50316f3fc5d3 100644 --- a/arch/powerpc/mm/book3s64/hash_pgtable.c +++ b/arch/powerpc/mm/book3s64/hash_pgtable.c @@ -391,6 +391,8 @@ pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *m= m, return old_pmd; } =20 +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ + int hash__has_transparent_hugepage(void) { =20 @@ -422,8 +424,6 @@ int hash__has_transparent_hugepage(void) } EXPORT_SYMBOL_GPL(hash__has_transparent_hugepage); =20 -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ - #ifdef CONFIG_STRICT_KERNEL_RWX =20 struct change_memory_parms { --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 2D51B2356BE for ; Fri, 24 Jul 2026 01:35: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=1784856926; cv=none; b=K7E//NlU1KyTy0C1kcQUQeWeHbSKa4Pdi3i1z9wRIg8+UDwwjrvzIWKuE2kb8OrIfOkh1igze3+//esB7hOPe5K6i7+SIByGLnuvfVllQyf412xSkscmh9FAoGtTIDGb+nCFPUyx9mGT5sMIIjDx+Vn+XKgFt49d+V2gYsoVByI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856926; c=relaxed/simple; bh=J0bPWnYIrZbQ0xE6g3GCbSPFViCHg01sCqC84614T/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tzce4S4aQns6lgKtoUIUFIXm4Yg1E7B2/zca41qb786SdiAZRAqPf0crQEFHrxxuOgdx/8kFGNB1QnDrNh/FIjFA1oezlInQ0FjJDZO50+jo2hjyK5IFe+gtpSX63yvIkMFIdWtGFsvAaU9xliGw/pIiEzQRpykl1g/bWuh9pfQ= 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=G0ZNcl7a; 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="G0ZNcl7a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856924; 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=m95tIey3ZtO+pvQbNpV+QgUQHO9n1DJkdAhqLOU6XCs=; b=G0ZNcl7adZuURf2SuYp1Y137vgn2pjXVlMcFZhptGF5JtXbJMoNDN6GL/ekIl3ZSF+IguJ 9FqjotsN5HpNdeqsuWDAe9ntE2NYmExrBcUagqBj8ReSob0+I+hn9xZciqLnq7YxWMD0c2 aq+Fy5Rn/yM3G8y+4qzvf25GylusdWI= 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-610-yamiaaF0PwitWjTXObKyCw-1; Thu, 23 Jul 2026 21:35:22 -0400 X-MC-Unique: yamiaaF0PwitWjTXObKyCw-1 X-Mimecast-MFC-AGG-ID: yamiaaF0PwitWjTXObKyCw_1784856919 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 110CE18011EA; Fri, 24 Jul 2026 01:35:19 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 43B6B180059A; Fri, 24 Jul 2026 01:35:15 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 10/14] mips: move has_transparent_hugepage() out of THP guard Date: Thu, 23 Jul 2026 21:34:14 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" has_transparent_hugepage() definition is guarded by CONFIG_TRANSPARENT_HUGEPAGE, but there's a need to use it when CONFIG_TRANSPARENT_HUGEPAGE=3Dn. Move the definition out of the THP guard. Signed-off-by: Luiz Capitulino --- arch/mips/include/asm/pgtable.h | 6 +++--- arch/mips/mm/tlb-r4k.c | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtabl= e.h index fa7b935f947c..b038da872ec6 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -615,9 +615,6 @@ 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); - static inline int pmd_trans_huge(pmd_t pmd) { return !!(pmd_val(pmd) & _PAGE_HUGE); @@ -743,6 +740,9 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_s= truct *mm, =20 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 +#define has_transparent_hugepage has_transparent_hugepage +extern int has_transparent_hugepage(void); + #ifdef _PAGE_HUGE #define pmd_leaf(pmd) ((pmd_val(pmd) & _PAGE_HUGE) !=3D 0) #define pud_leaf(pud) ((pud_val(pud) & _PAGE_HUGE) !=3D 0) diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 24fe85fa169d..f4e369342a56 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -432,8 +432,6 @@ void add_wired_entry(unsigned long entrylo0, unsigned l= ong entrylo1, #endif } =20 -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - int has_transparent_hugepage(void) { static unsigned int mask =3D -1; @@ -452,8 +450,6 @@ int has_transparent_hugepage(void) } EXPORT_SYMBOL(has_transparent_hugepage); =20 -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ - /* * Used for loading TLB entries before trap_init() has started, when we * don't actually want to add a wired entry which remains throughout the --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 C28F21D47AC for ; Fri, 24 Jul 2026 01:35:30 +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=1784856932; cv=none; b=uVYJcGYX55Sy9+1r8UAU9zqZvM+EroHC+SDTcfqx8P0ShkgEKesMO5r6aCQYFtWh7XzlueaUQYSbYhMMb8jWUto9hQ80bS5wUDz0iehgUUtCPoloIyU/R6aTdcPRnvirl2D60ZDJd/+3NJpfHIInAOFw/adSiWSp7LzPdQuh5/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856932; c=relaxed/simple; bh=BvMw38SGUqLTlaFyKOdXdj8lZ42dd0Qld/L80SmnWlY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JkWQYqWC2s9PEM1/XHHKxkTulPHBcDQ4y3Q0Asi54jPmYv4YLvX64x1bxkZbVcGaWuaBVdhMGo7GJS4tmRHWc6SLU0vhe846JHm9YhQ8gvR2ZzNuJBU6dACX97vEZhFpzCY7UaJPZvdxnCy0S080Q3xurvg5gJ23yKmFONston4= 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=dYW3ExYQ; 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="dYW3ExYQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856929; 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=uBV8k5IXd6ab3fSjMUjNqJ/CRTgCYWOeALPQ6DqHXco=; b=dYW3ExYQ2eVyxEl0axvPrPklgaEqdZWaxBn6GKflpiVYlolLWzkpYtkCDVUQqR7xFqvzW5 CRnhyWYSg/u0uzwuZSw6W1cg7WjwzTXt45/zElvsQTaep6uFX00UryDJELTy9rCvLA6b6+ ZCyXLecL58HJaKlh7On7WT8Ad6Yso68= 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-17-U7tegR60Nmuz7K5YbVIW8w-1; Thu, 23 Jul 2026 21:35:26 -0400 X-MC-Unique: U7tegR60Nmuz7K5YbVIW8w-1 X-Mimecast-MFC-AGG-ID: U7tegR60Nmuz7K5YbVIW8w_1784856923 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 C4FB4183066D; Fri, 24 Jul 2026 01:35:22 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 465F3180059C; Fri, 24 Jul 2026 01:35:19 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 11/14] x86: move has_transparent_hugepage() out of THP guard Date: Thu, 23 Jul 2026 21:34:15 -0400 Message-ID: <12a6a1eb16e07359439c8c7d14e187a8ad56357a.1784856856.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" has_transparent_hugepage() definition is guarded by CONFIG_TRANSPARENT_HUGEPAGE, but there's a need to use it when CONFIG_TRANSPARENT_HUGEPAGE=3Dn. Move the definition out of the THP guard. Signed-off-by: Luiz Capitulino --- arch/x86/include/asm/pgtable.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 8e0018fadd14..3c62b33147fa 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -306,12 +306,6 @@ 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) -{ - return boot_cpu_has(X86_FEATURE_PSE); -} - #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP static inline bool pmd_special(pmd_t pmd) { @@ -337,6 +331,12 @@ static inline pud_t pud_mkspecial(pud_t pud) #endif /* CONFIG_ARCH_SUPPORTS_PUD_PFNMAP */ #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 +#define has_transparent_hugepage has_transparent_hugepage +static inline int has_transparent_hugepage(void) +{ + return boot_cpu_has(X86_FEATURE_PSE); +} + static inline pte_t pte_set_flags(pte_t pte, pteval_t set) { pteval_t v =3D native_pte_val(pte); --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 4653F31D759 for ; Fri, 24 Jul 2026 01:35: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=1784856936; cv=none; b=RZi/hhuvwZJRzAcbgD6rmPWL6BD1IbtCtii4eiZdQoPw4nQSdGmIOtfuoRqFpDayzO79D6r+9YaFYjderc2bByXF0aALMbRsZxApGRX982n5e5t0t9mbVYI6erQPPmE3zQzhVlTeCJYB4C0QOqsF9HQ2Doj2+HRwv4a2d0B3qTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856936; c=relaxed/simple; bh=nPQaOfWUNLNU2OEMiDC91DfuyLVkxb7Pek9g3iNZfA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UxJiIdn/0shz9o37EH8WmXv9cTgSUXko87ZYwHfn9+3Lw5RCjGrJVR1XNJDpwdek2MZWJFtZv+sLyoAuDq5ZvlnFwknNMJ7bPaQqCyXL7b7wVha5q51OFMW1wQR3pQ6dPZL+f7AmpFkEb1090FZKoZLE9pAEG3vIKC2R9KHbAxI= 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=JDLau4ui; 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="JDLau4ui" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856933; 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=NmG4KDvtxag7hsVnR/hZC54Qonf4BczxEK6GS3DrpEE=; b=JDLau4ui7/GKi10Sm7sTmTkJtJ0JU5qM44cT1VZD8RgX/1umIFoqEsMnvYCKKthAEl4pIR OFf/JyAuL22GH+Q/0Gr9D1os0iydhmOjusAF3Tg/kKGLWW42uCLVBv+cnJzxUJmQhsbV2U Sm4iHlN6NY43ntRX21iZcnn8H8TA++I= 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-534-nBgHwHz4N2iQtQ_cZCqREw-1; Thu, 23 Jul 2026 21:35:29 -0400 X-MC-Unique: nBgHwHz4N2iQtQ_cZCqREw-1 X-Mimecast-MFC-AGG-ID: nBgHwHz4N2iQtQ_cZCqREw_1784856926 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 7B430183130F; Fri, 24 Jul 2026 01:35:26 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 04A5C180059A; Fri, 24 Jul 2026 01:35:22 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 12/14] treewide: introduce arch_has_pmd_leaves() Date: Thu, 23 Jul 2026 21:34:16 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Now that all the has_transparent_hugepage() callers have been converted to pgtable_has_pmd_leaves(), this commit does two things: 1. Rename has_transparent_hugepage() arch implementations to arch_has_pmd_leaves(), since that's what the helper checks for 2. Introduce the default implementation of arch_has_pmd_leaves() as IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE). This means that if the arch doesn't implement arch_has_pmd_leaves() we default to checking CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE as a way to determine if PMD-sized pages are supported Note that arch_has_pmd_leaves() is supposed to be called only by init_arch_has_pmd_leaves(). The remaining exception is hugepage_init() which will be converted in a future commit. Signed-off-by: Luiz Capitulino --- arch/mips/include/asm/pgtable.h | 4 ++-- arch/mips/mm/tlb-r4k.c | 4 ++-- arch/powerpc/include/asm/book3s/64/hash-4k.h | 2 +- arch/powerpc/include/asm/book3s/64/hash-64k.h | 2 +- arch/powerpc/include/asm/book3s/64/pgtable.h | 10 +++++----- arch/powerpc/include/asm/book3s/64/radix.h | 2 +- arch/powerpc/mm/book3s64/hash_pgtable.c | 4 ++-- arch/s390/include/asm/pgtable.h | 4 ++-- arch/x86/include/asm/pgtable.h | 4 ++-- include/linux/pgtable.h | 4 ++-- mm/huge_memory.c | 2 +- mm/memory.c | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtabl= e.h index b038da872ec6..2a0a7ddf8bee 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -740,8 +740,8 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_s= truct *mm, =20 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =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 #ifdef _PAGE_HUGE #define pmd_leaf(pmd) ((pmd_val(pmd) & _PAGE_HUGE) !=3D 0) diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index f4e369342a56..9339ebb0815f 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, #endif } =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 /* * Used for loading TLB entries before trap_init() has started, when we diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h b/arch/powerpc/in= clude/asm/book3s/64/hash-4k.h index 79511e6abfca..d532e3f0dfc3 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h @@ -167,7 +167,7 @@ extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_st= ruct *mm, unsigned long addr, pmd_t *pmdp); #endif =20 -extern int hash__has_transparent_hugepage(void); +extern int hash__arch_has_pmd_leaves(void); #endif /* !__ASSEMBLER__ */ =20 #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */ diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h b/arch/powerpc/i= nclude/asm/book3s/64/hash-64k.h index a4a44a112ff9..d523c80f44f7 100644 --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h @@ -280,7 +280,7 @@ extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_st= ruct *mm, unsigned long addr, pmd_t *pmdp); #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 -extern int hash__has_transparent_hugepage(void); +extern int hash__arch_has_pmd_leaves(void); #endif /* __ASSEMBLER__ */ =20 #endif /* _ASM_POWERPC_BOOK3S_64_HASH_64K_H */ diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/in= clude/asm/book3s/64/pgtable.h index 2a795f6d9263..41166d44fa75 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1432,14 +1432,14 @@ static inline bool arch_needs_pgtable_deposit(void) =20 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =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 #define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION pte_t ptep_modify_prot_start(struct vm_area_struct *, unsigned long, pte_t= *); diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/incl= ude/asm/book3s/64/radix.h index 50545cf519bd..e8b74528953f 100644 --- a/arch/powerpc/include/asm/book3s/64/radix.h +++ b/arch/powerpc/include/asm/book3s/64/radix.h @@ -307,7 +307,7 @@ static inline int radix__has_transparent_pud_hugepage(v= oid) } #endif =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 50316f3fc5d3..a67bc1723404 100644 --- a/arch/powerpc/mm/book3s64/hash_pgtable.c +++ b/arch/powerpc/mm/book3s64/hash_pgtable.c @@ -393,7 +393,7 @@ pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *m= m, =20 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =20 -int hash__has_transparent_hugepage(void) +int hash__arch_has_pmd_leaves(void) { =20 if (!mmu_has_feature(MMU_FTR_16M_PAGE)) @@ -422,7 +422,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 #ifdef CONFIG_STRICT_KERNEL_RWX =20 diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtabl= e.h index 5aa8f621df04..24ee90c7e9bf 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1827,8 +1827,8 @@ static inline int pmd_trans_huge(pmd_t pmd) } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =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 3c62b33147fa..3c6a641e6c21 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -331,8 +331,8 @@ static inline pud_t pud_mkspecial(pud_t pud) #endif /* CONFIG_ARCH_SUPPORTS_PUD_PFNMAP */ #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ =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 4c00cf53e183..d571d161a84b 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -2344,8 +2344,8 @@ static inline void __init pgtable_leaf_support_init(v= oid) { } #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_HAVE_ARCH_TRANSPARENT_HUGE= PAGE) #endif =20 #ifndef has_transparent_pud_hugepage diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 04e8a6b55343..3f3a929e3069 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1010,7 +1010,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 d6540d6d4ef9..b0d3a8a8a25d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -169,7 +169,7 @@ EXPORT_SYMBOL(__arch_has_pmd_leaves_key); =20 void __init pgtable_leaf_support_init(void) { - if (!has_transparent_hugepage()) + if (!arch_has_pmd_leaves()) static_branch_disable(&__arch_has_pmd_leaves_key); } =20 --=20 2.55.0 From nobody Fri Jul 24 04:41:26 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 45F9A45039 for ; Fri, 24 Jul 2026 01:35:37 +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=1784856941; cv=none; b=kEaR5zNVQfbGPta6oKEqab0cwUC5xg9Y8F/loQ5hhUVpPIdxwD/wZNGGB8z/opA1x+9i1s1G4ZISEXNauTyVVjerSQApT5rZknOQeGXVI9VtdIRPbIPCO3zmAHuMReUEiPjglDTCGj4xf6LHSvkxhUzwMoPtmgn5dC4x6Rn/aRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856941; c=relaxed/simple; bh=UaXQeE2gpDb4ShTJDYhpT0hbKOofFmdA44JO5fKU9ok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ixZgqzbhMjB6yC4nKIN56veBB/R5HY8ID7aQY51gjbqexf/VvwrusMgi8M4DmXle4LEmOawWXynI9Zr2hdR/34BZEONnkl+zHIOR4Cl3Y8Dve3jTAX82/NXi2l8LYNtKJZexjglpWAmhea8qT5nrWrywJAKn3W28X/GbVyEG8bk= 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=ZUTDGrgD; 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="ZUTDGrgD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856937; 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=Sgmo3dkmrTaTr7yC380bEBxgt/VymQg2/lczzNEznUk=; b=ZUTDGrgDKxEZAvGBzONFb8dEs6hA6G+yO/P1C4tovXyZ9FUkYAwBUjYignaSWH6v4FS0Ju 1TkSJaMy0bOOhiMXP+f3jKiYc4wft81D651tuwfoDYU61Zg8C/uY0ohjLGAR+Avl+sF36j /ZMPBCwFjMKR0v3IF4NFnfkT1YT9CAo= 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-67-FbnTqJmhPTm4qCYxQYmUMA-1; Thu, 23 Jul 2026 21:35:33 -0400 X-MC-Unique: FbnTqJmhPTm4qCYxQYmUMA-1 X-Mimecast-MFC-AGG-ID: FbnTqJmhPTm4qCYxQYmUMA_1784856930 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 33C89183031E; Fri, 24 Jul 2026 01:35:30 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AF4BB180059A; Fri, 24 Jul 2026 01:35:26 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 13/14] mm: replace thp_disabled_by_hw() with pgtable_has_pmd_leaves() Date: Thu, 23 Jul 2026 21:34:17 -0400 Message-ID: <45fa16fa399243b20c90196a7d9ba217cc29d399.1784856856.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Despite its name, thp_disabled_by_hw() just checks whether the architecture supports PMD-sized pages. It returns true when TRANSPARENT_HUGEPAGE_UNSUPPORTED is set in transparent_hugepage_flags, this only occurs if the architecture implements arch_has_pmd_leaves() and that function returns false. Since pgtable_has_pmd_leaves() provides the same semantics, use it instead. Reviewed-by: Lance Yang Reviewed-by: Baolin Wang Acked-by: Zi Yan Acked-by: David Hildenbrand (Arm) 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 c745f7ad2298..525acea2eb59 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, @@ -383,12 +382,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_vmaflags(struct file *filp, unsigned l= ong addr, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3f3a929e3069..78dd16513a11 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -136,7 +136,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. */ @@ -1010,10 +1010,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 b0d3a8a8a25d..f39d9383494e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5576,7 +5576,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 68ae606b5c4c..4d2e1b91ec26 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1832,7 +1832,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.55.0 From nobody Fri Jul 24 04:41:26 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 838DE2741B6 for ; Fri, 24 Jul 2026 01:35:44 +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=1784856946; cv=none; b=qbGKtuPkh+/Al5y01hzrO1214OrKkU9UNi/R7ebkMnm+mSI7RNxb/keVeIG5OpdO6aIfKdQx/iHr4xuDcw2eaGBX3n3SANxUZ0P3wohuxuZpPdNscqKR2sk9g650bkHhoN+ji7P3djpX36veQbMdZJo4/SUH+kfHLs6DgbdFzPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784856946; c=relaxed/simple; bh=SzlEPn3zXXD/0uUd8oDs22F/ZYp8Zi34wwK0cbg9xpU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tmYP/sjjRMvqQ4idVl545hhCPz1dPpbv0Yp80Dd+9ybxs0RonV6bDqWQu6pF3ZBq3Bb+/8oFAeiYKOkcjihbnAxC930hjMJQL/nLAPl1QCRctIXAh5yMWns28S+ORpWjKAijGcAzvfa6F217hwUK3gw1mWdlYyYDQk82dYiOJ4c= 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=Omr7iMeu; 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="Omr7iMeu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784856943; 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=8NGeKqua+tRU3jPUjhDe7h+RXR8SmOKilK5RCupyqUY=; b=Omr7iMeuoHN80ivSgzuIY63MDLLlGDu1ljRvNxQBqF8SLflOtRoiXKS6NGzbda5jd73LgT 5anL/+JhoR6klPAoAMGJAkq3guNXkSsjQP8NKVryYZ/WGJK34GWtGdTbYuFiq5lcn+MCw0 3QHrybUhG4igtQmQzGR9WkteM8MivAc= 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-317-1-f-MQAMNVqJKz5xu6vCGw-1; Thu, 23 Jul 2026 21:35:37 -0400 X-MC-Unique: 1-f-MQAMNVqJKz5xu6vCGw-1 X-Mimecast-MFC-AGG-ID: 1-f-MQAMNVqJKz5xu6vCGw_1784856934 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E1B051944EB2; Fri, 24 Jul 2026 01:35:33 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.238]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 672B6180059A; Fri, 24 Jul 2026 01:35:30 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, lance.yang@linux.dev Cc: corbet@lwn.net, tsbogend@alpha.franken.de, maddy@linux.ibm.com, mpe@ellerman.id.au, agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, ira.weiny@intel.com, hughd@google.com, dave.hansen@linux.intel.com, djbw@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com, akpm@linux-foundation.org, yintirui@huawei.com, ljs@kernel.org, dev.jain@arm.com Subject: [PATCH v6 14/14] mm: thp: always enable mTHP support Date: Thu, 23 Jul 2026 21:34:18 -0400 Message-ID: <1a11c6075971d7321bb115ea16a2ec2e0cdfadc0.1784856856.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 - Filter out PMD and PUD orders from allowable orders when PMD-sized pages are not supported by the CPU Reviewed-by: Baolin Wang Signed-off-by: Luiz Capitulino --- mm/huge_memory.c | 25 ++++++++++++++++++++----- mm/shmem.c | 14 +++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 78dd16513a11..385a305e7af6 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -129,6 +129,15 @@ unsigned long __thp_vma_allowable_orders(struct vm_are= a_struct *vma, else supported_orders =3D THP_ORDERS_ALL_FILE_DEFAULT; =20 + if (!pgtable_has_pmd_leaves()) { + /* + * If the CPU does not support PMD leaves, assume for + * now that it does not support PUD leaves and disable + * both folio orders. + */ + supported_orders &=3D ~(BIT(PMD_ORDER) | BIT(PUD_ORDER)); + } + orders &=3D supported_orders; if (!orders) return 0; @@ -136,7 +145,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. */ @@ -874,7 +883,7 @@ static int __init hugepage_init_sysfs(struct kobject **= hugepage_kobj) * disable all other sizes. powerpc's PMD_ORDER isn't a compile-time * constant so we have to do this here. */ - if (!anon_orders_configured) + if (!anon_orders_configured && pgtable_has_pmd_leaves()) huge_anon_orders_inherit =3D BIT(PMD_ORDER); =20 *hugepage_kobj =3D kobject_create_and_add("transparent_hugepage", mm_kobj= ); @@ -896,6 +905,15 @@ 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()) { + /* + * If the CPU does not support PMD leaves, assume for + * now that it does not support PUD leaves and disable + * both folio orders. + */ + orders &=3D ~(BIT(PMD_ORDER) | BIT(PUD_ORDER)); + } + order =3D highest_order(orders); while (orders) { thpsize =3D thpsize_create(order, *hugepage_kobj); @@ -1010,9 +1028,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 4d2e1b91ec26..008df558af23 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1830,16 +1830,19 @@ unsigned long shmem_allowable_huge_orders(struct in= ode *inode, unsigned long mask =3D READ_ONCE(huge_shmem_orders_always); unsigned long within_size_orders =3D READ_ONCE(huge_shmem_orders_within_s= ize); vm_flags_t vm_flags =3D vma ? vma->vm_flags : 0; - unsigned int global_orders; + unsigned int global_orders, disabled_orders =3D 0; =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 + if (!pgtable_has_pmd_leaves()) + disabled_orders =3D BIT(PMD_ORDER); + global_orders =3D shmem_huge_global_enabled(inode, index, write_end, shmem_huge_force, vma, vm_flags); /* Tmpfs huge pages allocation */ if (!vma || !vma_is_anon_shmem(vma)) - return global_orders; + return global_orders & ~disabled_orders; =20 /* * Following the 'deny' semantics of the top level, force the huge @@ -1853,7 +1856,7 @@ unsigned long shmem_allowable_huge_orders(struct inod= e *inode, * means non-PMD sized THP can not override 'huge' mount option now. */ if (shmem_huge =3D=3D SHMEM_HUGE_FORCE) - return READ_ONCE(huge_shmem_orders_inherit); + return READ_ONCE(huge_shmem_orders_inherit) & ~disabled_orders; =20 /* Allow mTHP that will be fully within i_size. */ mask |=3D shmem_get_orders_within_size(inode, within_size_orders, index, = 0); @@ -1864,6 +1867,7 @@ unsigned long shmem_allowable_huge_orders(struct inod= e *inode, if (global_orders > 0) mask |=3D READ_ONCE(huge_shmem_orders_inherit); =20 + mask &=3D ~disabled_orders; return THP_ORDERS_ALL_FILE_DEFAULT & mask; } =20 @@ -5395,7 +5399,7 @@ void __init shmem_init(void) * Default to setting PMD-sized THP to inherit the global setting and * disable all other multi-size THPs. */ - if (!shmem_orders_configured) + if (!shmem_orders_configured && pgtable_has_pmd_leaves()) huge_shmem_orders_inherit =3D BIT(HPAGE_PMD_ORDER); #endif return; --=20 2.55.0