linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Paul Menage" <menage@google.com>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Christoph Lameter <clameter@sgi.com>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	linux-mm@kvack.org
Subject: Re: [patch -mm 7/5] oom: filter tasklist dump by mem_cgroup
Date: Tue, 25 Sep 2007 11:00:36 -0700	[thread overview]
Message-ID: <6599ad830709251100n352028beraddaf2ac33ea8f6c@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.0.9999.0709250037030.11015@chino.kir.corp.google.com>

It would be nice to be able to do the same thing for cpuset
membership, in the event that cpusets are active and the memory
controller is not.

Paul

On 9/25/07, David Rientjes <rientjes@google.com> wrote:
> If an OOM was triggered as a result a cgroup's memory controller, the
> tasklist shall be filtered to exclude tasks that are not a member of the
> same group.
>
> Creates a helper function to return non-zero if a task is a member of a
> mem_cgroup:
>
>         int task_in_mem_cgroup(const struct task_struct *task,
>                                const struct mem_cgroup *mem);
>
> Cc: Christoph Lameter <clameter@sgi.com>
> Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  include/linux/memcontrol.h |   16 ++++++++++++++++
>  mm/oom_kill.c              |   25 ++++++++++++++-----------
>  2 files changed, 30 insertions(+), 11 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -52,6 +52,16 @@ static inline void mem_cgroup_uncharge_page(struct page *page)
>         mem_cgroup_uncharge(page_get_page_cgroup(page));
>  }
>
> +/*
> + * Returns non-zero if the task is in the cgroup; otherwise returns zero.
> + * Call with task_lock(task) held.
> + */
> +static inline int task_in_mem_cgroup(const struct task_struct *task,
> +                                    const struct mem_cgroup *mem)
> +{
> +       return mem && task->mm && mm_cgroup(task->mm) == mem;
> +}
> +
>  #else /* CONFIG_CGROUP_MEM_CONT */
>  static inline void mm_init_cgroup(struct mm_struct *mm,
>                                         struct task_struct *p)
> @@ -103,6 +113,12 @@ static inline struct mem_cgroup *mm_cgroup(struct mm_struct *mm)
>         return NULL;
>  }
>
> +static inline int task_in_mem_cgroup(const struct task_struct *task,
> +                                    const struct mem_cgroup *mem)
> +{
> +       return 1;
> +}
> +
>  #endif /* CONFIG_CGROUP_MEM_CONT */
>
>  #endif /* _LINUX_MEMCONTROL_H */
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -65,13 +65,10 @@ unsigned long badness(struct task_struct *p, unsigned long uptime,
>                 task_unlock(p);
>                 return 0;
>         }
> -
> -#ifdef CONFIG_CGROUP_MEM_CONT
> -       if (mem != NULL && mm->mem_cgroup != mem) {
> +       if (!task_in_mem_cgroup(p, mem)) {
>                 task_unlock(p);
>                 return 0;
>         }
> -#endif
>
>         /*
>          * The memory size of the process is the basis for the badness.
> @@ -274,9 +271,12 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
>   * State information includes task's pid, uid, tgid, vm size, rss, cpu, oom_adj
>   * score, and name.
>   *
> + * If the actual is non-NULL, only tasks that are a member of the mem_cgroup are
> + * shown.
> + *
>   * Call with tasklist_lock read-locked.
>   */
> -static void dump_tasks(void)
> +static void dump_tasks(const struct mem_cgroup *mem)
>  {
>         struct task_struct *g, *p;
>
> @@ -291,6 +291,8 @@ static void dump_tasks(void)
>                         continue;
>
>                 task_lock(p);
> +               if (!task_in_mem_cgroup(p, mem))
> +                       continue;
>                 printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d     %3d %s\n",
>                        p->pid, p->uid, p->tgid, p->mm->total_vm,
>                        get_mm_rss(p->mm), (int)task_cpu(p), p->oomkilladj,
> @@ -376,7 +378,8 @@ static int oom_kill_task(struct task_struct *p)
>  }
>
>  static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
> -                           unsigned long points, const char *message)
> +                           unsigned long points, struct mem_cgroup *mem,
> +                           const char *message)
>  {
>         struct task_struct *c;
>
> @@ -387,7 +390,7 @@ static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
>                 dump_stack();
>                 show_mem();
>                 if (sysctl_oom_dump_tasks)
> -                       dump_tasks();
> +                       dump_tasks(mem);
>         }
>
>         /*
> @@ -428,7 +431,7 @@ retry:
>         if (!p)
>                 p = current;
>
> -       if (oom_kill_process(p, gfp_mask, 0, points,
> +       if (oom_kill_process(p, gfp_mask, 0, points, mem,
>                                 "Memory cgroup out of memory"))
>                 goto retry;
>  out:
> @@ -534,7 +537,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
>
>         switch (constraint) {
>         case CONSTRAINT_MEMORY_POLICY:
> -               oom_kill_process(current, gfp_mask, order, points,
> +               oom_kill_process(current, gfp_mask, order, points, NULL,
>                                 "No available memory (MPOL_BIND)");
>                 break;
>
> @@ -544,7 +547,7 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
>                 /* Fall-through */
>         case CONSTRAINT_CPUSET:
>                 if (sysctl_oom_kill_allocating_task) {
> -                       oom_kill_process(current, gfp_mask, order, points,
> +                       oom_kill_process(current, gfp_mask, order, points, NULL,
>                                         "Out of memory (oom_kill_allocating_task)");
>                         break;
>                 }
> @@ -564,7 +567,7 @@ retry:
>                         panic("Out of memory and no killable processes...\n");
>                 }
>
> -               if (oom_kill_process(p, points, gfp_mask, order,
> +               if (oom_kill_process(p, points, gfp_mask, order, NULL,
>                                      "Out of memory"))
>                         goto retry;
>
>
> --
> 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>
>

--
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>

  parent reply	other threads:[~2007-09-25 18:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-25 17:13 [patch -mm 6/5] memcontrol: move mm_cgroup to header file David Rientjes
2007-09-25 17:13 ` [patch -mm 7/5] oom: filter tasklist dump by mem_cgroup David Rientjes
2007-09-25 17:48   ` Balbir Singh
2007-09-25 19:18     ` David Rientjes
2007-09-25 18:00   ` Paul Menage [this message]
2007-09-25 21:17     ` Christoph Lameter
2007-09-25 22:54       ` Paul Menage
2007-09-26  1:14     ` Paul Jackson
2007-09-26  1:20       ` David Rientjes
2007-09-26  3:56         ` Paul Jackson
2007-09-26  4:14           ` David Rientjes
2007-09-26  4:24             ` David Rientjes
2007-09-26  4:37             ` Paul Jackson
2007-09-26  1:22       ` Paul Menage
2007-09-26  3:57         ` Paul Jackson
2007-09-26  4:03           ` Paul Menage
2007-09-26  4:30             ` Paul Jackson
2007-09-25 17:18 ` [patch -mm 6/5] memcontrol: move mm_cgroup to header file Balbir Singh
2007-09-25 18:49   ` David Rientjes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6599ad830709251100n352028beraddaf2ac33ea8f6c@mail.gmail.com \
    --to=menage@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=clameter@sgi.com \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox