aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAndrzej Hajda <a.hajda@samsung.com>2015-02-13 17:36:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:36 -0500
commit3dec16ea38afce38ceb49c8938901318797a08c4 (patch)
treed40b51012496854360bc3292675cc3520ac4cbef /mm
parent612936f21277d1254dd885de2e383aacdc7ca67f (diff)
mm/slab: convert cache name allocations to kstrdup_const
slab frequently performs duplication of strings located in read-only memory section. Replacing kstrdup by kstrdup_const allows to avoid such operations. [akpm@linux-foundation.org: make the handling of kmem_cache.name const-correct] Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Mike Turquette <mturquette@linaro.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Tejun Heo <tj@kernel.org> Cc: Greg KH <greg@kroah.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/slab_common.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 1a1cc89acaa3..429a4506b382 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -295,8 +295,8 @@ unsigned long calculate_alignment(unsigned long flags,
295} 295}
296 296
297static struct kmem_cache * 297static struct kmem_cache *
298do_kmem_cache_create(char *name, size_t object_size, size_t size, size_t align, 298do_kmem_cache_create(const char *name, size_t object_size, size_t size,
299 unsigned long flags, void (*ctor)(void *), 299 size_t align, unsigned long flags, void (*ctor)(void *),
300 struct mem_cgroup *memcg, struct kmem_cache *root_cache) 300 struct mem_cgroup *memcg, struct kmem_cache *root_cache)
301{ 301{
302 struct kmem_cache *s; 302 struct kmem_cache *s;
@@ -363,7 +363,7 @@ kmem_cache_create(const char *name, size_t size, size_t align,
363 unsigned long flags, void (*ctor)(void *)) 363 unsigned long flags, void (*ctor)(void *))
364{ 364{
365 struct kmem_cache *s; 365 struct kmem_cache *s;
366 char *cache_name; 366 const char *cache_name;
367 int err; 367 int err;
368 368
369 get_online_cpus(); 369 get_online_cpus();
@@ -390,7 +390,7 @@ kmem_cache_create(const char *name, size_t size, size_t align,
390 if (s) 390 if (s)
391 goto out_unlock; 391 goto out_unlock;
392 392
393 cache_name = kstrdup(name, GFP_KERNEL); 393 cache_name = kstrdup_const(name, GFP_KERNEL);
394 if (!cache_name) { 394 if (!cache_name) {
395 err = -ENOMEM; 395 err = -ENOMEM;
396 goto out_unlock; 396 goto out_unlock;
@@ -401,7 +401,7 @@ kmem_cache_create(const char *name, size_t size, size_t align,
401 flags, ctor, NULL, NULL); 401 flags, ctor, NULL, NULL);
402 if (IS_ERR(s)) { 402 if (IS_ERR(s)) {
403 err = PTR_ERR(s); 403 err = PTR_ERR(s);
404 kfree(cache_name); 404 kfree_const(cache_name);
405 } 405 }
406 406
407out_unlock: 407out_unlock:
@@ -607,7 +607,7 @@ void memcg_destroy_kmem_caches(struct mem_cgroup *memcg)
607void slab_kmem_cache_release(struct kmem_cache *s) 607void slab_kmem_cache_release(struct kmem_cache *s)
608{ 608{
609 destroy_memcg_params(s); 609 destroy_memcg_params(s);
610 kfree(s->name); 610 kfree_const(s->name);
611 kmem_cache_free(kmem_cache, s); 611 kmem_cache_free(kmem_cache, s);
612} 612}
613 613