From nobody Fri Dec 19 18:52:53 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96BF032E6AC for ; Mon, 15 Dec 2025 21:17:24 +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=1765833446; cv=none; b=pX8bsL7cLYCUfo64kffmh99REjgoMt8e6DnmcClJZuN0TymLIxMGv9XPyF85D/n2PdL4qWWTKs+sikhiRNJZI/WXqBjUjUHY2iThEP8fDvnlZtowmG1K5iZtbiR8ZN6uCMH3Zwe8L08X/dZX3LoayPnm5lBL5/1KFDEY5KdLOyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765833446; c=relaxed/simple; bh=iRTFqap1GbX+q9AgKYDSz9aocRsUB3w/XX2FPdmxG3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bMGVUQRUN6xhem/jnDX5dh6inqUIsPWlvVSpHODAGQ2h3F2spYNeYpvntGAsDf/o48YYFVi5UinGwu3m8G3e/ITLm5ELFn/Txl0xJn3wj7EDq7jYZ+mEdSPbuT+FqrZhmkWzSU2mkPNo1WJmiKgQ3oGcf+yzSsn6fOQlhZ51cOU= 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=Bes/lqIX; 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="Bes/lqIX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765833443; 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=L2PbOLfYPhFxdlOOiPwr4Dslly/YjHx+LvU3PsfPUTg=; b=Bes/lqIXU+fLVbCquFuDbl+bKGrIfo3iGuTHAz8HXefZq4lnkn2IkmdIrmOtqQ0C4Ij8j2 o+lEP750RYzhFIxe+cYEhpRdOV3xnzjAb9p7jfkhocp8gUJzRVlOVBOjFdjaVntR7ytG2s U25hnu8Rluy5/shWSXHqDRUZOGVCDWs= 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-119-ki4eWxA6M4yvJz2On9rXIQ-1; Mon, 15 Dec 2025 16:17:20 -0500 X-MC-Unique: ki4eWxA6M4yvJz2On9rXIQ-1 X-Mimecast-MFC-AGG-ID: ki4eWxA6M4yvJz2On9rXIQ_1765833439 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 E22DB1801212; Mon, 15 Dec 2025 21:17:18 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.180]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E4CC41956056; Mon, 15 Dec 2025 21:17:17 +0000 (UTC) From: Luiz Capitulino To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, david@kernel.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [PATCH 10/11] mm/thp: always enable mTHP support Date: Mon, 15 Dec 2025 16:16:52 -0500 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" If PMD-sized pages are not supported on an architecture (ie. the arch implements arch_has_pmd_leaves() and it returns false) then the current code disables all THP, including mTHP. This commit fixes this by allowing mTHP to be always enabled for all archs. When PMD-sized pages are not supported, its sysfs entry won't be created and their mapping will be disallowed at page-fault time. Signed-off-by: Luiz Capitulino --- mm/huge_memory.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1e5ea2e47f79..882331592928 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -115,6 +115,9 @@ unsigned long __thp_vma_allowable_orders(struct vm_area= _struct *vma, else supported_orders =3D THP_ORDERS_ALL_FILE_DEFAULT; =20 + if (!pgtable_has_pmd_leaves()) + supported_orders &=3D ~(BIT(PMD_ORDER) | BIT(PUD_ORDER)); + orders &=3D supported_orders; if (!orders) return 0; @@ -122,7 +125,7 @@ unsigned long __thp_vma_allowable_orders(struct vm_area= _struct *vma, if (!vma->vm_mm) /* vdso */ return 0; =20 - if (!pgtable_has_pmd_leaves() || vma_thp_disabled(vma, vm_flags, forced_c= ollapse)) + if (vma_thp_disabled(vma, vm_flags, forced_collapse)) return 0; =20 /* khugepaged doesn't collapse DAX vma, but page fault is fine. */ @@ -806,6 +809,9 @@ static int __init hugepage_init_sysfs(struct kobject **= hugepage_kobj) } =20 orders =3D THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE_DEFAULT; + if (!pgtable_has_pmd_leaves()) + orders &=3D ~(BIT(PMD_ORDER) | BIT(PUD_ORDER)); + order =3D highest_order(orders); while (orders) { thpsize =3D thpsize_create(order, *hugepage_kobj); @@ -905,9 +911,6 @@ static int __init hugepage_init(void) int err; struct kobject *hugepage_kobj; =20 - if (!pgtable_has_pmd_leaves()) - return -EINVAL; - /* * hugepages can't be allocated by the buddy allocator */ --=20 2.52.0