From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932782Ab2IUJd0 (ORCPT ); Fri, 21 Sep 2012 05:33:26 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:50352 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757143Ab2IUJdY (ORCPT ); Fri, 21 Sep 2012 05:33:24 -0400 MIME-Version: 1.0 In-Reply-To: <5059777E.8060906@parallels.com> 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> <5059777E.8060906@parallels.com> Date: Fri, 21 Sep 2012 12:33:23 +0300 X-Google-Sender-Auth: JiMmHb1Bdoiyn4Jml0vV_rr2vCY Message-ID: Subject: Re: [PATCH v3 09/16] sl[au]b: always get the cache from its page in kfree From: Pekka Enberg To: Glauber Costa Cc: Christoph Lameter , 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 , Ingo Molnar , Steven Rostedt Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 19, 2012 at 10:42 AM, 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. We should assume that most distributions enable CONFIG_MEMCG_KMEM, right? Therfore, any performance impact should be dependent on whether or not kmem memcg is *enabled* at runtime or not. Can we use the "static key" thingy introduced by tracing folks for this?