From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: Re: [PATCH 19/23] slab: per-memcg accounting of slab caches Date: Wed, 2 May 2012 12:40:37 -0300 Message-ID: <4FA15575.6020209@parallels.com> References: <1334959051-18203-1-git-send-email-glommer@parallels.com> <1335138820-26590-8-git-send-email-glommer@parallels.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Suleiman Souhlal Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org, kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org, Michal Hocko , Johannes Weiner , fweisbec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, Greg Thelen , Christoph Lameter , Pekka Enberg >> @@ -3834,11 +3866,15 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp, >> */ >> void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) >> { >> - void *ret = __cache_alloc(cachep, flags, __builtin_return_address(0)); >> + void *ret; >> + >> + rcu_read_lock(); >> + cachep = mem_cgroup_get_kmem_cache(cachep, flags); >> + rcu_read_unlock(); > > Don't we need to check in_interrupt(), current, __GFP_NOFAIL every > time we call mem_cgroup_cgroup_get_kmem_cache()? > > I would personally prefer if those checks were put inside > mem_cgroup_get_kmem_cache() instead of having to check for every > caller. > in_interrupt() yes, __GFP_NOFAIL I don't think so. __GFP_NOFAIL should lead to a res_counter_charge_nofail() in the end. The name similarity is no coincidence... From a code style PoV, it makes sense to bundle an in_interrupt() check here, but from a performance PoV, putting it in the callers can help us avoid the price of a function call. But well, looking at the code, I see it is not there as well... =( I plan to change memcontrol.h to look like this: static __always_inline struct kmem_cache * mem_cgroup_get_kmem_cache(struct kmem_cache *cachep, gfp_t gfp) { if (mem_cgroup_kmem_on && current->mm && !in_interrupt()) return __mem_cgroup_get_kmem_cache(cachep, gfp); return cachep; } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx121.postini.com [74.125.245.121]) by kanga.kvack.org (Postfix) with SMTP id 0D7026B004D for ; Wed, 2 May 2012 11:42:58 -0400 (EDT) Message-ID: <4FA15575.6020209@parallels.com> Date: Wed, 2 May 2012 12:40:37 -0300 From: Glauber Costa MIME-Version: 1.0 Subject: Re: [PATCH 19/23] slab: per-memcg accounting of slab caches References: <1334959051-18203-1-git-send-email-glommer@parallels.com> <1335138820-26590-8-git-send-email-glommer@parallels.com> In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Suleiman Souhlal Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, devel@openvz.org, kamezawa.hiroyu@jp.fujitsu.com, Michal Hocko , Johannes Weiner , fweisbec@gmail.com, Greg Thelen , Christoph Lameter , Pekka Enberg >> @@ -3834,11 +3866,15 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp, >> */ >> void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) >> { >> - void *ret = __cache_alloc(cachep, flags, __builtin_return_address(0)); >> + void *ret; >> + >> + rcu_read_lock(); >> + cachep = mem_cgroup_get_kmem_cache(cachep, flags); >> + rcu_read_unlock(); > > Don't we need to check in_interrupt(), current, __GFP_NOFAIL every > time we call mem_cgroup_cgroup_get_kmem_cache()? > > I would personally prefer if those checks were put inside > mem_cgroup_get_kmem_cache() instead of having to check for every > caller. > in_interrupt() yes, __GFP_NOFAIL I don't think so. __GFP_NOFAIL should lead to a res_counter_charge_nofail() in the end. The name similarity is no coincidence... From a code style PoV, it makes sense to bundle an in_interrupt() check here, but from a performance PoV, putting it in the callers can help us avoid the price of a function call. But well, looking at the code, I see it is not there as well... =( I plan to change memcontrol.h to look like this: static __always_inline struct kmem_cache * mem_cgroup_get_kmem_cache(struct kmem_cache *cachep, gfp_t gfp) { if (mem_cgroup_kmem_on && current->mm && !in_interrupt()) return __mem_cgroup_get_kmem_cache(cachep, gfp); return cachep; } -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755249Ab2EBPm7 (ORCPT ); Wed, 2 May 2012 11:42:59 -0400 Received: from mx2.parallels.com ([64.131.90.16]:43388 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752806Ab2EBPm6 (ORCPT ); Wed, 2 May 2012 11:42:58 -0400 Message-ID: <4FA15575.6020209@parallels.com> Date: Wed, 2 May 2012 12:40:37 -0300 From: Glauber Costa User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: Suleiman Souhlal CC: , , , , , Michal Hocko , "Johannes Weiner" , , Greg Thelen , Christoph Lameter , Pekka Enberg Subject: Re: [PATCH 19/23] slab: per-memcg accounting of slab caches References: <1334959051-18203-1-git-send-email-glommer@parallels.com> <1335138820-26590-8-git-send-email-glommer@parallels.com> In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [201.82.19.44] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> @@ -3834,11 +3866,15 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp, >> */ >> void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) >> { >> - void *ret = __cache_alloc(cachep, flags, __builtin_return_address(0)); >> + void *ret; >> + >> + rcu_read_lock(); >> + cachep = mem_cgroup_get_kmem_cache(cachep, flags); >> + rcu_read_unlock(); > > Don't we need to check in_interrupt(), current, __GFP_NOFAIL every > time we call mem_cgroup_cgroup_get_kmem_cache()? > > I would personally prefer if those checks were put inside > mem_cgroup_get_kmem_cache() instead of having to check for every > caller. > in_interrupt() yes, __GFP_NOFAIL I don't think so. __GFP_NOFAIL should lead to a res_counter_charge_nofail() in the end. The name similarity is no coincidence... From a code style PoV, it makes sense to bundle an in_interrupt() check here, but from a performance PoV, putting it in the callers can help us avoid the price of a function call. But well, looking at the code, I see it is not there as well... =( I plan to change memcontrol.h to look like this: static __always_inline struct kmem_cache * mem_cgroup_get_kmem_cache(struct kmem_cache *cachep, gfp_t gfp) { if (mem_cgroup_kmem_on && current->mm && !in_interrupt()) return __mem_cgroup_get_kmem_cache(cachep, gfp); return cachep; }