From: Pekka Enberg <penberg@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Pekka Enberg <penberg@kernel.org>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [RFC/PATCH 1/2] slub: Break out alloc_kmem_cache_cpus() from kmem_cache_open()
Date: Mon, 25 Apr 2011 20:46:47 +0300 [thread overview]
Message-ID: <1303753608-19248-1-git-send-email-penberg@kernel.org> (raw)
In preparation for sharing per-CPU structures between merged caches, break out
alloc_kmem_cache_cpus() from kmem_cache_open() function.
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---
mm/slub.c | 37 +++++++++++++++++++++----------------
1 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 94d2a33..cb61024 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2638,11 +2638,7 @@ static int kmem_cache_open(struct kmem_cache *s,
#endif
if (!init_kmem_cache_nodes(s))
goto error;
-
- if (alloc_kmem_cache_cpus(s))
- return 1;
-
- free_kmem_cache_nodes(s);
+ return 1;
error:
if (flags & SLAB_PANIC)
panic("Cannot create slab %s size=%lu realsize=%u "
@@ -2818,6 +2814,9 @@ static struct kmem_cache *__init create_kmalloc_cache(const char *name,
flags, NULL))
goto panic;
+ if (!alloc_kmem_cache_cpus(s))
+ goto panic;
+
list_add(&s->list, &slab_caches);
return s;
@@ -3239,6 +3238,8 @@ void __init kmem_cache_init(void)
sizeof(struct kmem_cache_node),
0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
+ alloc_kmem_cache_cpus(kmem_cache_node);
+
hotplug_memory_notifier(slab_memory_callback, SLAB_CALLBACK_PRI);
/* Able to allocate the per node structures */
@@ -3247,6 +3248,8 @@ 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);
+ alloc_kmem_cache_cpus(kmem_cache);
+
kmem_cache = kmem_cache_alloc(kmem_cache, GFP_NOWAIT);
memcpy(kmem_cache, temp_kmem_cache, kmem_size);
@@ -3469,18 +3472,20 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
s = kmalloc(kmem_size, GFP_KERNEL);
if (s) {
- if (kmem_cache_open(s, n,
- size, align, flags, ctor)) {
- list_add(&s->list, &slab_caches);
- if (sysfs_slab_add(s)) {
- list_del(&s->list);
- kfree(n);
- kfree(s);
- goto err;
- }
- up_write(&slub_lock);
- return s;
+ if (!kmem_cache_open(s, n, size, align, flags, ctor))
+ goto err_free;
+
+ if (!alloc_kmem_cache_cpus(s))
+ goto err_free;
+
+ list_add(&s->list, &slab_caches);
+ if (sysfs_slab_add(s)) {
+ list_del(&s->list);
+ goto err_free;
}
+ up_write(&slub_lock);
+ return s;
+err_free:
kfree(n);
kfree(s);
}
--
1.7.0.4
next reply other threads:[~2011-04-25 17:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-25 17:46 Pekka Enberg [this message]
2011-04-25 17:46 ` [RFC/PATCH 2/2] slub: Don't share struct kmem_cache for shared caches Pekka Enberg
2011-04-25 19:09 ` Christoph Lameter
2011-04-25 19:25 ` Pekka Enberg
2011-04-25 21:08 ` Christoph Lameter
2011-04-25 19:06 ` [RFC/PATCH 1/2] slub: Break out alloc_kmem_cache_cpus() from kmem_cache_open() 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=1303753608-19248-1-git-send-email-penberg@kernel.org \
--to=penberg@kernel.org \
--cc=cl@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
--cc=torvalds@linux-foundation.org \
/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.