From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: Re: [PATCH] memcg: don't initialize kmem-cache destroying work for root caches Date: Wed, 29 May 2013 08:18:00 +0530 Message-ID: <51A56C60.9030306@parallels.com> References: <1368535118-27369-1-git-send-email-avagin@openvz.org> <20130528155326.0a8b66a7711746e827d5fdea@linux-foundation.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130528155326.0a8b66a7711746e827d5fdea-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Andrew Morton Cc: Andrey Vagin , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Konstantin Khlebnikov , Johannes Weiner , Michal Hocko , Balbir Singh , KAMEZAWA Hiroyuki On 05/29/2013 04:23 AM, Andrew Morton wrote: > On Tue, 14 May 2013 16:38:38 +0400 Andrey Vagin wrote: > >> struct memcg_cache_params has a union. Different parts of this union are >> used for root and non-root caches. A part with destroying work is used only >> for non-root caches. > > That union is a bit dangerous. Perhaps it would be better to do > something like > > --- a/include/linux/slab.h~a > +++ a/include/linux/slab.h > @@ -337,15 +337,17 @@ static __always_inline int kmalloc_size( > struct memcg_cache_params { > bool is_root_cache; > union { > - struct kmem_cache *memcg_caches[0]; > - struct { > + struct memcg_root_cache { > + struct kmem_cache *caches[0]; > + } memcg_root_cache; > + struct memcg_child_cache { > struct mem_cgroup *memcg; > struct list_head list; > struct kmem_cache *root_cache; > bool dead; > atomic_t nr_pages; > struct work_struct destroy; > - }; > + } memcg_child_cache; > }; > }; > > And then adopt the convention of selecting either memcg_root_cache or > memcg_child_cache at the highest level then passing the more strongly > typed pointer to callees. > Since it is already creating problems, yes, I agree. I will try to cook up something soon. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx150.postini.com [74.125.245.150]) by kanga.kvack.org (Postfix) with SMTP id CD2296B0089 for ; Tue, 28 May 2013 22:47:14 -0400 (EDT) Message-ID: <51A56C60.9030306@parallels.com> Date: Wed, 29 May 2013 08:18:00 +0530 From: Glauber Costa MIME-Version: 1.0 Subject: Re: [PATCH] memcg: don't initialize kmem-cache destroying work for root caches References: <1368535118-27369-1-git-send-email-avagin@openvz.org> <20130528155326.0a8b66a7711746e827d5fdea@linux-foundation.org> In-Reply-To: <20130528155326.0a8b66a7711746e827d5fdea@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Andrey Vagin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, Konstantin Khlebnikov , Johannes Weiner , Michal Hocko , Balbir Singh , KAMEZAWA Hiroyuki On 05/29/2013 04:23 AM, Andrew Morton wrote: > On Tue, 14 May 2013 16:38:38 +0400 Andrey Vagin wrote: > >> struct memcg_cache_params has a union. Different parts of this union are >> used for root and non-root caches. A part with destroying work is used only >> for non-root caches. > > That union is a bit dangerous. Perhaps it would be better to do > something like > > --- a/include/linux/slab.h~a > +++ a/include/linux/slab.h > @@ -337,15 +337,17 @@ static __always_inline int kmalloc_size( > struct memcg_cache_params { > bool is_root_cache; > union { > - struct kmem_cache *memcg_caches[0]; > - struct { > + struct memcg_root_cache { > + struct kmem_cache *caches[0]; > + } memcg_root_cache; > + struct memcg_child_cache { > struct mem_cgroup *memcg; > struct list_head list; > struct kmem_cache *root_cache; > bool dead; > atomic_t nr_pages; > struct work_struct destroy; > - }; > + } memcg_child_cache; > }; > }; > > And then adopt the convention of selecting either memcg_root_cache or > memcg_child_cache at the highest level then passing the more strongly > typed pointer to callees. > Since it is already creating problems, yes, I agree. I will try to cook up something soon. -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759443Ab3E2CrP (ORCPT ); Tue, 28 May 2013 22:47:15 -0400 Received: from mx2.parallels.com ([199.115.105.18]:56908 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759366Ab3E2CrN (ORCPT ); Tue, 28 May 2013 22:47:13 -0400 Message-ID: <51A56C60.9030306@parallels.com> Date: Wed, 29 May 2013 08:18:00 +0530 From: Glauber Costa User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 MIME-Version: 1.0 To: Andrew Morton CC: Andrey Vagin , , , , Konstantin Khlebnikov , Johannes Weiner , Michal Hocko , Balbir Singh , KAMEZAWA Hiroyuki Subject: Re: [PATCH] memcg: don't initialize kmem-cache destroying work for root caches References: <1368535118-27369-1-git-send-email-avagin@openvz.org> <20130528155326.0a8b66a7711746e827d5fdea@linux-foundation.org> In-Reply-To: <20130528155326.0a8b66a7711746e827d5fdea@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [175.100.147.64] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/29/2013 04:23 AM, Andrew Morton wrote: > On Tue, 14 May 2013 16:38:38 +0400 Andrey Vagin wrote: > >> struct memcg_cache_params has a union. Different parts of this union are >> used for root and non-root caches. A part with destroying work is used only >> for non-root caches. > > That union is a bit dangerous. Perhaps it would be better to do > something like > > --- a/include/linux/slab.h~a > +++ a/include/linux/slab.h > @@ -337,15 +337,17 @@ static __always_inline int kmalloc_size( > struct memcg_cache_params { > bool is_root_cache; > union { > - struct kmem_cache *memcg_caches[0]; > - struct { > + struct memcg_root_cache { > + struct kmem_cache *caches[0]; > + } memcg_root_cache; > + struct memcg_child_cache { > struct mem_cgroup *memcg; > struct list_head list; > struct kmem_cache *root_cache; > bool dead; > atomic_t nr_pages; > struct work_struct destroy; > - }; > + } memcg_child_cache; > }; > }; > > And then adopt the convention of selecting either memcg_root_cache or > memcg_child_cache at the highest level then passing the more strongly > typed pointer to callees. > Since it is already creating problems, yes, I agree. I will try to cook up something soon.