From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753120Ab2HPRIc (ORCPT ); Thu, 16 Aug 2012 13:08:32 -0400 Received: from a194-183.smtp-out.amazonses.com ([199.255.194.183]:39897 "EHLO a194-183.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752426Ab2HPRIY (ORCPT ); Thu, 16 Aug 2012 13:08:24 -0400 Date: Thu, 16 Aug 2012 17:08:23 +0000 From: Christoph Lameter X-X-Sender: cl@gentwo.org To: JoonSoo Kim cc: Pekka Enberg , linux-kernel@vger.kernel.org, linux-mm@kvack.org, David Rientjes Subject: Re: [PATCH] slub: try to get cpu partial slab even if we get enough objects for cpu freelist In-Reply-To: Message-ID: <00000139306844c8-bb717c88-ca56-48b3-9b8f-9186053359d3-000000@email.amazonses.com> References: <1345045084-7292-1-git-send-email-js1304@gmail.com> <000001392af5ab4e-41dbbbe4-5808-484b-900a-6f4eba102376-000000@email.amazonses.com> <000001392b579d4f-bb5ccaf5-1a2c-472c-9b76-05ec86297706-000000@email.amazonses.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SES-Outgoing: 199.255.194.183 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 16 Aug 2012, JoonSoo Kim wrote: > But, if you prefer that s->cpu_partial is for both cpu slab and cpu > partial slab, > get_partial_node() needs an another minor fix. > We should add number of objects in cpu slab when we refill cpu partial slab. > Following is my suggestion. > > @@ -1546,7 +1546,7 @@ static void *get_partial_node(struct kmem_cache *s, > spin_lock(&n->list_lock); > list_for_each_entry_safe(page, page2, &n->partial, lru) { > void *t = acquire_slab(s, n, page, object == NULL); > - int available; > + int available, nr = 0; > > if (!t) > break; > @@ -1557,10 +1557,10 @@ static void *get_partial_node(struct kmem_cache *s, > object = t; > available = page->objects - page->inuse; > } else { > - available = put_cpu_partial(s, page, 0); > + nr = put_cpu_partial(s, page, 0); > stat(s, CPU_PARTIAL_NODE); > } > - if (kmem_cache_debug(s) || available > s->cpu_partial / 2) > + if (kmem_cache_debug(s) || (available + nr) > > s->cpu_partial / 2) > break; > > } > > If you agree with this suggestion, I send a patch for this. What difference does this patch make? At the end of the day you need the total number of objects available in the partial slabs and the cpu slab for comparison.