Re: [PATCH v4 3/3] mm/khugepaged: maintain page cache uptodate flag

From: Peter Xu
Date: Tue Feb 21 2023 - 17:19:15 EST


On Fri, Feb 17, 2023 at 05:54:39PM +0900, David Stevens wrote:
> From: David Stevens <stevensd@xxxxxxxxxxxx>
>
> Make sure that collapse_file doesn't interfere with checking the
> uptodate flag in the page cache by only inserting hpage into the page
> cache after it has been updated and marked uptodate. This is achieved by
> simply not replacing present pages with hpage when iterating over them
> target range. The present pages are already locked, so replacing the
> with the locked hpage before the collapse is finalized is unnecessary.
>
> This fixes a race where folio_seek_hole_data would mistake hpage for
> an fallocated but unwritten page. This race is visible to userspace via
> data temporarily disappearing from SEEK_DATA/SEEK_HOLE.
>
> Fixes: f3f0e1d2150b ("khugepaged: add support of collapse for tmpfs/shmem pages")
> Signed-off-by: David Stevens <stevensd@xxxxxxxxxxxx>

Per my knowledge, this one looks all correct too.

Acked-by: Peter Xu <peterx@xxxxxxxxxx>

So at least to me the whole set looks mostly good except patch 1 needs some
confirmation.

Thanks,

--
Peter Xu