From: Peter Zijlstra <peterz@infradead.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Tejun Heo <tj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>, Michal Hocko <mhocko@suse.cz>,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [patch] mm: memcontrol: do not iterate uninitialized memcgs
Date: Fri, 26 Sep 2014 15:39:25 +0200 [thread overview]
Message-ID: <20140926133925.GG4140@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20140925134342.GB22508@cmpxchg.org>
On Thu, Sep 25, 2014 at 09:43:42AM -0400, Johannes Weiner wrote:
> > > + if (next_css == &root->css ||
> > > + css_tryget_online(next_css)) {
> > > + struct mem_cgroup *memcg;
> > > +
> > > + memcg = mem_cgroup_from_css(next_css);
> > > + if (memcg->initialized) {
> > > + /*
> > > + * Make sure the caller's accesses to
> > > + * the memcg members are issued after
> > > + * we see this flag set.
> >
> > I usually prefer if the comment points to the exact location that the
> > matching memory barriers live. Sometimes it's difficult to locate the
> > partner barrier even w/ the functional explanation.
That is indeed good practise! :-)
> > > + */
> > > + smp_rmb();
> > > + return memcg;
> >
> > In an unlikely event this rmb becomes an issue, a self-pointing
> > pointer which is set/read using smp_store_release() and
> > smp_load_acquire() respectively can do with plain barrier() on the
> > reader side on archs which don't need data dependency barrier
> > (basically everything except alpha). Not sure whether that'd be more
> > or less readable than this tho.
> So as far as I understand memory-barriers.txt we do not even need a
> data dependency here to use store_release and load_acquire:
>
> mem_cgroup_css_online():
> <initialize memcg>
> smp_store_release(&memcg->initialized, 1);
>
> mem_cgroup_iter():
> <look up maybe-initialized memcg>
> if (smp_load_acquire(&memcg->initialized))
> return memcg;
>
> So while I doubt that the smp_rmb() will become a problem in this
> path, it would be neat to annotate the state flag around which we
> synchronize like this, rather than have an anonymous barrier.
>
> Peter, would you know if this is correct, or whether these primitives
> actually do require a data dependency?
I'm fairly sure you do not. load_acquire() has the same barrier in on
Alpha that read_barrier_depends() does, and that's the only arch that
matters.
--
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-26 13:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 2:31 Johannes Weiner
2014-09-25 2:40 ` [patch v2] " Johannes Weiner
2014-09-25 11:43 ` Michal Hocko
2014-09-25 13:54 ` Johannes Weiner
2014-09-25 14:11 ` Michal Hocko
2014-09-25 2:57 ` [patch] " Tejun Heo
2014-09-25 13:43 ` Johannes Weiner
2014-09-25 14:23 ` Michal Hocko
2014-09-26 13:39 ` Peter Zijlstra [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=20140926133925.GG4140@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--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