Re: + memcg-fix-deadlock-between-cpuset-and-memcg.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(resend with adding Cc: containers and linux-mm)

Hi, Andrew.

Thank you for picking up this patch.

But this version has a small race problem. This is a fix-up patch.

===
From: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx>

We must clear "mc.moving_task" before waking up all waiters at the end of
task migration.

Otherwise, there can be a small race like:

        mem_cgroup_clear_mc()        |    mem_cgroup_wait_acct_move()
    ---------------------------------+-----------------------------------
          __mem_cgroup_clear_mc()    |
            wake_up_all()            |
                                     |    prepare_to_wait()
                                     |    if (mc.moving_task) -> true
                                     |      schedule()
                                     |      -> noone wakes it up.
          mc.moving_task = NULL      |

Signed-off-by: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx>
---
 mm/memcontrol.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b108b30..61678be 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4714,12 +4714,16 @@ static void mem_cgroup_clear_mc(void)
 {
 	struct mem_cgroup *from = mc.from;
 
+	/*
+	 * we must clear moving_task before waking up waiters at the end of
+	 * task migration.
+	 */
+	mc.moving_task = NULL;
 	__mem_cgroup_clear_mc();
 	spin_lock(&mc.lock);
 	mc.from = NULL;
 	mc.to = NULL;
 	spin_unlock(&mc.lock);
-	mc.moving_task = NULL;
 	mem_cgroup_end_move(from);
 }
 
-- 
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]