[Devel] Re: [PATCH 1/2] memcg: dirty pages accounting and limiting infrastructure

KAMEZAWA Hiroyuki kamezawa.hiroyu at jp.fujitsu.com
Thu Feb 25 16:23:39 PST 2010


On Fri, 26 Feb 2010 00:36:15 +0900
Minchan Kim <minchan.kim at gmail.com> wrote:

> Hi
> 
> On Tue, Feb 23, 2010 at 8:58 PM, Andrea Righi <arighi at develer.com> wrote:
> > On Mon, Feb 22, 2010 at 01:07:32PM -0500, Vivek Goyal wrote:
> >> > > > +unsigned long mem_cgroup_dirty_bytes(void)
> >> > > > +{
> >> > > > +       struct mem_cgroup *memcg;
> >> > > > +       unsigned long dirty_bytes;
> >> > > > +
> >> > > > +       if (mem_cgroup_disabled())
> >> > > > +               return vm_dirty_bytes;
> >> > > > +
> >> > > > +       rcu_read_lock();
> >> > > > +       memcg = mem_cgroup_from_task(current);
> >> > > > +       if (memcg == NULL)
> >> > > > +               dirty_bytes = vm_dirty_bytes;
> >> > > > +       else
> >> > > > +               dirty_bytes = get_dirty_bytes(memcg);
> >> > > > +       rcu_read_unlock();
> >> > >
> >> > > The rcu_read_lock() isn't protecting anything here.
> >> >
> >> > Right!
> >>
> >> Are we not protecting "memcg" pointer using rcu here?
> >
> > Vivek, you are right:
> >
> >  mem_cgroup_from_task() -> task_subsys_state() -> rcu_dereference()
> >
> > So, this *must* be RCU protected.
> 
> So, Doesn't mem_cgroup_from_task in mem_cgroup_can_attach need RCU, too?
> 
Hm ? I don't read the whole thread but can_attach() is called under
cgroup_mutex(). So, it doesn't need to use RCU.

Thanks,
-Kame


_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list