From: Michal Hocko <mhocko@suse.cz>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: linux-mm@kvack.org, Tejun Heo <tj@kernel.org>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [patch v2] mm: memcontrol: convert reclaim iterator to simple css refcounting
Date: Thu, 25 Sep 2014 12:01:30 +0200 [thread overview]
Message-ID: <20140925100130.GC12090@dhcp22.suse.cz> (raw)
In-Reply-To: <20140924171653.GA10082@cmpxchg.org>
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
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2014-09-25 10:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-19 21:10 [patch] mm: memcontrol: convert reclaim iterator to simple css refcounting Johannes Weiner
2014-09-19 21:28 ` [patch v2] " Johannes Weiner
2014-09-22 9:53 ` Vladimir Davydov
2014-09-24 16:47 ` Michal Hocko
2014-09-24 17:16 ` Johannes Weiner
2014-09-25 1:29 ` Tejun Heo
2014-09-25 10:01 ` Michal Hocko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140925100130.GC12090@dhcp22.suse.cz \
--to=mhocko@suse.cz \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).