Re: [RFC][PATCH 2/3] memcg: oom notifier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you.

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

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

> >        /*
> >         * 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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]