aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6f6a575e77ad..025f8abfae2d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -295,6 +295,9 @@ struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
295static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm) 295static struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
296{ 296{
297 struct mem_cgroup *mem = NULL; 297 struct mem_cgroup *mem = NULL;
298
299 if (!mm)
300 return NULL;
298 /* 301 /*
299 * Because we have no locks, mm->owner's may be being moved to other 302 * Because we have no locks, mm->owner's may be being moved to other
300 * cgroup. We use css_tryget() here even if this looks 303 * cgroup. We use css_tryget() here even if this looks
@@ -486,10 +489,20 @@ void mem_cgroup_move_lists(struct page *page,
486int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem) 489int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem)
487{ 490{
488 int ret; 491 int ret;
492 struct mem_cgroup *curr = NULL;
489 493
490 task_lock(task); 494 task_lock(task);
491 ret = task->mm && mm_match_cgroup(task->mm, mem); 495 rcu_read_lock();
496 curr = try_get_mem_cgroup_from_mm(task->mm);
497 rcu_read_unlock();
492 task_unlock(task); 498 task_unlock(task);
499 if (!curr)
500 return 0;
501 if (curr->use_hierarchy)
502 ret = css_is_ancestor(&curr->css, &mem->css);
503 else
504 ret = (curr == mem);
505 css_put(&curr->css);
493 return ret; 506 return ret;
494} 507}
495 508
@@ -820,6 +833,19 @@ bool mem_cgroup_oom_called(struct task_struct *task)
820 rcu_read_unlock(); 833 rcu_read_unlock();
821 return ret; 834 return ret;
822} 835}
836
837static int record_last_oom_cb(struct mem_cgroup *mem, void *data)
838{
839 mem->last_oom_jiffies = jiffies;
840 return 0;
841}
842
843static void record_last_oom(struct mem_cgroup *mem)
844{
845 mem_cgroup_walk_tree(mem, NULL, record_last_oom_cb);
846}
847
848
823/* 849/*
824 * Unlike exported interface, "oom" parameter is added. if oom==true, 850 * Unlike exported interface, "oom" parameter is added. if oom==true,
825 * oom-killer can be invoked. 851 * oom-killer can be invoked.
@@ -902,7 +928,7 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
902 mutex_lock(&memcg_tasklist); 928 mutex_lock(&memcg_tasklist);
903 mem_cgroup_out_of_memory(mem_over_limit, gfp_mask); 929 mem_cgroup_out_of_memory(mem_over_limit, gfp_mask);
904 mutex_unlock(&memcg_tasklist); 930 mutex_unlock(&memcg_tasklist);
905 mem_over_limit->last_oom_jiffies = jiffies; 931 record_last_oom(mem_over_limit);
906 } 932 }
907 goto nomem; 933 goto nomem;
908 } 934 }