Re: [BUGFIX][PATCH] memcg: fix oom kill behavior v3

From: KAMEZAWA Hiroyuki
Date: Wed Mar 03 2010 - 23:12:17 EST


On Thu, 4 Mar 2010 13:04:06 +0900
Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx> wrote:

> On Wed, 3 Mar 2010 16:23:04 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
> > On Wed, 3 Mar 2010 09:38:44 +0900
> > KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
> >
> > > On Wed, 3 Mar 2010 09:26:06 +0900
> > > Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx> wrote:
> > >
> > > > > I'll test this patch all through this night, and check whether it doesn't trigger
> > > > > global oom after memcg's oom.
> > > > >
> > > > O.K. It works well.
> > > > Feel free to add my signs.
> > > >
> > > > Reviewed-by: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx>
> > > > Tested-by: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx>
> > > >
> > >
> > > Thank you !
> > >
> > > I'll apply Balbir's comment and post v3.
> > >
> >
> > rebased onto mmotm-Mar2.
> > tested on x86-64.
> >
> I found a small race problem. This is the fix for it.
>
> ===
> From: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx>
>
> We must avoid making oom_lock of a newly created child be negative.
>
> Signed-off-by: Daisuke Nishimura <nishimura@xxxxxxxxxxxxxxxxx>
> ---
> mm/memcontrol.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 3ce8c5b..9e25400 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1272,7 +1272,12 @@ static bool mem_cgroup_oom_lock(struct mem_cgroup *mem)
>
> static int mem_cgroup_oom_unlock_cb(struct mem_cgroup *mem, void *data)
> {
> - atomic_dec(&mem->oom_lock);
> + /*
> + * There is a small race window where a new child can be created after
> + * we called mem_cgroup_oom_lock(). Use atomic_add_unless() to avoid
> + * making oom_lock of such a child be negative.
> + */
> + atomic_add_unless(&mem->oom_lock, -1, 0);
> return 0;
> }
>


Thank you!. I'll merge this to v4.

-Kame


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

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