diff mbox series

[RFC,v1,2/2] mm: vmscan: ignore non-LRU-based reclaim in memcg reclaim

Message ID 20230202233229.3895713-3-yosryahmed@google.com (mailing list archive)
State New
Headers show
Series Ignore non-LRU-based reclaim in memcg reclaim | expand

Commit Message

Yosry Ahmed Feb. 2, 2023, 11:32 p.m. UTC
We keep track of different types of reclaimed pages through
reclaim_state->reclaimed, and we add them to the reported number of
reclaimed pages. For non-memcg reclaim, this makes sense. For memcg
reclaim, we have no clue if those pages are charged to the memcg under
reclaim.

Slab pages are shared by different memcgs, so a freed slab page may have
only been partially charged to the memcg under reclaim. The same goes
for clean file pages from pruned inodes or xfs buffer pages, there is no
way to link them to the memcg under reclaim.

Stop reporting those freed pages as reclaimed pages during memcg
reclaim. This should make the return value of writing to memory.reclaim,
and may help reduce unnecessary reclaim retries during memcg charging.

Generally, this should make the return value of
try_to_free_mem_cgroup_pages() more accurate. In some limited cases (e.g.
freed a slab page that was mostly charged to the memcg under reclaim),
the return value of try_to_free_mem_cgroup_pages() can be
underestimated, but this should be fine as it is mostly called in a
retry loop.

Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
---
 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 63a27d2f6f31..207998b16e5f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -6181,7 +6181,7 @@  static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 
 	shrink_node_memcgs(pgdat, sc);
 
-	if (reclaim_state) {
+	if (reclaim_state && !cgroup_reclaim(sc)) {
 		sc->nr_reclaimed += reclaim_state->reclaimed;
 		reclaim_state->reclaimed = 0;
 	}