diff options
author | Christoph Lameter <clameter@sgi.com> | 2007-07-17 07:03:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 13:23:01 -0400 |
commit | 81cda6626178cd55297831296ba8ecedbfd8b52d (patch) | |
tree | fa35a6a04db63080bbeb42f33f4b4a891b7fc96c /mm | |
parent | ce15fea8274acca06daa1674322d37a7d3f0036b (diff) |
Slab allocators: Cleanup zeroing allocations
It becomes now easy to support the zeroing allocs with generic inline
functions in slab.h. Provide inline definitions to allow the continued use of
kzalloc, kmem_cache_zalloc etc but remove other definitions of zeroing
functions from the slab allocators and util.c.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
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.c | 17 | ||||
-rw-r--r-- | mm/slob.c | 10 | ||||
-rw-r--r-- | mm/slub.c | 11 | ||||
-rw-r--r-- | mm/util.c | 14 |
4 files changed, 0 insertions, 52 deletions
@@ -3590,23 +3590,6 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags) | |||
3590 | EXPORT_SYMBOL(kmem_cache_alloc); | 3590 | EXPORT_SYMBOL(kmem_cache_alloc); |
3591 | 3591 | ||
3592 | /** | 3592 | /** |
3593 | * kmem_cache_zalloc - Allocate an object. The memory is set to zero. | ||
3594 | * @cache: The cache to allocate from. | ||
3595 | * @flags: See kmalloc(). | ||
3596 | * | ||
3597 | * Allocate an object from this cache and set the allocated memory to zero. | ||
3598 | * The flags are only relevant if the cache has no available objects. | ||
3599 | */ | ||
3600 | void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags) | ||
3601 | { | ||
3602 | void *ret = __cache_alloc(cache, flags, __builtin_return_address(0)); | ||
3603 | if (ret) | ||
3604 | memset(ret, 0, obj_size(cache)); | ||
3605 | return ret; | ||
3606 | } | ||
3607 | EXPORT_SYMBOL(kmem_cache_zalloc); | ||
3608 | |||
3609 | /** | ||
3610 | * kmem_ptr_validate - check if an untrusted pointer might | 3593 | * kmem_ptr_validate - check if an untrusted pointer might |
3611 | * be a slab entry. | 3594 | * be a slab entry. |
3612 | * @cachep: the cache we're checking against | 3595 | * @cachep: the cache we're checking against |
@@ -543,16 +543,6 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node) | |||
543 | } | 543 | } |
544 | EXPORT_SYMBOL(kmem_cache_alloc_node); | 544 | EXPORT_SYMBOL(kmem_cache_alloc_node); |
545 | 545 | ||
546 | void *kmem_cache_zalloc(struct kmem_cache *c, gfp_t flags) | ||
547 | { | ||
548 | void *ret = kmem_cache_alloc(c, flags); | ||
549 | if (ret) | ||
550 | memset(ret, 0, c->size); | ||
551 | |||
552 | return ret; | ||
553 | } | ||
554 | EXPORT_SYMBOL(kmem_cache_zalloc); | ||
555 | |||
556 | static void __kmem_cache_free(void *b, int size) | 546 | static void __kmem_cache_free(void *b, int size) |
557 | { | 547 | { |
558 | if (size < PAGE_SIZE) | 548 | if (size < PAGE_SIZE) |
@@ -2706,17 +2706,6 @@ err: | |||
2706 | } | 2706 | } |
2707 | EXPORT_SYMBOL(kmem_cache_create); | 2707 | EXPORT_SYMBOL(kmem_cache_create); |
2708 | 2708 | ||
2709 | void *kmem_cache_zalloc(struct kmem_cache *s, gfp_t flags) | ||
2710 | { | ||
2711 | void *x; | ||
2712 | |||
2713 | x = slab_alloc(s, flags, -1, __builtin_return_address(0)); | ||
2714 | if (x) | ||
2715 | memset(x, 0, s->objsize); | ||
2716 | return x; | ||
2717 | } | ||
2718 | EXPORT_SYMBOL(kmem_cache_zalloc); | ||
2719 | |||
2720 | #ifdef CONFIG_SMP | 2709 | #ifdef CONFIG_SMP |
2721 | /* | 2710 | /* |
2722 | * Use the cpu notifier to insure that the cpu slabs are flushed when | 2711 | * Use the cpu notifier to insure that the cpu slabs are flushed when |
@@ -5,20 +5,6 @@ | |||
5 | #include <asm/uaccess.h> | 5 | #include <asm/uaccess.h> |
6 | 6 | ||
7 | /** | 7 | /** |
8 | * __kzalloc - allocate memory. The memory is set to zero. | ||
9 | * @size: how many bytes of memory are required. | ||
10 | * @flags: the type of memory to allocate. | ||
11 | */ | ||
12 | void *__kzalloc(size_t size, gfp_t flags) | ||
13 | { | ||
14 | void *ret = kmalloc_track_caller(size, flags); | ||
15 | if (ret) | ||
16 | memset(ret, 0, size); | ||
17 | return ret; | ||
18 | } | ||
19 | EXPORT_SYMBOL(__kzalloc); | ||
20 | |||
21 | /* | ||
22 | * kstrdup - allocate space for and copy an existing string | 8 | * kstrdup - allocate space for and copy an existing string |
23 | * | 9 | * |
24 | * @s: the string to duplicate | 10 | * @s: the string to duplicate |