aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorJohannes Weiner <jweiner@redhat.com>2011-08-25 18:59:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-08-25 19:25:34 -0400
commit23751be0094012eb6b4756fa80ca54b3eb83069f (patch)
tree30c33d9165bb33d64bd42d6e9bc1e4cbed1c0780 /mm
parent86383b55791bd97e88ef493e33ef521ee244f3d9 (diff)
memcg: fix hierarchical oom locking
Commit 79dfdaccd1d5 ("memcg: make oom_lock 0 and 1 based rather than counter") tried to oom lock the hierarchy and roll back upon encountering an already locked memcg. The code is confused when it comes to detecting a locked memcg, though, so it would fail and rollback after locking one memcg and encountering an unlocked second one. The result is that oom-locking hierarchies fails unconditionally and that every oom killer invocation simply goes to sleep on the oom waitqueue forever. The tasks practically hang forever without anyone intervening, possibly holding locks that trip up unrelated tasks, too. Signed-off-by: Johannes Weiner <jweiner@redhat.com> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 0e40f0205732..ebd1e86bef1c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1841,29 +1841,23 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
1841 */ 1841 */
1842static bool mem_cgroup_oom_lock(struct mem_cgroup *mem) 1842static bool mem_cgroup_oom_lock(struct mem_cgroup *mem)
1843{ 1843{
1844 int lock_count = -1;
1845 struct mem_cgroup *iter, *failed = NULL; 1844 struct mem_cgroup *iter, *failed = NULL;
1846 bool cond = true; 1845 bool cond = true;
1847 1846
1848 for_each_mem_cgroup_tree_cond(iter, mem, cond) { 1847 for_each_mem_cgroup_tree_cond(iter, mem, cond) {
1849 bool locked = iter->oom_lock; 1848 if (iter->oom_lock) {
1850
1851 iter->oom_lock = true;
1852 if (lock_count == -1)
1853 lock_count = iter->oom_lock;
1854 else if (lock_count != locked) {
1855 /* 1849 /*
1856 * this subtree of our hierarchy is already locked 1850 * this subtree of our hierarchy is already locked
1857 * so we cannot give a lock. 1851 * so we cannot give a lock.
1858 */ 1852 */
1859 lock_count = 0;
1860 failed = iter; 1853 failed = iter;
1861 cond = false; 1854 cond = false;
1862 } 1855 } else
1856 iter->oom_lock = true;
1863 } 1857 }
1864 1858
1865 if (!failed) 1859 if (!failed)
1866 goto done; 1860 return true;
1867 1861
1868 /* 1862 /*
1869 * OK, we failed to lock the whole subtree so we have to clean up 1863 * OK, we failed to lock the whole subtree so we have to clean up
@@ -1877,8 +1871,7 @@ static bool mem_cgroup_oom_lock(struct mem_cgroup *mem)
1877 } 1871 }
1878 iter->oom_lock = false; 1872 iter->oom_lock = false;
1879 } 1873 }
1880done: 1874 return false;
1881 return lock_count;
1882} 1875}
1883 1876
1884/* 1877/*