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


Groups > linux.kernel > #1462756

Re: [PATCH stable-4.4 1/3] mm: memcontrol: fix cgroup creation failure after many small jobs

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH stable-4.4 1/3] mm: memcontrol: fix cgroup creation failure after many small jobs
Date 2016-08-15 14:50 +0200
Message-ID <s6pv3-5Eh-7@gated-at.bofh.it> (permalink)
References <s5hpT-8r9-17@gated-at.bofh.it> <s5hpU-8r9-37@gated-at.bofh.it> <s6pln-5AL-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon 15-08-16 08:34:07, Johannes Weiner wrote:
> Hi Michal, thanks for doing this. There is only one issue I can see:
> 
> On Fri, Aug 12, 2016 at 11:56:17AM +0200, Michal Hocko wrote:
> > @@ -4171,17 +4211,27 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
> >  	if (!memcg)
> >  		return NULL;
> >  
> > +	memcg->id.id = idr_alloc(&mem_cgroup_idr, NULL,
> > +				 1, MEM_CGROUP_ID_MAX,
> > +				 GFP_KERNEL);
> > +	if (memcg->id.id < 0)
> > +		goto out_free;
> > +
> >  	memcg->stat = alloc_percpu(struct mem_cgroup_stat_cpu);
> >  	if (!memcg->stat)
> > -		goto out_free;
> > +		goto out_idr;
> >  
> >  	if (memcg_wb_domain_init(memcg, GFP_KERNEL))
> >  		goto out_free_stat;
> >  
> > +	idr_replace(&mem_cgroup_idr, memcg, memcg->id.id);
> 
> This publishes the memcg object too early. Before 4.5, the memcg is
> not fully initialized in mem_cgroup_alloc(). You have to move the
> idr_replace() down to that function (and idr_remove() on free_out).

You are right. I am just wondering whether it matters. Nobody should see
the id so nobody will be looking it up, no?

> >  	return memcg;
> >  
> >  out_free_stat:
> >  	free_percpu(memcg->stat);
> > +out_idr:
> > +	if (memcg->id.id > 0)
> > +		idr_remove(&mem_cgroup_idr, memcg->id.id);
> 
> The > 0 check seems unnecessary, no?

Yes, I will drop it.

Thanks!
-- 
Michal Hocko
SUSE Labs

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


Thread

[PATCH stable-4.4 0/3] backport memcg id patches Michal Hocko <mhocko@kernel.org> - 2016-08-12 12:00 +0200
  [PATCH stable-4.4 1/3] mm: memcontrol: fix cgroup creation failure after many small jobs Michal Hocko <mhocko@kernel.org> - 2016-08-12 12:00 +0200
    Re: [PATCH stable-4.4 1/3] mm: memcontrol: fix cgroup creation  failure after many small jobs Johannes Weiner <hannes@cmpxchg.org> - 2016-08-15 14:40 +0200
      Re: [PATCH stable-4.4 1/3] mm: memcontrol: fix cgroup creation  failure after many small jobs Michal Hocko <mhocko@kernel.org> - 2016-08-15 14:50 +0200
        Re: [PATCH stable-4.4 1/3] mm: memcontrol: fix cgroup creation  failure after many small jobs Johannes Weiner <hannes@cmpxchg.org> - 2016-08-15 15:50 +0200
          Re: [PATCH stable-4.4 1/3] mm: memcontrol: fix cgroup creation  failure after many small jobs Michal Hocko <mhocko@kernel.org> - 2016-08-15 16:10 +0200
            Re: [PATCH stable-4.4 1/3] mm: memcontrol: fix cgroup creation  failure after many small jobs Johannes Weiner <hannes@cmpxchg.org> - 2016-08-15 16:40 +0200
  Re: [PATCH stable-4.4 0/3] backport memcg id patches Greg KH <greg@kroah.com> - 2016-08-14 18:10 +0200

csiph-web