From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754007AbYHKPQa (ORCPT ); Mon, 11 Aug 2008 11:16:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752009AbYHKPQU (ORCPT ); Mon, 11 Aug 2008 11:16:20 -0400 Received: from nlpi053.sbcis.sbc.com ([207.115.36.82]:60229 "EHLO nlpi053.prodigy.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752028AbYHKPQT (ORCPT ); Mon, 11 Aug 2008 11:16:19 -0400 Message-Id: <20080811150653.575096604@quilx.com> References: <20080811150616.207532384@quilx.com> User-Agent: quilt/0.46-1 Date: Mon, 11 Aug 2008 08:06:17 -0700 From: Christoph Lameter To: Pekka Enberg CC: akpm@linux-foundation.org, Christoph Lameter , Christoph Lameter Cc: linux-kernel@vger.kernel.org CC: linux-fsdevel@vger.kernel.org Cc: Mel Gorman Cc: andi@firstfloor.org Cc: Rik van Riel Cc: mpm@selenic.com Cc: Dave Chinner Subject: [patch 01/19] slub: Add defrag_ratio field and sysfs support. Content-Disposition: inline; filename=0001-SLUB-Add-defrag_ratio-field-and-sysfs-support.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The defrag_ratio is used to set the threshold at which defragmentation should be attempted on a slab page. The allocation ratio is measured by the percentage of the available slots allocated. Add a defrag ratio field and set it to 30% by default. A limit of 30% specified that less than 3 out of 10 available slots for objects are in use before slab defragmeentation runs. Reviewed-by: Rik van Riel Signed-off-by: Christoph Lameter Signed-off-by: Pekka Enberg Signed-off-by: Christoph Lameter --- include/linux/slub_def.h | 7 +++++++ mm/slub.c | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) Index: linux-next/include/linux/slub_def.h =================================================================== --- linux-next.orig/include/linux/slub_def.h 2008-08-11 07:42:32.301017715 -0700 +++ linux-next/include/linux/slub_def.h 2008-08-11 07:50:11.382348462 -0700 @@ -89,6 +89,13 @@ struct kmem_cache { void (*ctor)(void *); int inuse; /* Offset to metadata */ int align; /* Alignment */ + int defrag_ratio; /* + * Ratio used to check the percentage of + * objects allocate in a slab page. + * If less than this ratio is allocated + * then reclaim attempts are made. + */ + const char *name; /* Name (only for display!) */ struct list_head list; /* List of slab caches */ #ifdef CONFIG_SLUB_DEBUG Index: linux-next/mm/slub.c =================================================================== --- linux-next.orig/mm/slub.c 2008-08-11 07:42:34.392348172 -0700 +++ linux-next/mm/slub.c 2008-08-11 07:50:11.802347432 -0700 @@ -2324,6 +2324,7 @@ static int kmem_cache_open(struct kmem_c goto error; s->refcount = 1; + s->defrag_ratio = 30; #ifdef CONFIG_NUMA s->remote_node_defrag_ratio = 100; #endif @@ -4056,6 +4057,27 @@ static ssize_t free_calls_show(struct km } SLAB_ATTR_RO(free_calls); +static ssize_t defrag_ratio_show(struct kmem_cache *s, char *buf) +{ + return sprintf(buf, "%d\n", s->defrag_ratio); +} + +static ssize_t defrag_ratio_store(struct kmem_cache *s, + const char *buf, size_t length) +{ + unsigned long ratio; + int err; + + err = strict_strtoul(buf, 10, &ratio); + if (err) + return err; + + if (ratio < 100) + s->defrag_ratio = ratio; + return length; +} +SLAB_ATTR(defrag_ratio); + #ifdef CONFIG_NUMA static ssize_t remote_node_defrag_ratio_show(struct kmem_cache *s, char *buf) { @@ -4163,6 +4185,7 @@ static struct attribute *slab_attrs[] = &shrink_attr.attr, &alloc_calls_attr.attr, &free_calls_attr.attr, + &defrag_ratio_attr.attr, #ifdef CONFIG_ZONE_DMA &cache_dma_attr.attr, #endif --