Re: [PATCH V4 1/2] mm/khugepaged: map dirty/writeback pages failures to EAGAIN
From: David Hildenbrand (Red Hat)
Date: Fri Jan 09 2026 - 09:31:40 EST
On 12/15/25 09:46, 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>
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
Reviewed-by: wang lian <lianux.mm@xxxxxxxxx>
Signed-off-by: Shivank Garg <shivankg@xxxxxxx>
Acked-by: David Hildenbrand (Red Hat) <david@xxxxxxxxxx>
--
Cheers
David