[Devel] [PATCH RHEL9 COMMIT] mm/vmscan: add cond_resched() to loop in shrink_slab_memcg()

Konstantin Khorenko khorenko at virtuozzo.com
Wed Oct 20 11:40:46 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.12
------>
commit 1cf24e694c8f176cab31e05f7a2e8a9ed8e9c380
Author: Andrey Ryabinin <ryabinin.a.a at gmail.com>
Date:   Wed Oct 20 11:40:46 2021 +0300

    mm/vmscan: add cond_resched() to loop in shrink_slab_memcg()
    
    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 dfc094cafb9b..26e12dff98f7 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)


More information about the Devel mailing list