[Devel] [PATCH RHEL7 COMMIT] memcg: change oom_info_lock to mutex

Vladimir Davydov vdavydov at virtuozzo.com
Tue Sep 8 08:31:01 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.6.8
------>
commit 8b9f4ff2b3634b2fbdaa2c70d5f92b89861a43fd
Author: Michal Hocko <mhocko at suse.cz>
Date:   Tue Sep 8 19:31:01 2015 +0400

    memcg: change oom_info_lock to mutex
    
    Kirill has reported the following:
    
      Task in /test killed as a result of limit of /test
      memory: usage 10240kB, limit 10240kB, failcnt 51
      memory+swap: usage 10240kB, limit 10240kB, failcnt 0
      kmem: usage 0kB, limit 18014398509481983kB, failcnt 0
      Memory cgroup stats for /test:
    
      BUG: sleeping function called from invalid context at kernel/cpu.c:68
      in_atomic(): 1, irqs_disabled(): 0, pid: 66, name: memcg_test
      2 locks held by memcg_test/66:
       #0:  (memcg_oom_lock#2){+.+...}, at: [<ffffffff81131014>] pagefault_out_of_memory+0x14/0x90
       #1:  (oom_info_lock){+.+...}, at: [<ffffffff81197b2a>] mem_cgroup_print_oom_info+0x2a/0x390
      CPU: 2 PID: 66 Comm: memcg_test Not tainted 3.14.0-rc1-dirty #745
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Bochs 01/01/2011
      Call Trace:
        __might_sleep+0x16a/0x210
        get_online_cpus+0x1c/0x60
        mem_cgroup_read_stat+0x27/0xb0
        mem_cgroup_print_oom_info+0x260/0x390
        dump_header+0x88/0x251
        ? trace_hardirqs_on+0xd/0x10
        oom_kill_process+0x258/0x3d0
        mem_cgroup_oom_synchronize+0x656/0x6c0
        ? mem_cgroup_charge_common+0xd0/0xd0
        pagefault_out_of_memory+0x14/0x90
        mm_fault_error+0x91/0x189
        __do_page_fault+0x48e/0x580
        do_page_fault+0xe/0x10
        page_fault+0x22/0x30
    
    which complains that mem_cgroup_read_stat cannot be called from an atomic
    context but mem_cgroup_print_oom_info takes a spinlock.  Change
    oom_info_lock to a mutex.
    
    This was introduced by 947b3dd1a84b ("memcg, oom: lock
    mem_cgroup_print_oom_info").
    
    Signed-off-by: Michal Hocko <mhocko at suse.cz>
    Reported-by: "Kirill A. Shutemov" <kirill.shutemov at linux.intel.com>
    Cc: Johannes Weiner <hannes at cmpxchg.org>
    Cc: David Rientjes <rientjes at google.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    (cherry picked from commit 08088cb9ac0a9c28d4cf3efa4f6848a9b053ccfd)
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 mm/memcontrol.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 54bad06b0200..0c617c32d7fa 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1823,7 +1823,7 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
 	 * protects memcg_name and makes sure that parallel ooms do not
 	 * interleave
 	 */
-	static DEFINE_SPINLOCK(oom_info_lock);
+	static DEFINE_MUTEX(oom_info_lock);
 	struct cgroup *task_cgrp;
 	struct cgroup *mem_cgrp;
 	static char memcg_name[PATH_MAX];
@@ -1834,7 +1834,7 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
 	if (!p)
 		return;
 
-	spin_lock(&oom_info_lock);
+	mutex_lock(&oom_info_lock);
 	rcu_read_lock();
 
 	mem_cgrp = memcg->css.cgroup;
@@ -1903,7 +1903,7 @@ done:
 
 		pr_cont("\n");
 	}
-	spin_unlock(&oom_info_lock);
+	mutex_unlock(&oom_info_lock);
 }
 
 /*



More information about the Devel mailing list