Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1295329

Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to interrupted reclaim

From Vladimir Davydov <vdavydov@virtuozzo.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to interrupted reclaim
Date 2015-12-19 10:00 +0100
Message-ID <qHlwS-WX-3@gated-at.bofh.it> (permalink)
References (1 earlier) <qGPQl-61K-5@gated-at.bofh.it> <qH5iq-7rE-45@gated-at.bofh.it> <qH5Ls-7Ro-1@gated-at.bofh.it> <qH64O-7Y5-21@gated-at.bofh.it> <qHc0x-3j8-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Dec 18, 2015 at 02:40:04PM -0800, Andrew Morton wrote:
> On Fri, 18 Dec 2015 19:24:05 +0300 Vladimir Davydov <vdavydov@virtuozzo.com> wrote:
> 
> > 
> > OK, got it, thanks. Here goes the incremental patch (it should also fix
> > the warning regarding unused cmpxchg returned value):
> > ---
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index fc25dc211eaf..908c075e04eb 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -864,7 +864,7 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
> >  			 * might block it. So we clear iter->position right
> >  			 * away.
> >  			 */
> > -			cmpxchg(&iter->position, pos, NULL);
> > +			(void)cmpxchg(&iter->position, pos, NULL);
> 
> No, this doesn't actually squish the __must_check warning.

The warning was caused not by a __must_check annotation - using it for
cmpxchg would be just wrong - it was caused by type conversion done in
expansion of cmpxchg macro:

   arch/m68k/include/asm/cmpxchg.h:121:3: warning: value computed is not used [-Wunused-value]
     ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o),     \
      ^

(see http://www.spinics.net/lists/linux-mm/msg99133.html)

Type conversion to (void) helps suppressing this warning, and it seems
this is what is done commonly (e.g. see kernel/rcu/tree_plugin.h)

Thanks,
Vladimir
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2] mm: memcontrol: fix possible memcg leak due to interrupted reclaim Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-12-15 13:40 +0100
  Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to  interrupted reclaim Johannes Weiner <hannes@cmpxchg.org> - 2015-12-15 16:00 +0100
  Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to  interrupted reclaim Andrew Morton <akpm@linux-foundation.org> - 2015-12-18 00:10 +0100
    Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to  interrupted reclaim Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-12-18 16:40 +0100
      Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to  interrupted reclaim Johannes Weiner <hannes@cmpxchg.org> - 2015-12-18 17:10 +0100
        Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to  interrupted reclaim Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-12-18 17:30 +0100
          Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to  interrupted reclaim Andrew Morton <akpm@linux-foundation.org> - 2015-12-18 23:50 +0100
            Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to  interrupted reclaim Vladimir Davydov <vdavydov@virtuozzo.com> - 2015-12-19 10:00 +0100
  Re: [PATCH v2] mm: memcontrol: fix possible memcg leak due to  interrupted reclaim Johannes Weiner <hannes@cmpxchg.org> - 2015-12-23 23:20 +0100

csiph-web