Re: [PATCH] khugepaged: convert redundant check to WARN_ON
From: Lance Yang
Date: Tue Feb 24 2026 - 03:46:28 EST
On 2026/2/24 16:21, Baolin Wang wrote:
On 2/19/26 1:48 PM, Dev Jain wrote:
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, therefore
folio_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, convert this to a VM_WARN_ON.
Signed-off-by: Dev Jain <dev.jain@xxxxxxx>
---
Make sense to me. Personally, I’d like to keep this VM_WARN_ON() to catch unexpected behavior.
+1
Reviewed-by: Lance Yang <lance.yang@xxxxxxxxx>