From: Michal Hocko <mhocko@suse.cz>
To: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>,
Andrew Morton <akpm@linux-foundation.org>,
Glauber Costa <glommer@parallels.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Johannes Weiner <hannes@cmpxchg.org>,
LKML <linux-kernel@vger.kernel.org>,
Cgroups <cgroups@vger.kernel.org>,
linux-mm@kvack.org
Subject: Re: [PATCH 5/9] memcg: use css_get/put when charging/uncharging kmem
Date: Thu, 30 May 2013 17:12:20 +0200 [thread overview]
Message-ID: <20130530151220.GB18155@dhcp22.suse.cz> (raw)
In-Reply-To: <20130530054852.GA9305@mtj.dyndns.org>
On Thu 30-05-13 14:48:52, Tejun Heo wrote:
> Hello,
>
> Sorry about the delay. Have been and still am traveling.
>
> On Fri, May 24, 2013 at 09:54:20AM +0200, Michal Hocko wrote:
> > > > On Fri, May 17, 2013 at 03:04:06PM +0800, Li Zefan wrote:
> > > >> + /*
> > > >> + * Releases a reference taken in kmem_cgroup_css_offline in case
> > > >> + * this last uncharge is racing with the offlining code or it is
> > > >> + * outliving the memcg existence.
> > > >> + *
> > > >> + * The memory barrier imposed by test&clear is paired with the
> > > >> + * explicit one in kmem_cgroup_css_offline.
> > > >
> > > > Paired with the wmb to achieve what?
> >
> > https://lkml.org/lkml/2013/4/4/190
> > "
> > ! > + css_get(&memcg->css);
> > ! I think that you need a write memory barrier here because css_get
> > ! nor memcg_kmem_mark_dead implies it. memcg_uncharge_kmem uses
> > ! memcg_kmem_test_and_clear_dead which imply a full memory barrier but it
> > ! should see the elevated reference count. No?
> > !
> > ! > + /*
> > ! > + * We need to call css_get() first, because memcg_uncharge_kmem()
> > ! > + * will call css_put() if it sees the memcg is dead.
> > ! > + */
> > ! > memcg_kmem_mark_dead(memcg);
> > "
> >
> > Does it make sense to you Tejun?
>
> Yeah, you're right. We need them. It's still a bummer that mark_dead
> has the appearance of proper encapsulation while not really taking
> care of synchronization.
No objection to put barrier there. You are right it is more natural.
> I think it'd make more sense for mark_dead to have the barrier (which
> BTW should probably be smp_wmb() instead of wmb())
Yes, smp_wmb sounds like a better fit.
> inside it or for the function to be just open-coded. More on this
> topic later.
>
> > > The comment is wrong. I'll fix it.
> >
> > Ohh, right. "Althouth this might sound strange as this path is called from
> > css_offline when the reference might have dropped down to 0 and shouldn't ..."
> >
> > Sounds better?
>
> Yeap.
>
> > > I don't quite like adding a lock not to protect data but just ensure code
> > > orders.
> >
> > Agreed.
> >
> > > Michal, what's your preference? I want to be sure that everyone is happy
> > > so the next version will hopefully be the last version.
> >
> > I still do not see why the barrier is not needed and the lock seems too
> > big hammer.
>
> Yes, the barrier is necessary but I still think it's unnecessarily
> elaborate. Among the locking constructs, the barriesr are the worst -
> they don't enforce any structures, people often misunderstand / make
> mistakes about them, bugs from misusages are extremely difficult to
> trigger and reproduce especially on x86. It's a horrible construct
> and should only be used if no other options can meet the performance
> requirements required for the path.
I am all for simplifying the code. I guess it deserves a separate patch
though and it is a bit unrelated to the scope of the series.
--
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>
next prev parent reply other threads:[~2013-05-30 15:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-17 7:02 [PATCH 0/12][V3] memcg: make memcg's life cycle the same as cgroup Li Zefan
2013-05-17 7:03 ` [PATCH 1/9] Revert "memcg: avoid dangling reference count in creation failure." Li Zefan
2013-05-17 7:03 ` [PATCH 2/9] memcg, kmem: fix reference count handling on the error path Li Zefan
2013-05-17 7:03 ` [PATCH 3/9] memcg: use css_get() in sock_update_memcg() Li Zefan
2013-05-17 7:03 ` [PATCH 4/9] memcg: don't use mem_cgroup_get() when creating a kmemcg cache Li Zefan
2013-05-17 7:04 ` [PATCH 5/9] memcg: use css_get/put when charging/uncharging kmem Li Zefan
2013-05-17 18:08 ` Tejun Heo
2013-05-22 8:36 ` Li Zefan
2013-05-24 7:54 ` Michal Hocko
2013-05-30 5:48 ` Tejun Heo
2013-05-30 15:12 ` Michal Hocko [this message]
2013-05-17 7:04 ` [PATCH 6/9] memcg: use css_get/put for swap memcg Li Zefan
2013-05-17 7:04 ` [PATCH 7/9] memcg: don't need to get a reference to the parent Li Zefan
2013-05-17 7:05 ` [PATCH 8/9] memcg: kill memcg refcnt Li Zefan
2013-05-17 7:05 ` [PATCH 9/9] memcg: don't need to free memcg via RCU or workqueue Li Zefan
2013-05-17 7:06 ` [PATCH 0/12][V3] memcg: make memcg's life cycle the same as cgroup Li Zefan
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=20130530151220.GB18155@dhcp22.suse.cz \
--to=mhocko@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=glommer@parallels.com \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lizefan@huawei.com \
--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