public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] oom, memcg: handle sysctl oom_kill_allocating_task while memcg oom happening
@ 2012-10-16 10:12 Sha Zhengju
  2012-10-16 10:20 ` Ni zhan Chen
       [not found] ` <1350382328-28977-1-git-send-email-handai.szj-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>
  0 siblings, 2 replies; 16+ messages in thread
From: Sha Zhengju @ 2012-10-16 10:12 UTC (permalink / raw)
  To: linux-mm-Bw31MaZKKs3YtjvyW6yDsg, cgroups-u79uwXL29TY76Z2rM5mHXA,
	kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, mhocko-AlSwsSmVLrQ
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Sha Zhengju

From: Sha Zhengju <handai.szj-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>

Sysctl oom_kill_allocating_task enables or disables killing the OOM-triggering
task in out-of-memory situations, but it only works on overall system-wide oom.
But it's also a useful indication in memcg so we take it into consideration
while oom happening in memcg. Other sysctl such as panic_on_oom has already
been memcg-ware.


Signed-off-by: Sha Zhengju <handai.szj-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>
---
 mm/memcontrol.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index e4e9b18..c329940 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1486,6 +1486,15 @@ static void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
 
 	check_panic_on_oom(CONSTRAINT_MEMCG, gfp_mask, order, NULL);
 	totalpages = mem_cgroup_get_limit(memcg) >> PAGE_SHIFT ? : 1;
+	if (sysctl_oom_kill_allocating_task && current->mm &&
+	    !oom_unkillable_task(current, memcg, NULL) &&
+	    current->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) {
+		get_task_struct(current);
+		oom_kill_process(current, gfp_mask, order, 0, totalpages, memcg, NULL,
+				 "Memory cgroup out of memory (oom_kill_allocating_task)");
+		return;
+	}
+
 	for_each_mem_cgroup_tree(iter, memcg) {
 		struct cgroup *cgroup = iter->css.cgroup;
 		struct cgroup_iter it;
-- 
1.7.6.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH] oom, memcg: handle sysctl oom_kill_allocating_task while memcg oom happening
@ 2012-10-16  6:10 Sha Zhengju
       [not found] ` <1350367837-27919-1-git-send-email-handai.szj-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 16+ messages in thread
From: Sha Zhengju @ 2012-10-16  6:10 UTC (permalink / raw)
  To: linux-mm, cgroups, kamezawa.hiroyu, akpm, mhocko
  Cc: linux-kernel, Sha Zhengju

From: Sha Zhengju <handai.szj@taobao.com>

Sysctl oom_kill_allocating_task enables or disables killing the OOM-triggering
task in out-of-memory situations, but it only works on overall system-wide oom.
But it's also a useful indication in memcg so we take it into consideration
while oom happening in memcg. Other sysctl such as panic_on_oom has already
been memcg-ware.


Signed-off-by: Sha Zhengju <handai.szj@taobao.com>
---
 mm/oom_kill.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 38129e3..2a176af 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -574,6 +574,18 @@ void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask)
        check_panic_on_oom(CONSTRAINT_MEMCG, gfp_mask, 0, NULL);
        limit = mem_cgroup_get_limit(memcg) >> PAGE_SHIFT;
        read_lock(&tasklist_lock);
+       if (sysctl_oom_kill_allocating_task &&
+           !oom_unkillable_task(current, memcg, NULL) &&
+           current->mm) {
+               /*
+                * oom_kill_process() needs tasklist_lock held.  If it returns
+                * non-zero, current could not be killed so we must fallback to
+                * the tasklist scan.
+                */
+               if (!oom_kill_process(current, gfp_mask, 0, 0, limit, memcg, NULL,
+                               "Memory cgroup out of memory (oom_kill_allocating_task)"))
+                       goto out;
+       }
 retry:
        p = select_bad_process(&points, limit, memcg, NULL);
        if (!p || PTR_ERR(p) == -1UL)
--
1.7.6.1


________________________________

This email (including any attachments) is confidential and may be legally privileged. If you received this email in error, please delete it immediately and do not copy it or use it for any purpose or disclose its contents to any other person. Thank you.

本电邮(包括任何附件)可能含有机密资料并受法律保护。如您不是正确的收件人,请您立即删除本邮件。请不要将本电邮进行复制并用作任何其他用途、或透露本邮件之内容。谢谢。

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-10-19  9:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-16 10:12 [PATCH] oom, memcg: handle sysctl oom_kill_allocating_task while memcg oom happening Sha Zhengju
2012-10-16 10:20 ` Ni zhan Chen
     [not found]   ` <507D34E3.3040705-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-16 10:41     ` Sha Zhengju
     [not found] ` <1350382328-28977-1-git-send-email-handai.szj-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>
2012-10-16 13:34   ` Michal Hocko
2012-10-16 17:14     ` Sha Zhengju
     [not found]       ` <CAFj3OHVW-betpEnauzk-vQEfw_7bJxFneQb2oWpAZzOpZuMDiQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-18 11:56         ` Michal Hocko
     [not found]           ` <20121018115640.GB24295-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2012-10-18 13:51             ` Sha Zhengju
     [not found]               ` <5080097D.5020501-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-18 15:32                 ` Michal Hocko
     [not found]                   ` <20121018153256.GC24295-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2012-10-19  4:11                     ` Sha Zhengju
     [not found]                       ` <5080D308.1020805-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-19  9:52                         ` Michal Hocko
     [not found]     ` <20121016133439.GI13991-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2012-10-16 18:39       ` David Rientjes
2012-10-16 18:44   ` David Rientjes
  -- strict thread matches above, loose matches on Subject: below --
2012-10-16  6:10 Sha Zhengju
     [not found] ` <1350367837-27919-1-git-send-email-handai.szj-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>
2012-10-16  6:12   ` David Rientjes
2012-10-16  6:32     ` Sha Zhengju
2012-10-16  7:03       ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox