[Devel] [PATCH RH9 21/28] mm/vmscan: add cond_resched() to loop in shrink_slab_memcg()

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Thu Oct 14 13:33:29 MSK 2021


From: Andrey Ryabinin <aryabinin at virtuozzo.com>

shrink_slab_memcg() may iterate for a long time without resched if we
have many memcg with small amount of objects. Add cond_resched() to
avoid potential softlockup.

https://jira.sw.ru/browse/PSBM-125095

Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>

(cherry picked from vz7 commit c2ccf83304f1 ("mm/vmscan: add cond_resched() to
loop in shrink_slab_memcg()"))

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>

(cherry picked from vz8 commit 5af0061feb0f264d1ad23580f5febe0bd10a154d)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 mm/vmscan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index dfc094c..26e12df 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -766,6 +766,8 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
 		};
 		struct shrinker *shrinker;
 
+		cond_resched();
+
 		shrinker = idr_find(&shrinker_idr, i);
 		if (unlikely(!shrinker || !(shrinker->flags & SHRINKER_REGISTERED))) {
 			if (!shrinker)
-- 
1.8.3.1



More information about the Devel mailing list