lkml.org 
[lkml]   [2014]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch v2] mm: memcontrol: convert reclaim iterator to simple css refcounting
On Wed 24-09-14 13:16:53, Johannes Weiner wrote:
> On Wed, Sep 24, 2014 at 06:47:39PM +0200, Michal Hocko wrote:
> > On Fri 19-09-14 17:28:43, Johannes Weiner wrote:
[...]
> > > - memcg = __mem_cgroup_iter_next(root, last_visited);
> > > + do {
> > > + pos = ACCESS_ONCE(mz->reclaim_iter[priority]);
> > > + } while (pos && !css_tryget(&pos->css));
> >
> > This is a bit confusing. AFAIU css_tryget fails only when the current
> > ref count is zero already. When do we keep cached memcg with zero count
> > behind? We always do css_get after cmpxchg.
> >
> > Hmm, there is a small window between cmpxchg and css_get when we store
> > the current memcg into the reclaim_iter[priority]. If the current memcg
> > is root then we do not take any css reference before cmpxchg and so it
> > might drop down to zero in the mean time so other CPU might see zero I
> > guess. But I do not see how css_get after cmpxchg on such css works.
> > I guess I should go and check the css reference counting again.
>
> It's not about root or the newly stored memcg, it's that you might
> read the position right before it's replaced and css_put(), at which

OK, got it

CPU0 CPU1
pos = reclaim_iter[priority]
cmpxchg(reclaim_iter[priority], pos, memcg)
css_put(pos) # -> 0
css_tryget(pos)

Thanks!
--
Michal Hocko
SUSE Labs


\
 
 \ /
  Last update: 2014-09-25 12:21    [W:0.359 / U:0.924 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site