From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx146.postini.com [74.125.245.146]) by kanga.kvack.org (Postfix) with SMTP id 566A06B0069 for ; Wed, 19 Sep 2012 03:49:16 -0400 (EDT) Message-ID: <5059777E.8060906@parallels.com> Date: Wed, 19 Sep 2012 11:42:54 +0400 From: Glauber Costa MIME-Version: 1.0 Subject: Re: [PATCH v3 09/16] sl[au]b: always get the cache from its page in kfree References: <1347977530-29755-1-git-send-email-glommer@parallels.com> <1347977530-29755-10-git-send-email-glommer@parallels.com> <00000139d9fe8595-8905906d-18ed-4d41-afdb-f4c632c2d50a-000000@email.amazonses.com> In-Reply-To: <00000139d9fe8595-8905906d-18ed-4d41-afdb-f4c632c2d50a-000000@email.amazonses.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Christoph Lameter Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, kamezawa.hiroyu@jp.fujitsu.com, devel@openvz.org, Tejun Heo , linux-mm@kvack.org, Suleiman Souhlal , Frederic Weisbecker , Mel Gorman , David Rientjes , Pekka Enberg On 09/18/2012 07:28 PM, Christoph Lameter wrote: > On Tue, 18 Sep 2012, Glauber Costa wrote: > >> index f2d760c..18de3f6 100644 >> --- a/mm/slab.c >> +++ b/mm/slab.c >> @@ -3938,9 +3938,12 @@ EXPORT_SYMBOL(__kmalloc); >> * Free an object which was previously allocated from this >> * cache. >> */ >> -void kmem_cache_free(struct kmem_cache *cachep, void *objp) >> +void kmem_cache_free(struct kmem_cache *s, void *objp) >> { >> unsigned long flags; >> + struct kmem_cache *cachep = virt_to_cache(objp); >> + >> + VM_BUG_ON(!slab_equal_or_parent(cachep, s)); >> > > This is an extremely hot path of the kernel and you are adding significant > processing. Check how the benchmarks are influenced by this change. > virt_to_cache can be a bit expensive. > Would it be enough for you to have a separate code path for !CONFIG_MEMCG_KMEM? I don't really see another way to do it, aside from deriving the cache from the object in our case. I am open to suggestions if you do. >> diff --git a/mm/slub.c b/mm/slub.c >> index 4778548..a045dfc 100644 >> --- a/mm/slub.c >> +++ b/mm/slub.c >> @@ -2604,7 +2604,9 @@ void kmem_cache_free(struct kmem_cache *s, void *x) >> >> page = virt_to_head_page(x); >> >> - slab_free(s, page, x, _RET_IP_); >> + VM_BUG_ON(!slab_equal_or_parent(page->slab, s)); >> + >> + slab_free(page->slab, page, x, _RET_IP_); >> > > Less of a problem here but you are eroding one advantage that slab has had > in the past over slub in terms of freeing objects. > likewise. -- 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