From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C27A9224B04 for ; Sat, 6 Jun 2026 00:39:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780706390; cv=none; b=ZTDpUTe0xLQ4yoNeZfWhdOUoxe6Jw1SAMsmltZQjwNzbXLRmvmkfSrl65JDyAyrK/PK6ZXEnBXwGuHvPrv9mysLH9tQfL9bwViOZcXiqowrtT0sMpz8ky0CC1SueRY8Wj/JHJBUyHXqlC88DFa/p4UTMcDClNNgjEBjJLyGE1XA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780706390; c=relaxed/simple; bh=ODISNZMftRLi28ZeLGBDClzU/HweDRYGKn15K86UN8Y=; h=Date:To:From:Subject:Message-Id; b=cDpsAQQWUKsiKgdHaKF3tscwkIwX27/7yXXUHbZj7r8STAaYYw+bsJey9kz4JNd9oPXlPr30SCpoZY4vc+GP5Yg8fO0SUBe48dEXIWNWEqn2mJicGlqEtQWuj/8KaXETjQQ3HvdGcqmnTzPZADGglSaiUtqgTvMSxZmkip3X30Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=ngBE2SUX; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="ngBE2SUX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D6FD1F00893; Sat, 6 Jun 2026 00:39:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1780706386; bh=Lt2emMwsazXR4nJC+f6IUBe4+bB2U9E94H6GzTfzT9I=; h=Date:To:From:Subject; b=ngBE2SUXZ4iJvFdfljEsGzgCf8XkeSGLT+5H/5ZuQtIqHNB3KrSv6UKcVD50jnUSj wAIh4hCdrYhHBfMARhtApnvgs7iFnZYwQelJyEbWl3dsRRuIpQED8y0rtKE+f2NCRt v0RaGLWn04vlDf+LSTEIUN1hKzMA1Veyf/Z2G57c= Date: Fri, 05 Jun 2026 17:39:45 -0700 To: mm-commits@vger.kernel.org,npache@redhat.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-khugepaged-skip-collapsing-mthp-to-smaller-orders.patch added to mm-unstable branch Message-Id: <20260606003946.5D6FD1F00893@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/khugepaged: skip collapsing mTHP to smaller orders has been added to the -mm mm-unstable branch. Its filename is mm-khugepaged-skip-collapsing-mthp-to-smaller-orders.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-khugepaged-skip-collapsing-mthp-to-smaller-orders.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Nico Pache Subject: mm/khugepaged: skip collapsing mTHP to smaller orders Date: Fri, 5 Jun 2026 10:14:14 -0600 khugepaged may try to collapse a mTHP to a folio of equal or smaller size, possibly resulting in a partially mapped source folio, which is undesired. Skip these cases until we have a way to check if its ok to collapse to a smaller mTHP size (like in the case of a partially mapped folio). This check is not done during the scan phase as the current collapse order is unknown at that time. This patch is inspired by Dev Jain's work on khugepaged mTHP support [1]. Link: https://lore.kernel.org/20260605161422.213817-8-npache@redhat.com Link: https://lore.kernel.org/lkml/20241216165105.56185-11-dev.jain@arm.com/ [1] Co-developed-by: Dev Jain Signed-off-by: Dev Jain Signed-off-by: Nico Pache Reviewed-by: Lorenzo Stoakes Reviewed-by: Baolin Wang Acked-by: David Hildenbrand (arm) Acked-by: Usama Arif Cc: Alistair Popple Cc: Andrea Arcangeli Cc: Anshuman Khandual Cc: Bagas Sanjaya Cc: Barry Song Cc: Brendan Jackman Cc: Byungchul Park Cc: Catalin Marinas Cc: David Rientjes Cc: Gregory Price Cc: "Huang, Ying" Cc: Hugh Dickins Cc: Jan Kara Cc: Jann Horn Cc: Johannes Weiner Cc: Jonathan Corbet Cc: Joshua Hahn Cc: Kefeng Wang Cc: Lance Yang Cc: Liam R. Howlett Cc: "Masami Hiramatsu (Google)" Cc: Mathieu Desnoyers Cc: Matthew Brost Cc: Matthew Wilcox (Oracle) Cc: Michal Hocko Cc: Mike Rapoport Cc: Nanyong Sun Cc: Pedro Falcato Cc: Peter Xu Cc: Rafael Aquini Cc: Rakie Kim Cc: Randy Dunlap Cc: Ryan Roberts Cc: Shivank Garg Cc: Steven Rostedt Cc: Suren Baghdasaryan Cc: Takashi Iwai (SUSE) Cc: Thomas Hellström Cc: Usama Arif Cc: Vishal Moola (Oracle) Cc: Vlastimil Babka Cc: Wei Yang Cc: Will Deacon Cc: Yang Shi Cc: Zach O'Keefe Cc: Zi Yan Signed-off-by: Andrew Morton --- mm/khugepaged.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/mm/khugepaged.c~mm-khugepaged-skip-collapsing-mthp-to-smaller-orders +++ a/mm/khugepaged.c @@ -697,6 +697,14 @@ static enum scan_result __collapse_huge_ goto out; } } + /* + * TODO: In some cases of partially-mapped folios, we'd actually + * want to collapse. + */ + if (!is_pmd_order(order) && folio_order(folio) >= order) { + result = SCAN_PTE_MAPPED_HUGEPAGE; + goto out; + } if (folio_test_large(folio)) { struct folio *f; _ Patches currently in -mm which might be from npache@redhat.com are mm-khugepaged-generalize-hugepage_vma_revalidate-for-mthp-support.patch mm-khugepaged-rework-max_ptes_-handling-with-helper-functions.patch mm-khugepaged-generalize-__collapse_huge_page_-for-mthp-support.patch mm-khugepaged-require-collapse_huge_page-to-enter-exit-with-the-lock-dropped.patch mm-khugepaged-generalize-collapse_huge_page-for-mthp-collapse.patch mm-khugepaged-skip-collapsing-mthp-to-smaller-orders.patch mm-khugepaged-add-per-order-mthp-collapse-failure-statistics.patch mm-khugepaged-improve-tracepoints-for-mthp-orders.patch mm-khugepaged-introduce-collapse_possible_orders-helper-functions.patch mm-khugepaged-introduce-mthp-collapse-support.patch mm-khugepaged-avoid-unnecessary-mthp-collapse-attempts.patch documentation-mm-update-the-admin-guide-for-mthp-collapse.patch