lkml.org 
[lkml]   [2010]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 2/3] memcg: oom notifier
Thank you.

On Thu, 11 Mar 2010 16:47:00 +0200
"Kirill A. Shutemov" <kirill@shutemov.name> wrote:

> On Thu, Mar 11, 2010 at 9:57 AM, KAMEZAWA Hiroyuki
> <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>

> >        /*
> >         * Should we move charges of a task when a task is moved into this
> >         * mem_cgroup ? And what type of charges should we move ?
> > @@ -282,9 +292,12 @@ enum charge_type {
> >  /* for encoding cft->private value on file */
> >  #define _MEM                   (0)
> >  #define _MEMSWAP               (1)
> > +#define _OOM_TYPE              (2)
> >  #define MEMFILE_PRIVATE(x, val)        (((x) << 16) | (val))
> >  #define MEMFILE_TYPE(val)      (((val) >> 16) & 0xffff)
> >  #define MEMFILE_ATTR(val)      ((val) & 0xffff)
> > +/* Used for OOM nofiier */
> > +#define OOM_CONTROL            (0)
> >
> >  /*
> >  * Reclaim flags for mem_cgroup_hierarchical_reclaim
> > @@ -1351,6 +1364,8 @@ bool mem_cgroup_handle_oom(struct mem_cg
> >         */
> >        if (!locked)
> >                prepare_to_wait(&memcg_oom_waitq, &owait.wait, TASK_KILLABLE);
> > +       else
> > +               mem_cgroup_oom_notify(mem);
> >        mutex_unlock(&memcg_oom_mutex);
> >
> >        if (locked)
> > @@ -3398,8 +3413,22 @@ static int compare_thresholds(const void
> >        return _a->threshold - _b->threshold;
> >  }
> >
> > -static int mem_cgroup_register_event(struct cgroup *cgrp, struct cftype *cft,
> > -               struct eventfd_ctx *eventfd, const char *args)
> > +static int mem_cgroup_oom_notify_cb(struct mem_cgroup *mem, void *data)
> > +{
> > +       struct mem_cgroup_eventfd_list *ev;
> > +
> > +       list_for_each_entry(ev, &mem->oom_notify, list)
> > +               eventfd_signal(ev->eventfd, 1);
> > +       return 0;
> > +}
> > +
> > +static void mem_cgroup_oom_notify(struct mem_cgroup *mem)
> > +{
> > +       mem_cgroup_walk_tree(mem, NULL, mem_cgroup_oom_notify_cb);
> > +}
> > +
> > +static int mem_cgroup_usage_register_event(struct cgroup *cgrp,
> > +       struct cftype *cft, struct eventfd_ctx *eventfd, const char *args)
> >  {
> >        struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> >        struct mem_cgroup_threshold_ary *thresholds, *thresholds_new;
> > @@ -3483,8 +3512,8 @@ unlock:
> >        return ret;
> >  }
> >
> > -static int mem_cgroup_unregister_event(struct cgroup *cgrp, struct cftype *cft,
> > -               struct eventfd_ctx *eventfd)
> > +static int mem_cgroup_usage_unregister_event(struct cgroup *cgrp,
> > +       struct cftype *cft, struct eventfd_ctx *eventfd)
> >  {
> >        struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> >        struct mem_cgroup_threshold_ary *thresholds, *thresholds_new;
> > @@ -3568,13 +3597,66 @@ unlock:
> >        return ret;
> >  }
> >
> > +static int mem_cgroup_oom_register_event(struct cgroup *cgrp,
> > +       struct cftype *cft, struct eventfd_ctx *eventfd, const char *args)
> > +{
> > +       struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp);
> > +       struct mem_cgroup_eventfd_list *event;
> > +       int type = MEMFILE_TYPE(cft->private);
> > +       int ret = -ENOMEM;
> > +
> > +       BUG_ON(type != _OOM_TYPE);
> > +
> > +       mutex_lock(&memcg_oom_mutex);
> > +
> > +       /* Allocate memory for new array of thresholds */
>
> Irrelevant comment?
>
> > +       event = kmalloc(sizeof(*event), GFP_KERNEL);
> > +       if (!event)
> > +               goto unlock;
> > +       /* Add new threshold */
>
> Ditto.
>
Ah...sorry for garbages..I'll clean these up.

Thanks,
-Kame

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-03-12 01:01    [W:0.033 / U:4.660 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site