[PATCH v8 3/6] zswap: make shrinking memcg-aware (fix)

Nhat Pham
2023-12-05T19:54:21Z

Use the correct function for the onlineness check for the memcg
selection, and use mem_cgroup_iter_break() to break the iteration.

Suggested-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Nhat Pham <nphamcs@gmail.com>
---
mm/zswap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index f323e45cbdc7..7a84c1454988 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -834,9 +834,9 @@ static void shrink_worker(struct work_struct *w)
goto resched;
}

- if (!mem_cgroup_online(memcg)) {
+ if (!mem_cgroup_tryget_online(memcg)) {
/* drop the reference from mem_cgroup_iter() */
- mem_cgroup_put(memcg);
+ mem_cgroup_iter_break(NULL, memcg);
pool->next_shrink = NULL;
spin_unlock(&zswap_pools_lock);

@@ -985,7 +985,7 @@ static void zswap_pool_destroy(struct zswap_pool *pool)
list_lru_destroy(&pool->list_lru);

spin_lock(&zswap_pools_lock);
- mem_cgroup_put(pool->next_shrink);
+ mem_cgroup_iter_break(NULL, pool->next_shrink);
pool->next_shrink = NULL;
spin_unlock(&zswap_pools_lock);

--
2.34.1