On 4/18/26 10:44 AM, Zi Yan wrote:
This check ensures the correctness of collapse read-only THPs for FSes after READ_ONLY_THP_FOR_FS is enabled by default for all FSes supporting PMD THP pagecache. READ_ONLY_THP_FOR_FS only supports read-only fd and uses mapping->nr_thps and inode->i_writecount to prevent any write to read-only to-be-collapsed folios. In upcoming commits, READ_ONLY_THP_FOR_FS will be removed and the aforementioned mechanism will go away too. To ensure khugepaged functions as expected after the changes, skip if any folio is dirty after try_to_unmap(), since a dirty folio means this read-only folio got some writes via mmap can happen between try_to_unmap() and try_to_unmap_flush() via cached TLB entries and khugepaged does not support writable pagecache folio collapse yet. Signed-off-by: Zi Yan <[email protected]> ---
LGTM. Reviewed-by: Baolin Wang <[email protected]>

