[RHEL7,COMMIT] mm/memcg: Fix potential softlockup during memcgroup shutdown.

Submitted by Konstantin Khorenko on Oct. 30, 2017, 2:44 p.m.

Details

Message ID 201710301444.v9UEip2j015971@finist_ce7.work
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Oct. 30, 2017, 2:44 p.m.
The commit is pushed to "branch-rh7-3.10.0-693.1.1.vz7.37.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.1.1.vz7.37.20
------>
commit 9bd767bbdd723732317571ec69ea08f13cefea43
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Mon Oct 30 17:44:51 2017 +0300

    mm/memcg: Fix potential softlockup during memcgroup shutdown.
    
    On a huge mem cgroup mem_cgroup_force_empty_list() may iterate
    for a long time without rescheduling and cause softlockup.
    Add cond_resched() to avoid this.
    
    https://jira.sw.ru/browse/PSBM-76011
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/memcontrol.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index efc455d..a7fa84a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4038,8 +4038,10 @@  static void mem_cgroup_force_empty_list(struct mem_cgroup *memcg,
 			/* found lock contention or "pc" is obsolete. */
 			busy = page;
 			schedule_timeout_uninterruptible(1);
-		} else
+		} else {
 			busy = NULL;
+			cond_resched();
+		}
 	} while (!list_empty(list));
 }