[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20100824091920.181932e0.nishimura@mxp.nes.nec.co.jp>
Date: Tue, 24 Aug 2010 09:19:20 +0900
From: Daisuke Nishimura <nishimura@....nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc: linux-mm@...ck.org,
"balbir@...ux.vnet.ibm.com" <balbir@...ux.vnet.ibm.com>,
gthelen@...gle.com, m-ikeda@...jp.nec.com,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
kamezawa.hiroyuki@...il.com,
Daisuke Nishimura <nishimura@....nes.nec.co.jp>
Subject: Re: [PATCH 2/5] memcg: use array and ID for quick look up
> > > @@ -2231,7 +2244,7 @@ __mem_cgroup_commit_charge_swapin(struct
> > >
> > > id = swap_cgroup_record(ent, 0);
> > > rcu_read_lock();
> > > - memcg = mem_cgroup_lookup(id);
> > > + memcg = id_to_memcg(id);
> > > if (memcg) {
> > > /*
> > > * This recorded memcg can be obsolete one. So, avoid
> > > @@ -2240,9 +2253,10 @@ __mem_cgroup_commit_charge_swapin(struct
> > > if (!mem_cgroup_is_root(memcg))
> > > res_counter_uncharge(&memcg->memsw, PAGE_SIZE);
> > > mem_cgroup_swap_statistics(memcg, false);
> > > + rcu_read_unlock();
> > > mem_cgroup_put(memcg);
> > > - }
> > > - rcu_read_unlock();
> > > + } else
> > > + rcu_read_unlock();
> > > }
> > > /*
> > > * At swapin, we may charge account against cgroup which has no tasks.
> > > @@ -2495,7 +2509,7 @@ void mem_cgroup_uncharge_swap(swp_entry_
> > >
> > > id = swap_cgroup_record(ent, 0);
> > > rcu_read_lock();
> > > - memcg = mem_cgroup_lookup(id);
> > > + memcg = id_to_memcg(id);
> > > if (memcg) {
> > > /*
> > > * We uncharge this because swap is freed.
> > > @@ -2504,9 +2518,10 @@ void mem_cgroup_uncharge_swap(swp_entry_
> > > if (!mem_cgroup_is_root(memcg))
> > > res_counter_uncharge(&memcg->memsw, PAGE_SIZE);
> > > mem_cgroup_swap_statistics(memcg, false);
> > > + rcu_read_unlock();
> > > mem_cgroup_put(memcg);
> > > - }
> > > - rcu_read_unlock();
> > > + } else
> > > + rcu_read_unlock();
> > > }
> > >
> > > /**
> > Could you explain why we need rcu_read_unlock() before mem_cgroup_put() ?
> > I suspect that it's because mem_cgroup_put() can free the memcg, but do we
> > need mem->valid then ?
> >
> mem_cgroup_put() may call synchronize_rcu(). So, we have to unlock before it.
>
Ah, I see. Thank you for your explanation.
Daisuke Nishimura.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists