diff options
author | David Rientjes <rientjes@google.com> | 2010-08-09 20:18:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-09 23:44:57 -0400 |
commit | b940fd703572f7f9e5f894c682c91c3cbd84c11e (patch) | |
tree | cbb1f23073373ba1c425762f38f6f0bf9decf278 | |
parent | 8e4228e1edb922afa83366803a1e5b3fa8e987c2 (diff) |
oom: remove unnecessary code and cleanup
Remove the redundancy in __oom_kill_task() since:
- init can never be passed to this function: it will never be PF_EXITING
or selectable from select_bad_process(), and
- it will never be passed a task from oom_kill_task() without an ->mm
and we're unconcerned about detachment from exiting tasks, there's no
reason to protect them against SIGKILL or access to memory reserves.
Also moves the kernel log message to a higher level since the verbosity is
not always emitted here; we need not print an error message if an exiting
task is given a longer timeslice.
__oom_kill_task() only has a single caller, so it can be merged into that
function at the same time.
Signed-off-by: David Rientjes <rientjes@google.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: 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>
-rw-r--r-- | mm/oom_kill.c | 56 |
1 files changed, 10 insertions, 46 deletions
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index dad13fc41f47..2f37f6113d9e 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
@@ -410,61 +410,25 @@ static void dump_header(struct task_struct *p, gfp_t gfp_mask, int order, | |||
410 | } | 410 | } |
411 | 411 | ||
412 | #define K(x) ((x) << (PAGE_SHIFT-10)) | 412 | #define K(x) ((x) << (PAGE_SHIFT-10)) |
413 | 413 | static int oom_kill_task(struct task_struct *p) | |
414 | /* | ||
415 | * Send SIGKILL to the selected process irrespective of CAP_SYS_RAW_IO | ||
416 | * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO | ||
417 | * set. | ||
418 | */ | ||
419 | static void __oom_kill_task(struct task_struct *p, int verbose) | ||
420 | { | 414 | { |
421 | if (is_global_init(p)) { | ||
422 | WARN_ON(1); | ||
423 | printk(KERN_WARNING "tried to kill init!\n"); | ||
424 | return; | ||
425 | } | ||
426 | |||
427 | p = find_lock_task_mm(p); | 415 | p = find_lock_task_mm(p); |
428 | if (!p) | 416 | if (!p || p->signal->oom_adj == OOM_DISABLE) { |
429 | return; | 417 | task_unlock(p); |
430 | 418 | return 1; | |
431 | if (verbose) | 419 | } |
432 | printk(KERN_ERR "Killed process %d (%s) " | 420 | pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n", |
433 | "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n", | 421 | task_pid_nr(p), p->comm, K(p->mm->total_vm), |
434 | task_pid_nr(p), p->comm, | 422 | K(get_mm_counter(p->mm, MM_ANONPAGES)), |
435 | K(p->mm->total_vm), | 423 | K(get_mm_counter(p->mm, MM_FILEPAGES))); |
436 | K(get_mm_counter(p->mm, MM_ANONPAGES)), | ||
437 | K(get_mm_counter(p->mm, MM_FILEPAGES))); | ||
438 | task_unlock(p); | 424 | task_unlock(p); |
439 | 425 | ||
440 | /* | ||
441 | * We give our sacrificial lamb high priority and access to | ||
442 | * all the memory it needs. That way it should be able to | ||
443 | * exit() and clear out its resources quickly... | ||
444 | */ | ||
445 | p->rt.time_slice = HZ; | 426 | p->rt.time_slice = HZ; |
446 | set_tsk_thread_flag(p, TIF_MEMDIE); | 427 | set_tsk_thread_flag(p, TIF_MEMDIE); |
447 | |||
448 | force_sig(SIGKILL, p); | 428 | force_sig(SIGKILL, p); |
449 | } | ||
450 | |||
451 | static int oom_kill_task(struct task_struct *p) | ||
452 | { | ||
453 | /* WARNING: mm may not be dereferenced since we did not obtain its | ||
454 | * value from get_task_mm(p). This is OK since all we need to do is | ||
455 | * compare mm to q->mm below. | ||
456 | * | ||
457 | * Furthermore, even if mm contains a non-NULL value, p->mm may | ||
458 | * change to NULL at any time since we do not hold task_lock(p). | ||
459 | * However, this is of no concern to us. | ||
460 | */ | ||
461 | if (!p->mm || p->signal->oom_adj == OOM_DISABLE) | ||
462 | return 1; | ||
463 | |||
464 | __oom_kill_task(p, 1); | ||
465 | |||
466 | return 0; | 429 | return 0; |
467 | } | 430 | } |
431 | #undef K | ||
468 | 432 | ||
469 | static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, | 433 | static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, |
470 | unsigned long points, struct mem_cgroup *mem, | 434 | unsigned long points, struct mem_cgroup *mem, |