From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932139Ab1FVKt4 (ORCPT ); Wed, 22 Jun 2011 06:49:56 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:59214 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755246Ab1FVKtz (ORCPT ); Wed, 22 Jun 2011 06:49:55 -0400 X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Message-ID: <4E01C8C3.8040307@jp.fujitsu.com> Date: Wed, 22 Jun 2011 19:49:39 +0900 From: KOSAKI Motohiro User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: kosaki.motohiro@jp.fujitsu.com CC: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, caiqian@redhat.com, rientjes@google.com, hughd@google.com, kamezawa.hiroyu@jp.fujitsu.com, minchan.kim@gmail.com, oleg@redhat.com Subject: [PATCH 6/6] oom: merge oom_kill_process() with oom_kill_task() References: <4E01C7D5.3060603@jp.fujitsu.com> In-Reply-To: <4E01C7D5.3060603@jp.fujitsu.com> Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now, oom_kill_process() become almost empty function. Let's merge it with oom_kill_task(). Also, this patch replace task_pid_nr() with task_tgid_nr(). Because 1) oom killer kill a process, not thread. 2) a userland don't care thread id. Signed-off-by: KOSAKI Motohiro --- mm/oom_kill.c | 53 ++++++++++++++++++++++------------------------------- 1 files changed, 22 insertions(+), 31 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index cf48fd5..2fdbb96 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -470,11 +470,26 @@ static void dump_header(struct task_struct *p, gfp_t gfp_mask, int order, } #define K(x) ((x) << (PAGE_SHIFT-10)) -static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem) +static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, + unsigned long points, unsigned long totalpages, + struct mem_cgroup *mem, nodemask_t *nodemask, + const char *message) { struct task_struct *q; struct mm_struct *mm; + if (printk_ratelimit()) + dump_header(p, gfp_mask, order, mem, nodemask); + + /* + * If the task is already exiting, don't alarm the sysadmin or kill + * its children or threads, just set TIF_MEMDIE so it can die quickly + */ + if (p->flags & PF_EXITING) { + set_tsk_thread_flag(p, TIF_MEMDIE); + return 0; + } + p = find_lock_task_mm(p); if (!p) return 1; @@ -482,10 +497,11 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem) /* mm cannot be safely dereferenced after task_unlock(p) */ mm = p->mm; - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n", - task_pid_nr(p), p->comm, K(p->mm->total_vm), - K(get_mm_counter(p->mm, MM_ANONPAGES)), - K(get_mm_counter(p->mm, MM_FILEPAGES))); + pr_err("%s: Kill process %d (%s) points:%lu total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n", + message, task_tgid_nr(p), p->comm, points, + K(p->mm->total_vm), + K(get_mm_counter(p->mm, MM_ANONPAGES)), + K(get_mm_counter(p->mm, MM_FILEPAGES))); task_unlock(p); /* @@ -502,7 +518,7 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem) if (q->mm == mm && !same_thread_group(q, p)) { task_lock(q); /* Protect ->comm from prctl() */ pr_err("Kill process %d (%s) sharing same memory\n", - task_pid_nr(q), q->comm); + task_tgid_nr(q), q->comm); task_unlock(q); force_sig(SIGKILL, q); } @@ -514,31 +530,6 @@ static int oom_kill_task(struct task_struct *p, struct mem_cgroup *mem) } #undef K -static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, - unsigned long points, unsigned long totalpages, - struct mem_cgroup *mem, nodemask_t *nodemask, - const char *message) -{ - if (printk_ratelimit()) - dump_header(p, gfp_mask, order, mem, nodemask); - - /* - * If the task is already exiting, don't alarm the sysadmin or kill - * its children or threads, just set TIF_MEMDIE so it can die quickly - */ - if (p->flags & PF_EXITING) { - set_tsk_thread_flag(p, TIF_MEMDIE); - return 0; - } - - task_lock(p); - pr_err("%s: Kill process %d (%s) points %lu\n", - message, task_pid_nr(p), p->comm, points); - task_unlock(p); - - return oom_kill_task(p, mem); -} - /* * Determines whether the kernel must panic because of the panic_on_oom sysctl. */ -- 1.7.3.1