From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: Re: [PATCH 6/6] memcg: disable memcg page stat accounting Date: Wed, 20 Mar 2013 11:09:33 +0400 Message-ID: <514960AD.5010606@parallels.com> References: <1363082773-3598-1-git-send-email-handai.szj@taobao.com> <1363083103-3907-1-git-send-email-handai.szj@taobao.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1363083103-3907-1-git-send-email-handai.szj-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Sha Zhengju Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, mhocko-AlSwsSmVLrQ@public.gmane.org, kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, mgorman-l3A5Bk7waGM@public.gmane.org, Sha Zhengju On 03/12/2013 02:11 PM, Sha Zhengju wrote: > Use jump label to patch the memcg page stat accounting code > in or out when not used. when the first non-root memcg comes to > life the code is patching in otherwise it is out. > > Signed-off-by: Sha Zhengju > --- > include/linux/memcontrol.h | 23 +++++++++++++++++++++++ > mm/memcontrol.c | 34 +++++++++++++++++++++++++++++++++- > 2 files changed, 56 insertions(+), 1 deletion(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index d6183f0..99dca91 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -42,6 +42,14 @@ struct mem_cgroup_reclaim_cookie { > }; > > #ifdef CONFIG_MEMCG > + > +extern struct static_key memcg_in_use_key; > + > +static inline bool mem_cgroup_in_use(void) > +{ > + return static_key_false(&memcg_in_use_key); > +} > + I believe the big advantage of the approach I've taken, including this test in mem_cgroup_disabled(), is that we patch out a lot of things for free. We just need to be careful because some code expected that decision to be permanent and now that status can change. But I would still advocate for that.