[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160803095049.GG13263@esperanza>
Date: Wed, 3 Aug 2016 12:50:49 +0300
From: Vladimir Davydov <vdavydov@...tuozzo.com>
To: Michal Hocko <mhocko@...nel.org>
CC: Andrew Morton <akpm@...ux-foundation.org>,
<stable@...r.kernel.org>, Johannes Weiner <hannes@...xchg.org>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/3] mm: memcontrol: fix swap counter leak on swapout
from offline cgroup
On Tue, Aug 02, 2016 at 06:00:26PM +0200, Michal Hocko wrote:
> On Tue 02-08-16 18:00:48, Vladimir Davydov wrote:
...
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index 3be791afd372..4ae12effe347 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -4036,6 +4036,24 @@ static void mem_cgroup_id_get(struct mem_cgroup *memcg)
> > atomic_inc(&memcg->id.ref);
> > }
> >
> > +static struct mem_cgroup *mem_cgroup_id_get_active(struct mem_cgroup *memcg)
> > +{
> > + while (!atomic_inc_not_zero(&memcg->id.ref)) {
> > + /*
> > + * The root cgroup cannot be destroyed, so it's refcount must
> > + * always be >= 1.
> > + */
> > + if (memcg == root_mem_cgroup) {
> > + VM_BUG_ON(1);
> > + break;
> > + }
>
> why not simply VM_BUG_ON(memcg == root_mem_cgroup)?
Because with DEBUG_VM disabled we could wind up looping forever here if
the refcount of the root_mem_cgroup got screwed up. On production
kernels, it's better to break the loop and carry on closing eyes on
diverging counters rather than getting a lockup.
Powered by blists - more mailing lists