* [PATCH 1/8] slub: Add defrag_ratio field and sysfs support.
@ 2008-07-19 12:30 Pekka J Enberg
2008-07-19 17:52 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Pekka J Enberg @ 2008-07-19 12:30 UTC (permalink / raw)
To: linux-kernel, cl, akpm, riel
From: Christoph Lameter <clameter@sgi.com>
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 <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 | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index d117ea2..6f8d25f 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -88,6 +88,13 @@ struct kmem_cache {
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
diff --git a/mm/slub.c b/mm/slub.c
index 35ab38a..1b910ab 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2338,6 +2338,7 @@ static int kmem_cache_open(struct kmem_cache *s, gfp_t gfpflags,
goto error;
s->refcount = 1;
+ s->defrag_ratio = 30;
#ifdef CONFIG_NUMA
s->remote_node_defrag_ratio = 100;
#endif
@@ -4071,6 +4072,27 @@ static ssize_t free_calls_show(struct kmem_cache *s, char *buf)
}
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)
{
@@ -4178,6 +4200,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
--
1.5.4.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 1/8] slub: Add defrag_ratio field and sysfs support.
2008-07-19 12:30 [PATCH 1/8] slub: Add defrag_ratio field and sysfs support Pekka J Enberg
@ 2008-07-19 17:52 ` Andrew Morton
2008-07-20 10:38 ` Pekka Enberg
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2008-07-19 17:52 UTC (permalink / raw)
To: Pekka J Enberg; +Cc: linux-kernel, cl, riel
Were you planning on sending out the patches to wire all this up
to the notorious caches?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/8] slub: Add defrag_ratio field and sysfs support.
2008-07-19 17:52 ` Andrew Morton
@ 2008-07-20 10:38 ` Pekka Enberg
2008-07-21 16:17 ` Christoph Lameter
0 siblings, 1 reply; 5+ messages in thread
From: Pekka Enberg @ 2008-07-20 10:38 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, cl, riel
Hi Andrew,
On Sat, Jul 19, 2008 at 8:52 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> Were you planning on sending out the patches to wire all this up
> to the notorious caches?
No, I wasn't because don't have those patches in my tree (and I
probably don't want them either). Christoph?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/8] slub: Add defrag_ratio field and sysfs support.
2008-07-20 10:38 ` Pekka Enberg
@ 2008-07-21 16:17 ` Christoph Lameter
2008-07-21 21:13 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Lameter @ 2008-07-21 16:17 UTC (permalink / raw)
To: Pekka Enberg; +Cc: Andrew Morton, linux-kernel, riel
Pekka Enberg wrote:
> Hi Andrew,
>
> On Sat, Jul 19, 2008 at 8:52 PM, Andrew Morton
> <akpm@linux-foundation.org> wrote:
>
>> Were you planning on sending out the patches to wire all this up
>> to the notorious caches?
>>
>
> No, I wasn't because don't have those patches in my tree (and I
> probably don't want them either). Christoph?
>
I have those diffed against linux-next from a week ago or so and
rc8-mm1. Want me to post them? Would be good to have a tree to submit
against. rc8-mm1?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/8] slub: Add defrag_ratio field and sysfs support.
2008-07-21 16:17 ` Christoph Lameter
@ 2008-07-21 21:13 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2008-07-21 21:13 UTC (permalink / raw)
To: Christoph Lameter; +Cc: penberg, linux-kernel, riel
On Mon, 21 Jul 2008 11:17:14 -0500
Christoph Lameter <cl@linux-foundation.org> wrote:
> Pekka Enberg wrote:
> > Hi Andrew,
> >
> > On Sat, Jul 19, 2008 at 8:52 PM, Andrew Morton
> > <akpm@linux-foundation.org> wrote:
> >
> >> Were you planning on sending out the patches to wire all this up
> >> to the notorious caches?
> >>
> >
> > No, I wasn't because don't have those patches in my tree (and I
> > probably don't want them either). Christoph?
> >
> I have those diffed against linux-next from a week ago or so and
> rc8-mm1. Want me to post them?
Yes please.
> Would be good to have a tree to submit
> against. rc8-mm1?
I guess so.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-07-21 21:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-19 12:30 [PATCH 1/8] slub: Add defrag_ratio field and sysfs support Pekka J Enberg
2008-07-19 17:52 ` Andrew Morton
2008-07-20 10:38 ` Pekka Enberg
2008-07-21 16:17 ` Christoph Lameter
2008-07-21 21:13 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox