khugepaged-remove-redundant-index-check-for-pmd-folios.patch removed from -mm tree
The quilt patch titled
Subject: khugepaged: remove redundant index check for pmd-folios
has been removed from the -mm tree. Its filename was
khugepaged-remove-redundant-index-check-for-pmd-folios.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Dev Jain <[email protected]>
Subject: khugepaged: remove redundant index check for pmd-folios
Date: Fri, 27 Feb 2026 20:05:01 +0530
Claim: folio_order(folio) == HPAGE_PMD_ORDER => folio->index == start.
Proof: Both loops in hpage_collapse_scan_file and collapse_file, which iterate on the xarray, have the invariant that start <= folio->index < start + HPAGE_PMD_NR ... (i)
A folio is always naturally aligned in the pagecache, thereforefolio_order == HPAGE_PMD_ORDER => IS_ALIGNED(folio->index, HPAGE_PMD_NR) == true ... (ii)
thp_vma_allowable_order -> thp_vma_suitable_order requires that the virtual offsets in the VMA are aligned to the order,
=> IS_ALIGNED(start, HPAGE_PMD_NR) == true ... (iii)
Combining (i), (ii) and (iii), the claim is proven.
Therefore, remove this check.
While at it, simplify the comments.
---
mm/khugepaged.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
mm/khugepaged.c renamed from mm/khugepaged.c~khugepaged-remove-redundant-index-check-for-pmd-folios +4 -10
@@ -2023,9 +2023,7 @@ static enum scan_result collapse_file(st* we locked the first folio, then a THP might be there already. * This will be discovered on the first iteration. */ -if (folio_order (folio) ==HPAGE_PMD_ORDER && - folio->index == start) { -/* Maybe PMD-mapped */ +if (folio_order (folio) ==HPAGE_PMD_ORDER ) { result =SCAN_PTE_MAPPED_HUGEPAGE ; goto out_unlock; }
@@ -2353,15 +2351,11 @@ static enum scan_result hpage_collapse_scontinue ; } -if (folio_order (folio) ==HPAGE_PMD_ORDER && - folio->index == start) { -/* Maybe PMD-mapped */ +if (folio_order (folio) ==HPAGE_PMD_ORDER ) { result =SCAN_PTE_MAPPED_HUGEPAGE ;/* -* For SCAN_PTE_MAPPED_HUGEPAGE, further processing -* by the caller won't touch the page cache, and so -* it's safe to skip LRU and refcount checks before -* returning. +* PMD-sized THP implies that we can only try +* retracting the PTE table. */ folio_put (folio);break ;
_
Patches currently in -mm which might be from [email protected] are