From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx197.postini.com [74.125.245.197]) by kanga.kvack.org (Postfix) with SMTP id C33626B002B for ; Tue, 16 Oct 2012 04:49:00 -0400 (EDT) Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id F20B93EE0C1 for ; Tue, 16 Oct 2012 17:48:58 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id D719E45DE52 for ; Tue, 16 Oct 2012 17:48:58 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id A5E2F45DD78 for ; Tue, 16 Oct 2012 17:48:58 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 9A6C31DB803F for ; Tue, 16 Oct 2012 17:48:58 +0900 (JST) Received: from m1000.s.css.fujitsu.com (m1000.s.css.fujitsu.com [10.240.81.136]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 3C6FF1DB802C for ; Tue, 16 Oct 2012 17:48:58 +0900 (JST) Message-ID: <507D1F5D.8080709@jp.fujitsu.com> Date: Tue, 16 Oct 2012 17:48:29 +0900 From: Kamezawa Hiroyuki MIME-Version: 1.0 Subject: Re: [PATCH v4 10/14] memcg: use static branches when code not in use References: <1349690780-15988-1-git-send-email-glommer@parallels.com> <1349690780-15988-11-git-send-email-glommer@parallels.com> <20121011134028.GH29295@dhcp22.suse.cz> <5077CB29.2000505@parallels.com> In-Reply-To: <5077CB29.2000505@parallels.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Glauber Costa Cc: Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Mel Gorman , Suleiman Souhlal , Tejun Heo , cgroups@vger.kernel.org, Johannes Weiner , Greg Thelen , devel@openvz.org, Frederic Weisbecker , Christoph Lameter , Pekka Enberg (2012/10/12 16:47), Glauber Costa wrote: > On 10/11/2012 05:40 PM, Michal Hocko wrote: >> On Mon 08-10-12 14:06:16, Glauber Costa wrote: >>> We can use static branches to patch the code in or out when not used. >>> >>> Because the _ACTIVE bit on kmem_accounted is only set after the >>> increment is done, we guarantee that the root memcg will always be >>> selected for kmem charges until all call sites are patched (see >>> memcg_kmem_enabled). This guarantees that no mischarges are applied. >>> >>> static branch decrement happens when the last reference count from the >>> kmem accounting in memcg dies. This will only happen when the charges >>> drop down to 0. >>> >>> When that happen, we need to disable the static branch only on those >>> memcgs that enabled it. To achieve this, we would be forced to >>> complicate the code by keeping track of which memcgs were the ones >>> that actually enabled limits, and which ones got it from its parents. >>> >>> It is a lot simpler just to do static_key_slow_inc() on every child >>> that is accounted. >>> >>> [ v4: adapted this patch to the changes in kmem_accounted ] >>> >>> Signed-off-by: Glauber Costa >>> CC: Kamezawa Hiroyuki >>> CC: Christoph Lameter >>> CC: Pekka Enberg >>> CC: Michal Hocko >>> CC: Johannes Weiner >>> CC: Suleiman Souhlal >> >> Looks reasonable to me >> Acked-by: Michal Hocko >> >> Just a little nit. >> >> [...] >> >>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c >>> index 634c7b5..724a08b 100644 >>> --- a/mm/memcontrol.c >>> +++ b/mm/memcontrol.c >>> @@ -344,11 +344,15 @@ struct mem_cgroup { >>> /* internal only representation about the status of kmem accounting. */ >>> enum { >>> KMEM_ACCOUNTED_ACTIVE = 0, /* accounted by this cgroup itself */ >>> + KMEM_ACCOUNTED_ACTIVATED, /* static key enabled. */ >>> KMEM_ACCOUNTED_DEAD, /* dead memcg, pending kmem charges */ >>> }; >>> >>> -/* first bit */ >>> -#define KMEM_ACCOUNTED_MASK 0x1 >>> +/* >>> + * first two bits. We account when limit is on, but only after >>> + * call sites are patched >>> + */ >>> +#define KMEM_ACCOUNTED_MASK 0x3 >> >> The names are long but why not use KMEM_ACCOUNTED_ACTIVE* >> #define KMEM_ACCOUNTED_MASK 1<> > Because the names are long! =) > please use "long" macros ;) it's not bad. Anyway, Acked-by: KAMEZAWA Hiroyuki -- 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: email@kvack.org