Re: [PATCH] mm: huge_memory: add folio_mark_accessed() when zapping file THP
From: Oscar Salvador
Date: Thu Apr 10 2025 - 04:46:09 EST
On Wed, Apr 09, 2025 at 05:38:58PM +0800, Baolin Wang wrote:
> When investigating performance issues during file folio unmap, I noticed some
> behavioral differences in handling non-PMD-sized folios and PMD-sized folios.
> For non-PMD-sized file folios, it will call folio_mark_accessed() to mark the
> folio as having seen activity, but this is not done for PMD-sized folios.
>
> This might not cause obvious issues, but a potential problem could be that,
> it might lead to reclaim hot file folios under memory pressure, as quoted
> from Johannes:
>
> "
> Sometimes file contents are only accessed through relatively short-lived
> mappings. But they can nevertheless be accessed a lot and be hot. It's
> important to not lose that information on unmap, and end up kicking out a
> frequently used cache page.
> "
>
> Therefore, we should also add folio_mark_accessed() for PMD-sized file
> folios when unmapping.
>
> Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>
> Acked-by: Zi Yan <ziy@xxxxxxxxxx>
Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>
Although I agree with David here that pmd_present would be more obvious than
flush_needed.
It was not obvious to be at first glance.
--
Oscar Salvador
SUSE Labs