Re: [PATCH mm-new v3 3/3] mm/khugepaged: merge PTE scanning logic into a new helper
From: Lance Yang
Date: Fri Oct 10 2025 - 06:42:31 EST
On 2025/10/10 17:10, Dev Jain wrote:
On 08/10/25 10:07 am, Lance Yang wrote:
}
}
+/*
+ * thp_collapse_check_pte - Check if a PTE is suitable for THP collapse
+ * @pte: The PTE to check
+ * @vma: The VMA the PTE belongs to
+ * @addr: The virtual address corresponding to this PTE
+ * @foliop: On success, used to return a pointer to the folio
+ * Must be non-NULL
+ * @none_or_zero: Counter for none/zero PTEs. Must be non-NULL
+ * @unmapped: Counter for swap PTEs. Can be NULL if not scanning swaps
+ * @shared: Counter for shared pages. Must be non-NULL
+ * @scan_result: Used to return the failure reason (SCAN_*) on a
+ * PTE_CHECK_FAIL return. Must be non-NULL
+ * @cc: Collapse control settings
+ *
+ * Returns:
+ * PTE_CHECK_SUCCEED - PTE is suitable, proceed with further checks
+ * PTE_CHECK_CONTINUE - Skip this PTE and continue scanning
+ * PTE_CHECK_FAIL - Abort collapse scan
+ */
+static inline int thp_collapse_check_pte(pte_t pte, struct vm_area_struct *vma,
+ unsigned long addr, struct folio **foliop, int *none_or_zero,
+ int *unmapped, int *shared, int *scan_result,
+ struct collapse_control *cc)
+{
+ struct folio *folio = NULL;
I think initialization is not needed here?Otherwise, LGTM. Reviewed-by: Dev Jain <dev.jain@xxxxxxx>
Yep. It's a minor thing, so I'll fold that in if a new version is
needed. Thanks!