Re: [PATCH V3 1/2] mm/khugepaged: map dirty/writeback pages failures to EAGAIN
From: Baolin Wang
Date: Tue Dec 02 2025 - 02:57:13 EST
On 2025/12/2 02:56, Shivank Garg wrote:
When collapse_file encounters dirty or writeback pages in file-backed
mappings, it currently returns SCAN_FAIL which maps to -EINVAL. This is
misleading as EINVAL suggests invalid arguments, whereas dirty/writeback
pages represent transient conditions that may resolve on retry.
Introduce SCAN_PAGE_DIRTY_OR_WRITEBACK to cover both dirty and writeback
states, mapping it to -EAGAIN. For MADV_COLLAPSE, this provides userspace
with a clear signal that retry may succeed after writeback completes.
For khugepaged, this is harmless as it will naturally revisit the range
during periodic scans after async writeback completes.
Reported-by: Branden Moore <Branden.Moore@xxxxxxx>
Closes: https://lore.kernel.org/all/4e26fe5e-7374-467c-a333-9dd48f85d7cc@xxxxxxx
Fixes: 34488399fa08 ("mm/madvise: add file and shmem support to MADV_COLLAPSE")
Reviewed-by: Dev Jain <dev.jain@xxxxxxx>
Reviewed-by: Lance Yang <lance.yang@xxxxxxxxx>
Signed-off-by: Shivank Garg <shivankg@xxxxxxx>
---
LGTM.
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>