mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
Slab allocators: consistent ZERO_SIZE_PTR support and NULL result semantics
Define ZERO_OR_NULL_PTR macro to be able to remove the checks from the allocators. Move ZERO_SIZE_PTR related stuff into slab.h. Make ZERO_SIZE_PTR work for all slab allocators and get rid of the WARN_ON_ONCE(size == 0) that is still remaining in SLAB. Make slub return NULL like the other allocators if a too large memory segment is requested via __kmalloc. Signed-off-by: Christoph Lameter <clameter@sgi.com> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
ef2ad80c7d
commit
6cb8f91320
7 changed files with 57 additions and 35 deletions
|
@ -30,6 +30,19 @@
|
|||
#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
|
||||
#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */
|
||||
|
||||
/*
|
||||
* ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
|
||||
*
|
||||
* Dereferencing ZERO_SIZE_PTR will lead to a distinct access fault.
|
||||
*
|
||||
* ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
|
||||
* Both make kfree a no-op.
|
||||
*/
|
||||
#define ZERO_SIZE_PTR ((void *)16)
|
||||
|
||||
#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) < \
|
||||
(unsigned long)ZERO_SIZE_PTR)
|
||||
|
||||
/*
|
||||
* struct kmem_cache related prototypes
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue