Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/volatile: __purge_volatile_folio() locks anon_vma for
large folios
--
commit 989662cf3ea960d3c700d99d524e531e7df74975
Author: Hirotaka Yamagata [off-list ref]
mm/volatile: add PGPURGE vmstat counter and purge tracepoint
This commit adds the PGPURGE vmstat and memcg event counter and the
mm_purge_volatile_folio tracepoint for volatile folio purging.
quoted hunk ↗ jump to hunk
diff --git a/mm/mvolatile.c b/mm/mvolatile.c
index c111bc4f111d4..aa532d72d81cf 100644
--- a/mm/mvolatile.c
+++ b/mm/mvolatile.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -261,9 +264,13 @@ enum purge_result __purge_volatile_folio(struct folio *folio)
if (!mapped)
return PURGE_NONE;
- /* Only order-0 folios are supported for now. */
+ /*
+ * Only order-0 folios are supported for now. Checked after the
+ * volatile test so that the tracepoint shows large volatile folios
+ * falling back to swap.
+ */
if (folio_test_large(folio))
- return PURGE_NONE;
+ goto fail;
[Severity: Medium]
Does checking folio_test_large() after folio_lock_anon_vma_read() and the
anon_rmap_tree_foreach() walk cause unnecessary anon_vma lock contention on
every mapped large anonymous folio during page reclaim when the tracepoint
is disabled?
Once volatile_ranges_key is enabled, shrink_folio_list() calls
__purge_volatile_folio() on every folio it scans. When
mm_purge_volatile_folio is disabled, the fail label just returns
PURGE_NONE, so checking folio_test_large(folio) &&
!trace_mm_purge_volatile_folio_enabled() before folio_lock_anon_vma_read()
would avoid locking anon_vma and walking the rmap tree for large folios.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130083407.2669584-1-hiro@pisnp.net?part=4