From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DFB4332904 for ; Thu, 6 Nov 2025 21:29:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464574; cv=none; b=De8404cm8zjt49OhQj8JBzXDFvp8VTifqZxc+hJxQsNZZ8sTUatU3mmSG1ziWOJWmIoYIyb8n52OaofklS43JhpSx/S+jrytV3A3Nt6WNQF7UFABsJouHJzVl0pEMnyLZKTznDxKvsosDdK0yaN0hhiAhbzs65Y5onBWNIgAev0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762464574; c=relaxed/simple; bh=1T2wx5QuXjfi7mAYAugKsmzVMKvg5fYYqzV1rTTj+O4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qrZU9aavY0HcnA47heIq+vRVZP1Y3NjfQEN3cX151XOAZKAPSInQR+9+W3Byyewd5wZRufs0NA31HwKtaPzLhv3E8fb3mSvIl2FhBBKG9Dps4XG8wh+fKJoV+47VN4fjaF02XmAT2epWR7BsJeoofDEX9K3DuSiXZW7aAfILRyI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=T8zF3VNl; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="T8zF3VNl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762464571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g/LNaSNalss2cwlG3Ezg158HR0y6d2DV+kb4sHUe3rY=; b=T8zF3VNlhF6KoPb4jaguI3ktVGLykAVt2ItmgBCvPX3isg+Cf0hVruJgXWtd3hO6nhiZrE fAMSq3RdwyB6R+8YKM34tKQyE5OALXx3NbfEByEQ8BjEC6RtvioknjKCy3I8/DpqaLZzjU qAXWncoAU5m4jLJvmTWFw9NOqnnl2Kk= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-R36kOmdkMjmfZ5rrC7oMwA-1; Thu, 06 Nov 2025 16:29:28 -0500 X-MC-Unique: R36kOmdkMjmfZ5rrC7oMwA-1 X-Mimecast-MFC-AGG-ID: R36kOmdkMjmfZ5rrC7oMwA_1762464567 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0208D195608F; Thu, 6 Nov 2025 21:29:27 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.65.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0C17819560A7; Thu, 6 Nov 2025 21:29:25 +0000 (UTC) From: Luiz Capitulino To: david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com Subject: [RFC 09/10] mm: thp: always enable mTHP support Date: Thu, 6 Nov 2025 16:28:56 -0500 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 If PMD-sized pages are not supported on an architecture (ie. the arch implements arch_has_pmd_leaves() and it returns false) then the current code disables all THP, including mTHP. This commit fixes this by allowing mTHP to be always enabled for all archs. When PMD-sized pages are not supported, its sysfs entry won't be created and their mapping will be disallowed at page-fault time. Signed-off-by: Luiz Capitulino --- mm/huge_memory.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0f016ea7082d..4117833c53ef 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -115,6 +115,9 @@ unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma, else supported_orders = THP_ORDERS_ALL_FILE_DEFAULT; + if (!pgtable_has_pmd_leaves()) + supported_orders &= ~BIT(PMD_ORDER); + orders &= 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; - if (!pgtable_has_pmd_leaves() || vma_thp_disabled(vma, vm_flags, forced_collapse)) + if (vma_thp_disabled(vma, vm_flags, forced_collapse)) return 0; /* khugepaged doesn't collapse DAX vma, but page fault is fine. */ @@ -805,6 +808,9 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj) } orders = THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE_DEFAULT; + if (!pgtable_has_pmd_leaves()) + orders &= ~BIT(PMD_ORDER); + order = highest_order(orders); while (orders) { thpsize = thpsize_create(order, *hugepage_kobj); @@ -904,9 +910,6 @@ static int __init hugepage_init(void) int err; struct kobject *hugepage_kobj; - if (!pgtable_has_pmd_leaves()) - return -EINVAL; - /* * hugepages can't be allocated by the buddy allocator */ -- 2.51.1