aboutsummaryrefslogtreecommitdiffstats
path: root/mm/oom_kill.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/oom_kill.c')
-rw-r--r--mm/oom_kill.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index a7b2460e922b..b60913520ef3 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -58,6 +58,7 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
58 unsigned long points, cpu_time, run_time; 58 unsigned long points, cpu_time, run_time;
59 struct mm_struct *mm; 59 struct mm_struct *mm;
60 struct task_struct *child; 60 struct task_struct *child;
61 int oom_adj;
61 62
62 task_lock(p); 63 task_lock(p);
63 mm = p->mm; 64 mm = p->mm;
@@ -65,6 +66,7 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
65 task_unlock(p); 66 task_unlock(p);
66 return 0; 67 return 0;
67 } 68 }
69 oom_adj = mm->oom_adj;
68 70
69 /* 71 /*
70 * The memory size of the process is the basis for the badness. 72 * The memory size of the process is the basis for the badness.
@@ -148,15 +150,15 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
148 points /= 8; 150 points /= 8;
149 151
150 /* 152 /*
151 * Adjust the score by oomkilladj. 153 * Adjust the score by oom_adj.
152 */ 154 */
153 if (p->oomkilladj) { 155 if (oom_adj) {
154 if (p->oomkilladj > 0) { 156 if (oom_adj > 0) {
155 if (!points) 157 if (!points)
156 points = 1; 158 points = 1;
157 points <<= p->oomkilladj; 159 points <<= oom_adj;
158 } else 160 } else
159 points >>= -(p->oomkilladj); 161 points >>= -(oom_adj);
160 } 162 }
161 163
162#ifdef DEBUG 164#ifdef DEBUG
@@ -251,8 +253,12 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
251 *ppoints = ULONG_MAX; 253 *ppoints = ULONG_MAX;
252 } 254 }
253 255
254 if (p->oomkilladj == OOM_DISABLE) 256 task_lock(p);
257 if (p->mm && p->mm->oom_adj == OOM_DISABLE) {
258 task_unlock(p);
255 continue; 259 continue;
260 }
261 task_unlock(p);
256 262
257 points = badness(p, uptime.tv_sec); 263 points = badness(p, uptime.tv_sec);
258 if (points > *ppoints || !chosen) { 264 if (points > *ppoints || !chosen) {
@@ -304,8 +310,7 @@ static void dump_tasks(const struct mem_cgroup *mem)
304 } 310 }
305 printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d %3d %s\n", 311 printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d %3d %s\n",
306 p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm, 312 p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm,
307 get_mm_rss(mm), (int)task_cpu(p), p->oomkilladj, 313 get_mm_rss(mm), (int)task_cpu(p), mm->oom_adj, p->comm);
308 p->comm);
309 task_unlock(p); 314 task_unlock(p);
310 } while_each_thread(g, p); 315 } while_each_thread(g, p);
311} 316}
@@ -367,8 +372,12 @@ static int oom_kill_task(struct task_struct *p)
367 * Don't kill the process if any threads are set to OOM_DISABLE 372 * Don't kill the process if any threads are set to OOM_DISABLE
368 */ 373 */
369 do_each_thread(g, q) { 374 do_each_thread(g, q) {
370 if (q->mm == mm && q->oomkilladj == OOM_DISABLE) 375 task_lock(q);
376 if (q->mm == mm && q->mm && q->mm->oom_adj == OOM_DISABLE) {
377 task_unlock(q);
371 return 1; 378 return 1;
379 }
380 task_unlock(q);
372 } while_each_thread(g, q); 381 } while_each_thread(g, q);
373 382
374 __oom_kill_task(p, 1); 383 __oom_kill_task(p, 1);
@@ -393,10 +402,11 @@ static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
393 struct task_struct *c; 402 struct task_struct *c;
394 403
395 if (printk_ratelimit()) { 404 if (printk_ratelimit()) {
396 printk(KERN_WARNING "%s invoked oom-killer: "
397 "gfp_mask=0x%x, order=%d, oomkilladj=%d\n",
398 current->comm, gfp_mask, order, current->oomkilladj);
399 task_lock(current); 405 task_lock(current);
406 printk(KERN_WARNING "%s invoked oom-killer: "
407 "gfp_mask=0x%x, order=%d, oom_adj=%d\n",
408 current->comm, gfp_mask, order,
409 current->mm ? current->mm->oom_adj : OOM_DISABLE);
400 cpuset_print_task_mems_allowed(current); 410 cpuset_print_task_mems_allowed(current);
401 task_unlock(current); 411 task_unlock(current);
402 dump_stack(); 412 dump_stack();