All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Lameter <cl@linux.com>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Cc: David Rientjes <rientjes@google.com>
Subject: [UnifiedV4 14/16] slub: Reduce size of not performance critical slabs
Date: Tue, 05 Oct 2010 13:57:39 -0500	[thread overview]
Message-ID: <20101005185819.929054093@linux.com> (raw)
In-Reply-To: 20101005185725.088808842@linux.com

[-- Attachment #1: unified_reduce --]
[-- Type: text/plain, Size: 3801 bytes --]

There are some slab caches around that are rarely used and which are not
performance critical. Add a new SLAB_LOWMEM option to reduce the memory
requirements of such slabs. SLAB_LOWMEM caches will keep no empty slabs
around, have no shared or alien caches and will have a small per cpu
queue of 5 objects.

Signed-off-by: Christoph Lameter <cl@linux.com>

---
 include/linux/slab.h |    2 ++
 mm/slub.c            |   25 ++++++++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)

Index: linux-2.6/include/linux/slab.h
===================================================================
--- linux-2.6.orig/include/linux/slab.h	2010-10-05 13:40:04.000000000 -0500
+++ linux-2.6/include/linux/slab.h	2010-10-05 13:40:08.000000000 -0500
@@ -17,12 +17,14 @@
  * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
  */
 #define SLAB_DEBUG_FREE		0x00000100UL	/* DEBUG: Perform (expensive) checks on free */
+#define SLAB_LOWMEM		0x00000200UL	/* Reduce memory usage of this slab */
 #define SLAB_RED_ZONE		0x00000400UL	/* DEBUG: Red zone objs in a cache */
 #define SLAB_POISON		0x00000800UL	/* DEBUG: Poison objects */
 #define SLAB_HWCACHE_ALIGN	0x00002000UL	/* Align objs on cache lines */
 #define SLAB_CACHE_DMA		0x00004000UL	/* Use GFP_DMA memory */
 #define SLAB_STORE_USER		0x00010000UL	/* DEBUG: Store the last owner for bug hunting */
 #define SLAB_PANIC		0x00040000UL	/* Panic if kmem_cache_create() fails */
+
 /*
  * SLAB_DESTROY_BY_RCU - **WARNING** READ THIS!
  *
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c	2010-10-05 13:40:04.000000000 -0500
+++ linux-2.6/mm/slub.c	2010-10-05 13:40:08.000000000 -0500
@@ -2829,12 +2829,20 @@ static int kmem_cache_open(struct kmem_c
 	 * The larger the object size is, the more pages we want on the partial
 	 * list to avoid pounding the page allocator excessively.
 	 */
-	set_min_partial(s, ilog2(s->size));
+	if (flags & SLAB_LOWMEM)
+		set_min_partial(s, 0);
+	else
+		set_min_partial(s, ilog2(s->size));
+
 	s->refcount = 1;
 	if (!init_kmem_cache_nodes(s))
 		goto error;
 
-	s->queue = initial_queue_size(s->size);
+	if (flags & SLAB_LOWMEM)
+		s->queue = 5;
+	else
+		s->queue = initial_queue_size(s->size);
+
 	s->batch = (s->queue + 1) / 2;
 
 #ifdef CONFIG_NUMA
@@ -2879,7 +2887,9 @@ static int kmem_cache_open(struct kmem_c
 
 	if (alloc_kmem_cache_cpus(s)) {
 		s->shared_queue_sysfs = 0;
-		if (nr_cpu_ids > 1 && s->size < PAGE_SIZE) {
+		if (!(flags & SLAB_LOWMEM) &&
+				nr_cpu_ids > 1 &&
+				s->size < PAGE_SIZE) {
 			s->shared_queue_sysfs = 10 * s->batch;
 			alloc_shared_caches(s);
 		}
@@ -3788,7 +3798,7 @@ void __init kmem_cache_init(void)
 
 	kmem_cache_open(kmem_cache_node, "kmem_cache_node",
 		sizeof(struct kmem_cache_node),
-		0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
+		0, SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_LOWMEM, NULL);
 
 	hotplug_memory_notifier(slab_memory_callback, SLAB_CALLBACK_PRI);
 
@@ -3797,7 +3807,7 @@ void __init kmem_cache_init(void)
 
 	temp_kmem_cache = kmem_cache;
 	kmem_cache_open(kmem_cache, "kmem_cache", kmem_size,
-		0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
+		0, SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_LOWMEM, NULL);
 	kmem_cache = kmem_cache_alloc(kmem_cache, GFP_NOWAIT);
 	memcpy(kmem_cache, temp_kmem_cache, kmem_size);
 
@@ -3906,12 +3916,9 @@ void __init kmem_cache_init(void)
 		if (s && s->size) {
 			char *name = kasprintf(GFP_NOWAIT,
 				 "dma-kmalloc-%d", s->objsize);
-
 			BUG_ON(!name);
 			kmalloc_dma_caches[i] = create_kmalloc_cache(name,
-				s->objsize, SLAB_CACHE_DMA);
-			 /* DMA caches are rarely used. Reduce memory consumption */
-			kmalloc_dma_caches[i]->shared_queue_sysfs = 0;
+				s->objsize, SLAB_CACHE_DMA | SLAB_LOWMEM);
 		}
 	}
 #endif


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Lameter <cl@linux.com>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	David Rientjes <rientjes@google.com>
Subject: [UnifiedV4 14/16] slub: Reduce size of not performance critical slabs
Date: Tue, 05 Oct 2010 13:57:39 -0500	[thread overview]
Message-ID: <20101005185819.929054093@linux.com> (raw)
In-Reply-To: 20101005185725.088808842@linux.com

[-- Attachment #1: unified_reduce --]
[-- Type: text/plain, Size: 4026 bytes --]

There are some slab caches around that are rarely used and which are not
performance critical. Add a new SLAB_LOWMEM option to reduce the memory
requirements of such slabs. SLAB_LOWMEM caches will keep no empty slabs
around, have no shared or alien caches and will have a small per cpu
queue of 5 objects.

Signed-off-by: Christoph Lameter <cl@linux.com>

---
 include/linux/slab.h |    2 ++
 mm/slub.c            |   25 ++++++++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)

Index: linux-2.6/include/linux/slab.h
===================================================================
--- linux-2.6.orig/include/linux/slab.h	2010-10-05 13:40:04.000000000 -0500
+++ linux-2.6/include/linux/slab.h	2010-10-05 13:40:08.000000000 -0500
@@ -17,12 +17,14 @@
  * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
  */
 #define SLAB_DEBUG_FREE		0x00000100UL	/* DEBUG: Perform (expensive) checks on free */
+#define SLAB_LOWMEM		0x00000200UL	/* Reduce memory usage of this slab */
 #define SLAB_RED_ZONE		0x00000400UL	/* DEBUG: Red zone objs in a cache */
 #define SLAB_POISON		0x00000800UL	/* DEBUG: Poison objects */
 #define SLAB_HWCACHE_ALIGN	0x00002000UL	/* Align objs on cache lines */
 #define SLAB_CACHE_DMA		0x00004000UL	/* Use GFP_DMA memory */
 #define SLAB_STORE_USER		0x00010000UL	/* DEBUG: Store the last owner for bug hunting */
 #define SLAB_PANIC		0x00040000UL	/* Panic if kmem_cache_create() fails */
+
 /*
  * SLAB_DESTROY_BY_RCU - **WARNING** READ THIS!
  *
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c	2010-10-05 13:40:04.000000000 -0500
+++ linux-2.6/mm/slub.c	2010-10-05 13:40:08.000000000 -0500
@@ -2829,12 +2829,20 @@ static int kmem_cache_open(struct kmem_c
 	 * The larger the object size is, the more pages we want on the partial
 	 * list to avoid pounding the page allocator excessively.
 	 */
-	set_min_partial(s, ilog2(s->size));
+	if (flags & SLAB_LOWMEM)
+		set_min_partial(s, 0);
+	else
+		set_min_partial(s, ilog2(s->size));
+
 	s->refcount = 1;
 	if (!init_kmem_cache_nodes(s))
 		goto error;
 
-	s->queue = initial_queue_size(s->size);
+	if (flags & SLAB_LOWMEM)
+		s->queue = 5;
+	else
+		s->queue = initial_queue_size(s->size);
+
 	s->batch = (s->queue + 1) / 2;
 
 #ifdef CONFIG_NUMA
@@ -2879,7 +2887,9 @@ static int kmem_cache_open(struct kmem_c
 
 	if (alloc_kmem_cache_cpus(s)) {
 		s->shared_queue_sysfs = 0;
-		if (nr_cpu_ids > 1 && s->size < PAGE_SIZE) {
+		if (!(flags & SLAB_LOWMEM) &&
+				nr_cpu_ids > 1 &&
+				s->size < PAGE_SIZE) {
 			s->shared_queue_sysfs = 10 * s->batch;
 			alloc_shared_caches(s);
 		}
@@ -3788,7 +3798,7 @@ void __init kmem_cache_init(void)
 
 	kmem_cache_open(kmem_cache_node, "kmem_cache_node",
 		sizeof(struct kmem_cache_node),
-		0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
+		0, SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_LOWMEM, NULL);
 
 	hotplug_memory_notifier(slab_memory_callback, SLAB_CALLBACK_PRI);
 
@@ -3797,7 +3807,7 @@ void __init kmem_cache_init(void)
 
 	temp_kmem_cache = kmem_cache;
 	kmem_cache_open(kmem_cache, "kmem_cache", kmem_size,
-		0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
+		0, SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_LOWMEM, NULL);
 	kmem_cache = kmem_cache_alloc(kmem_cache, GFP_NOWAIT);
 	memcpy(kmem_cache, temp_kmem_cache, kmem_size);
 
@@ -3906,12 +3916,9 @@ void __init kmem_cache_init(void)
 		if (s && s->size) {
 			char *name = kasprintf(GFP_NOWAIT,
 				 "dma-kmalloc-%d", s->objsize);
-
 			BUG_ON(!name);
 			kmalloc_dma_caches[i] = create_kmalloc_cache(name,
-				s->objsize, SLAB_CACHE_DMA);
-			 /* DMA caches are rarely used. Reduce memory consumption */
-			kmalloc_dma_caches[i]->shared_queue_sysfs = 0;
+				s->objsize, SLAB_CACHE_DMA | SLAB_LOWMEM);
 		}
 	}
 #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:[~2010-10-05 18:59 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05 18:57 [UnifiedV4 00/16] The Unified slab allocator (V4) Christoph Lameter
2010-10-05 18:57 ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 01/16] slub: Enable sysfs support for !CONFIG_SLUB_DEBUG Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-06 14:02   ` Pekka Enberg
2010-10-06 14:02     ` Pekka Enberg
2010-10-05 18:57 ` [UnifiedV4 02/16] slub: Move functions to reduce #ifdefs Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-06 14:02   ` Pekka Enberg
2010-10-06 14:02     ` Pekka Enberg
2010-10-05 18:57 ` [UnifiedV4 03/16] slub: Add per cpu queueing Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 04/16] slub: Allow resizing of per cpu queues Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 05/16] slub: Remove MAX_OBJS limitation Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 06/16] slub: Drop allocator announcement Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 07/16] slub: Object based NUMA policies Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 08/16] slub: Get rid of page lock and rely on per node lock Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 09/16] slub: Shared cache to exploit cross cpu caching abilities Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 10/16] slub: Support Alien Caches Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 11/16] slub: Add a "touched" state to queues and partial lists Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 12/16] slub: Cached object expiration Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 13/16] vmscan: Tie slub object expiration into page reclaim Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` Christoph Lameter [this message]
2010-10-05 18:57   ` [UnifiedV4 14/16] slub: Reduce size of not performance critical slabs Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 15/16] slub: Detailed reports on validate Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-05 18:57 ` [UnifiedV4 16/16] slub: Add stats for alien allocation slowpath Christoph Lameter
2010-10-05 18:57   ` Christoph Lameter
2010-10-06  8:01 ` [UnifiedV4 00/16] The Unified slab allocator (V4) Pekka Enberg
2010-10-06  8:01   ` Pekka Enberg
2010-10-06 11:03   ` Richard Kennedy
2010-10-06 11:03     ` Richard Kennedy
2010-10-06 11:19     ` Pekka Enberg
2010-10-06 11:19       ` Pekka Enberg
2010-10-06 15:46       ` Richard Kennedy
2010-10-06 15:46         ` Richard Kennedy
2010-10-06 16:21         ` [UnifiedV4 slabinfo 1/2] Move slabinfo.c to tools/slub/slabinfo.c Christoph Lameter
2010-10-06 16:21           ` Christoph Lameter
2010-10-06 16:21         ` [UnifiedV4 slabinfo 2/2] slub: update slabinfo.c for queuing Christoph Lameter
2010-10-06 16:21           ` Christoph Lameter
2010-10-06 20:56         ` [UnifiedV4 00/16] The Unified slab allocator (V4) Christoph Lameter
2010-10-06 20:56           ` Christoph Lameter
2010-10-06 16:00     ` Christoph Lameter
2010-10-06 16:00       ` Christoph Lameter
2010-10-06 12:37   ` Wu Fengguang
2010-10-06 12:37     ` Wu Fengguang
2010-10-13  2:21     ` Alex,Shi
2010-10-13  2:21       ` Alex,Shi
2010-10-18 18:00       ` Christoph Lameter
2010-10-18 18:00         ` Christoph Lameter
2010-10-19  0:01         ` Alex,Shi
2010-10-19  0:01           ` Alex,Shi
2010-10-06 15:56   ` Christoph Lameter
2010-10-06 15:56     ` Christoph Lameter
2010-10-13 14:14     ` Mel Gorman
2010-10-13 14:14       ` Mel Gorman
2010-10-18 18:13       ` Christoph Lameter
2010-10-18 18:13         ` Christoph Lameter
2010-10-19  9:23         ` Mel Gorman
2010-10-19  9:23           ` Mel Gorman
2010-10-12 18:25   ` Mel Gorman
2010-10-12 18:25     ` Mel Gorman
2010-10-13  7:16     ` Pekka Enberg
2010-10-13  7:16       ` Pekka Enberg
2010-10-13 13:46       ` Mel Gorman
2010-10-13 13:46         ` Mel Gorman
2010-10-13 16:10     ` Christoph Lameter
2010-10-13 16:10       ` Christoph Lameter
2010-10-06 10:47 ` Andi Kleen
2010-10-06 15:59   ` Christoph Lameter
2010-10-06 16:25     ` Andi Kleen
2010-10-06 16:37       ` Christoph Lameter
2010-10-06 16:43         ` Andi Kleen
2010-10-06 16:49           ` Christoph Lameter
2010-10-06 16:52           ` Christoph Lameter
2010-10-19 20:39 ` David Rientjes
2010-10-19 20:39   ` David Rientjes
2010-10-20 13:47   ` Christoph Lameter
2010-10-20 13:47     ` 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=20101005185819.929054093@linux.com \
    --to=cl@linux.com \
    --cc=linux-mm@kvack.org \
    --cc=penberg@cs.helsinki.fi \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.