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

From: Minchan Kim
Date: Thu Feb 25 2010 - 10:36:20 EST


Hi

On Tue, Feb 23, 2010 at 8:58 PM, Andrea Righi <arighi@xxxxxxxxxxx> 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?


--
Kind regards,
Minchan Kim
--
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/