Commit 55935a34 authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

[PATCH] More slab.h cleanups

More cleanups for slab.h

1. Remove tabs from weird locations as suggested by Pekka

2. Drop the check for NUMA and SLAB_DEBUG from the fallback section
   as suggested by Pekka.

3. Uses static inline for the fallback defs as also suggested by Pekka.

4. Make kmem_ptr_valid take a const * argument.

5. Separate the NUMA fallback definitions from the kmalloc_track fallback
   definitions.
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2e892f43
...@@ -55,7 +55,7 @@ void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); ...@@ -55,7 +55,7 @@ void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
void kmem_cache_free(struct kmem_cache *, void *); void kmem_cache_free(struct kmem_cache *, void *);
unsigned int kmem_cache_size(struct kmem_cache *); unsigned int kmem_cache_size(struct kmem_cache *);
const char *kmem_cache_name(struct kmem_cache *); const char *kmem_cache_name(struct kmem_cache *);
int kmem_ptr_validate(struct kmem_cache *cachep, void *ptr); int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr);
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
...@@ -93,19 +93,15 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags) ...@@ -93,19 +93,15 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
* ways to convert kmalloc() calls to kmem_cache_alloc() invocations by selecting * ways to convert kmalloc() calls to kmem_cache_alloc() invocations by selecting
* the appropriate general cache at compile time. * the appropriate general cache at compile time.
*/ */
#ifdef CONFIG_SLAB #ifdef CONFIG_SLAB
#include <linux/slab_def.h> #include <linux/slab_def.h>
#else #else
/* /*
* Fallback definitions for an allocator not wanting to provide * Fallback definitions for an allocator not wanting to provide
* its own optimized kmalloc definitions (like SLOB). * its own optimized kmalloc definitions (like SLOB).
*/ */
#if defined(CONFIG_NUMA) || defined(CONFIG_DEBUG_SLAB)
#error "SLAB fallback definitions not usable for NUMA or Slab debug"
#endif
/** /**
* kmalloc - allocate memory * kmalloc - allocate memory
* @size: how many bytes of memory are required. * @size: how many bytes of memory are required.
...@@ -151,7 +147,7 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags) ...@@ -151,7 +147,7 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
* *
* %__GFP_REPEAT - If allocation fails initially, try once more before failing. * %__GFP_REPEAT - If allocation fails initially, try once more before failing.
*/ */
void *kmalloc(size_t size, gfp_t flags) static inline void *kmalloc(size_t size, gfp_t flags)
{ {
return __kmalloc(size, flags); return __kmalloc(size, flags);
} }
...@@ -161,12 +157,24 @@ void *kmalloc(size_t size, gfp_t flags) ...@@ -161,12 +157,24 @@ void *kmalloc(size_t size, gfp_t flags)
* @size: how many bytes of memory are required. * @size: how many bytes of memory are required.
* @flags: the type of memory to allocate (see kmalloc). * @flags: the type of memory to allocate (see kmalloc).
*/ */
void *kzalloc(size_t size, gfp_t flags) static inline void *kzalloc(size_t size, gfp_t flags)
{ {
return __kzalloc(size, flags); return __kzalloc(size, flags);
} }
#endif #endif
#ifndef CONFIG_NUMA
static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
{
return kmalloc(size, flags);
}
static inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
{
return __kmalloc(size, flags);
}
#endif /* !CONFIG_NUMA */
/* /*
* kmalloc_track_caller is a special version of kmalloc that records the * kmalloc_track_caller is a special version of kmalloc that records the
* calling function of the routine calling it for slab leak tracking instead * calling function of the routine calling it for slab leak tracking instead
...@@ -208,12 +216,8 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *); ...@@ -208,12 +216,8 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
#define kmalloc_node_track_caller(size, flags, node) \ #define kmalloc_node_track_caller(size, flags, node) \
kmalloc_track_caller(size, flags) kmalloc_track_caller(size, flags)
static inline void *kmalloc_node(size_t size, gfp_t flags, int node) #endif /* DEBUG_SLAB */
{
return kmalloc(size, flags);
}
#endif /* !CONFIG_NUMA */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _LINUX_SLAB_H */ #endif /* _LINUX_SLAB_H */
...@@ -3541,7 +3541,7 @@ EXPORT_SYMBOL(kmem_cache_zalloc); ...@@ -3541,7 +3541,7 @@ EXPORT_SYMBOL(kmem_cache_zalloc);
* *
* Currently only used for dentry validation. * Currently only used for dentry validation.
*/ */
int fastcall kmem_ptr_validate(struct kmem_cache *cachep, void *ptr) int fastcall kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr)
{ {
unsigned long addr = (unsigned long)ptr; unsigned long addr = (unsigned long)ptr;
unsigned long min_addr = PAGE_OFFSET; unsigned long min_addr = PAGE_OFFSET;
......
...@@ -334,7 +334,7 @@ int kmem_cache_shrink(struct kmem_cache *d) ...@@ -334,7 +334,7 @@ int kmem_cache_shrink(struct kmem_cache *d)
} }
EXPORT_SYMBOL(kmem_cache_shrink); EXPORT_SYMBOL(kmem_cache_shrink);
int kmem_ptr_validate(struct kmem_cache *a, void *b) int kmem_ptr_validate(struct kmem_cache *a, const void *b)
{ {
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment