aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/memcontrol.h7
-rw-r--r--mm/memcontrol.c10
-rw-r--r--mm/oom_kill.c9
3 files changed, 19 insertions, 7 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 4f580268b1b7..42536c737d9c 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -48,6 +48,7 @@ extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
48extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask); 48extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask);
49extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, 49extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
50 gfp_t gfp_mask); 50 gfp_t gfp_mask);
51int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
51 52
52static inline struct mem_cgroup *mm_cgroup(const struct mm_struct *mm) 53static inline struct mem_cgroup *mm_cgroup(const struct mm_struct *mm)
53{ 54{
@@ -110,6 +111,12 @@ static inline struct mem_cgroup *mm_cgroup(const struct mm_struct *mm)
110 return NULL; 111 return NULL;
111} 112}
112 113
114static inline int task_in_mem_cgroup(struct task_struct *task,
115 const struct mem_cgroup *mem)
116{
117 return 1;
118}
119
113#endif /* CONFIG_CGROUP_MEM_CONT */ 120#endif /* CONFIG_CGROUP_MEM_CONT */
114 121
115#endif /* _LINUX_MEMCONTROL_H */ 122#endif /* _LINUX_MEMCONTROL_H */
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f6cdbf755ed3..2fadd4896a14 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -170,6 +170,16 @@ static void __mem_cgroup_move_lists(struct page_cgroup *pc, bool active)
170 list_move(&pc->lru, &pc->mem_cgroup->inactive_list); 170 list_move(&pc->lru, &pc->mem_cgroup->inactive_list);
171} 171}
172 172
173int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem)
174{
175 int ret;
176
177 task_lock(task);
178 ret = task->mm && mm_cgroup(task->mm) == mem;
179 task_unlock(task);
180 return ret;
181}
182
173/* 183/*
174 * This routine assumes that the appropriate zone's lru lock is already held 184 * This routine assumes that the appropriate zone's lru lock is already held
175 */ 185 */
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 64751dc9d997..ef5084dbc793 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -65,13 +65,6 @@ unsigned long badness(struct task_struct *p, unsigned long uptime,
65 return 0; 65 return 0;
66 } 66 }
67 67
68#ifdef CONFIG_CGROUP_MEM_CONT
69 if (mem != NULL && mm->mem_cgroup != mem) {
70 task_unlock(p);
71 return 0;
72 }
73#endif
74
75 /* 68 /*
76 * The memory size of the process is the basis for the badness. 69 * The memory size of the process is the basis for the badness.
77 */ 70 */
@@ -223,6 +216,8 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
223 /* skip the init task */ 216 /* skip the init task */
224 if (is_global_init(p)) 217 if (is_global_init(p))
225 continue; 218 continue;
219 if (mem && !task_in_mem_cgroup(p, mem))
220 continue;
226 221
227 /* 222 /*
228 * This task already has access to memory reserves and is 223 * This task already has access to memory reserves and is