linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pekka J Enberg <penberg@cs.helsinki.fi>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <clameter@sgi.com>,
	linux-mm@kvack.org, Mel Gorman <mel@skynet.ie>,
	andi@firstfloor.org, Nick Piggin <npiggin@suse.de>,
	Rik van Riel <riel@redhat.com>
Subject: Re: [patch 01/18] SLUB: Add defrag_ratio field and sysfs support.
Date: Tue, 8 Apr 2008 21:55:05 +0300 (EEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0804082154180.8437@sbz-30.cs.Helsinki.FI> (raw)
In-Reply-To: <20080407231052.eb37a8fd.akpm@linux-foundation.org>

On Fri, 04 Apr 2008 16:01:59 -0700 Christoph Lameter <clameter@sgi.com> wrote:
> > +static ssize_t defrag_ratio_store(struct kmem_cache *s,
> > +				const char *buf, size_t length)
> > +{
> > +	int n = simple_strtoul(buf, NULL, 10);

On Mon, 7 Apr 2008, Andrew Morton wrote:
> WARNING: consider using strict_strtoul in preference to simple_strtoul
> #99: FILE: mm/slub.c:4038:
> +       int n = simple_strtoul(buf, NULL, 10);
> 
> total: 0 errors, 1 warnings, 49 lines checked
> 
> 
> It speaketh truth.

I fixed that up, thanks!

			Pekka

From: Christoph Lameter <clameter@sgi.com>
Subject: [PATCH] SLUB: Add defrag_ratio field and sysfs support.

The defrag_ratio is used to set the threshold at which defragmentation
should be run on a slabcache.

The allocation ratio is measured in the percentage of the available slots
allocated. The percentage will be lower for slabs that are more fragmented.

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 <riel@redhat.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
 include/linux/slub_def.h |    7 +++++++
 mm/slub.c                |   18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

Index: slab-2.6/include/linux/slub_def.h
===================================================================
--- slab-2.6.orig/include/linux/slub_def.h	2008-04-08 21:43:24.000000000 +0300
+++ slab-2.6/include/linux/slub_def.h	2008-04-08 21:44:03.000000000 +0300
@@ -88,6 +88,13 @@
 	void (*ctor)(struct kmem_cache *, 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: slab-2.6/mm/slub.c
===================================================================
--- slab-2.6.orig/mm/slub.c	2008-04-08 21:43:37.000000000 +0300
+++ slab-2.6/mm/slub.c	2008-04-08 21:51:43.000000000 +0300
@@ -2332,6 +2332,7 @@
 		goto error;
 
 	s->refcount = 1;
+	s->defrag_ratio = 30;
 #ifdef CONFIG_NUMA
 	s->remote_node_defrag_ratio = 100;
 #endif
@@ -4025,6 +4026,27 @@
 }
 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)
 {
@@ -4126,6 +4148,7 @@
 	&shrink_attr.attr,
 	&alloc_calls_attr.attr,
 	&free_calls_attr.attr,
+	&defrag_ratio_attr.attr,
 #ifdef CONFIG_ZONE_DMA
 	&cache_dma_attr.attr,
 #endif

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2008-04-08 18:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080404230158.365359425@sgi.com>
     [not found] ` <20080404230229.401345769@sgi.com>
2008-04-08  6:13   ` [patch 16/18] FS: Socket inode defragmentation Andrew Morton
     [not found] ` <20080404230225.862960359@sgi.com>
     [not found]   ` <20080407231052.eb37a8fd.akpm@linux-foundation.org>
2008-04-08 18:55     ` Pekka J Enberg [this message]
     [not found] ` <20080404230226.340749825@sgi.com>
     [not found]   ` <20080407231059.e8c173fa.akpm@linux-foundation.org>
2008-04-08 19:07     ` [patch 03/18] SLUB: Add get() and kick() methods Pekka J Enberg
     [not found] ` <20080404230226.577197795@sgi.com>
     [not found]   ` <20080407231113.855e2ba3.akpm@linux-foundation.org>
2008-04-08 19:18     ` [patch 04/18] SLUB: Sort slab cache list and establish maximum objects for defrag slabs Pekka Enberg
2008-04-08 21:01     ` Christoph Lameter
2008-04-08 21:07       ` Andi Kleen
     [not found]     ` <84144f020804072317g5b2b9f42yb300cad9a4258a15@mail.gmail.com>
     [not found]       ` <20080407233001.3e1e5147.akpm@linux-foundation.org>
2008-04-10 16:17         ` Pekka Enberg
     [not found] ` <20080404230226.847485429@sgi.com>
     [not found]   ` <20080407231129.3c044ba1.akpm@linux-foundation.org>
2008-04-08 21:02     ` [patch 05/18] SLUB: Slab defrag core Christoph Lameter
2008-04-08 21:11       ` Andrew Morton
2008-04-08 21:17         ` Christoph Lameter
2008-04-08 21:25           ` Andrew Morton
2008-04-08 21:47             ` Christoph Lameter
2008-04-10 18:28               ` Christoph Lameter
2008-04-10 19:00                 ` Andrew Morton
2008-04-10 20:33                   ` Christoph Lameter
2008-04-10 20:49                     ` Pekka Enberg
     [not found] ` <20080404230227.768964864@sgi.com>
     [not found]   ` <20080407231137.6e3a38cd.akpm@linux-foundation.org>
2008-04-08 21:05     ` [patch 09/18] SLUB: Trigger defragmentation from memory reclaim Christoph Lameter
     [not found] ` <20080404230229.678047976@sgi.com>
     [not found]   ` <20080407231402.63284bb5.akpm@linux-foundation.org>
2008-04-08 21:09     ` [patch 17/18] dentries: Add constructor Christoph Lameter
     [not found] ` <20080404230229.922470579@sgi.com>
     [not found]   ` <20080407231434.88352977.akpm@linux-foundation.org>
2008-04-08 21:14     ` [patch 18/18] dentries: dentry defragmentation Christoph Lameter
2008-04-08 21:22       ` Andrew Morton
2008-04-08 21:41         ` Christoph Lameter
     [not found] ` <20080404230229.169327879@sgi.com>
     [not found]   ` <20080407231346.8a17d27d.akpm@linux-foundation.org>
2008-04-13 13:39     ` RIP __kmem_cache_shrink (was Re: [patch 15/18] FS: Proc filesystem support for slab defrag) Alexey Dobriyan
2008-04-14 19:41       ` Christoph Lameter
2008-04-14 20:12         ` Alexey Dobriyan
2008-04-14 20:36           ` Pekka Enberg
     [not found] ` <20080404230228.523868817@sgi.com>
     [not found]   ` <20080407231341.ac45cd9d.akpm@linux-foundation.org>
2008-05-08  3:49     ` [patch 12/18] FS: ExtX filesystem defrag Christoph Lameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0804082154180.8437@sbz-30.cs.Helsinki.FI \
    --to=penberg@cs.helsinki.fi \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=clameter@sgi.com \
    --cc=linux-mm@kvack.org \
    --cc=mel@skynet.ie \
    --cc=npiggin@suse.de \
    --cc=riel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).