diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-11-13 14:30:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-11-13 14:30:46 -0500 |
commit | 2d1595ad8766c9cbab81d259168c00261d382ac5 (patch) | |
tree | 28fba62cf218ef484113ab4335e3f1f3fbecd484 | |
parent | 90aaa53c5a5af33a061313681d8f3234712b866b (diff) | |
parent | d7de4c1dc3a2faca0bf05d9e342f885cb2696766 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/slab-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/slab-2.6:
slab: document SLAB_DESTROY_BY_RCU
Kconfig: SLUB is the default slab allocator
-rw-r--r-- | include/linux/slab.h | 28 | ||||
-rw-r--r-- | init/Kconfig | 6 |
2 files changed, 31 insertions, 3 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index ba965c84ae06..000da12b5cf0 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
@@ -23,6 +23,34 @@ | |||
23 | #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ | 23 | #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ |
24 | #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ | 24 | #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ |
25 | #define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ | 25 | #define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ |
26 | /* | ||
27 | * SLAB_DESTROY_BY_RCU - **WARNING** READ THIS! | ||
28 | * | ||
29 | * This delays freeing the SLAB page by a grace period, it does _NOT_ | ||
30 | * delay object freeing. This means that if you do kmem_cache_free() | ||
31 | * that memory location is free to be reused at any time. Thus it may | ||
32 | * be possible to see another object there in the same RCU grace period. | ||
33 | * | ||
34 | * This feature only ensures the memory location backing the object | ||
35 | * stays valid, the trick to using this is relying on an independent | ||
36 | * object validation pass. Something like: | ||
37 | * | ||
38 | * rcu_read_lock() | ||
39 | * again: | ||
40 | * obj = lockless_lookup(key); | ||
41 | * if (obj) { | ||
42 | * if (!try_get_ref(obj)) // might fail for free objects | ||
43 | * goto again; | ||
44 | * | ||
45 | * if (obj->key != key) { // not the object we expected | ||
46 | * put_ref(obj); | ||
47 | * goto again; | ||
48 | * } | ||
49 | * } | ||
50 | * rcu_read_unlock(); | ||
51 | * | ||
52 | * See also the comment on struct slab_rcu in mm/slab.c. | ||
53 | */ | ||
26 | #define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ | 54 | #define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ |
27 | #define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ | 55 | #define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ |
28 | #define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ | 56 | #define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ |
diff --git a/init/Kconfig b/init/Kconfig index 86b00c53fade..226da2733c1e 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -771,8 +771,7 @@ config SLAB | |||
771 | help | 771 | help |
772 | The regular slab allocator that is established and known to work | 772 | The regular slab allocator that is established and known to work |
773 | well in all environments. It organizes cache hot objects in | 773 | well in all environments. It organizes cache hot objects in |
774 | per cpu and per node queues. SLAB is the default choice for | 774 | per cpu and per node queues. |
775 | a slab allocator. | ||
776 | 775 | ||
777 | config SLUB | 776 | config SLUB |
778 | bool "SLUB (Unqueued Allocator)" | 777 | bool "SLUB (Unqueued Allocator)" |
@@ -781,7 +780,8 @@ config SLUB | |||
781 | instead of managing queues of cached objects (SLAB approach). | 780 | instead of managing queues of cached objects (SLAB approach). |
782 | Per cpu caching is realized using slabs of objects instead | 781 | Per cpu caching is realized using slabs of objects instead |
783 | of queues of objects. SLUB can use memory efficiently | 782 | of queues of objects. SLUB can use memory efficiently |
784 | and has enhanced diagnostics. | 783 | and has enhanced diagnostics. SLUB is the default choice for |
784 | a slab allocator. | ||
785 | 785 | ||
786 | config SLOB | 786 | config SLOB |
787 | depends on EMBEDDED | 787 | depends on EMBEDDED |