diff options
| author | Pekka Enberg <penberg@kernel.org> | 2011-03-20 12:12:03 -0400 |
|---|---|---|
| committer | Pekka Enberg <penberg@kernel.org> | 2011-03-20 12:12:03 -0400 |
| commit | c53badd0801728feedfcccae04239410b52b0d03 (patch) | |
| tree | 016421ec2a618767f01df8cfbf765a4dab3b3629 | |
| parent | 521cb40b0c44418a4fd36dc633f575813d59a43d (diff) | |
| parent | 865d794d1f144d0f93796840d01696cd70647a8a (diff) | |
Merge branch 'slab/next' into for-linus
| -rw-r--r-- | include/linux/slab.h | 1 | ||||
| -rw-r--r-- | include/linux/slub_def.h | 1 | ||||
| -rw-r--r-- | mm/slab.c | 55 | ||||
| -rw-r--r-- | mm/slob.c | 6 | ||||
| -rw-r--r-- | mm/slub.c | 132 |
5 files changed, 107 insertions, 88 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index fa9086647eb7..ad4dd1c8d30a 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h | |||
| @@ -105,7 +105,6 @@ void kmem_cache_destroy(struct kmem_cache *); | |||
| 105 | int kmem_cache_shrink(struct kmem_cache *); | 105 | int kmem_cache_shrink(struct kmem_cache *); |
| 106 | void kmem_cache_free(struct kmem_cache *, void *); | 106 | void kmem_cache_free(struct kmem_cache *, void *); |
| 107 | unsigned int kmem_cache_size(struct kmem_cache *); | 107 | unsigned int kmem_cache_size(struct kmem_cache *); |
| 108 | const char *kmem_cache_name(struct kmem_cache *); | ||
| 109 | 108 | ||
| 110 | /* | 109 | /* |
| 111 | * Please use this macro to create slab caches. Simply specify the | 110 | * Please use this macro to create slab caches. Simply specify the |
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index 8b6e8ae5d5ca..ae0093cc5189 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
| @@ -83,6 +83,7 @@ struct kmem_cache { | |||
| 83 | void (*ctor)(void *); | 83 | void (*ctor)(void *); |
| 84 | int inuse; /* Offset to metadata */ | 84 | int inuse; /* Offset to metadata */ |
| 85 | int align; /* Alignment */ | 85 | int align; /* Alignment */ |
| 86 | int reserved; /* Reserved bytes at the end of slabs */ | ||
| 86 | unsigned long min_partial; | 87 | unsigned long min_partial; |
| 87 | const char *name; /* Name (only for display!) */ | 88 | const char *name; /* Name (only for display!) */ |
| 88 | struct list_head list; /* List of slab caches */ | 89 | struct list_head list; /* List of slab caches */ |
| @@ -191,22 +191,6 @@ typedef unsigned int kmem_bufctl_t; | |||
| 191 | #define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3) | 191 | #define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3) |
| 192 | 192 | ||
| 193 | /* | 193 | /* |
| 194 | * struct slab | ||
| 195 | * | ||
| 196 | * Manages the objs in a slab. Placed either at the beginning of mem allocated | ||
| 197 | * for a slab, or allocated from an general cache. | ||
| 198 | * Slabs are chained into three list: fully used, partial, fully free slabs. | ||
| 199 | */ | ||
| 200 | struct slab { | ||
| 201 | struct list_head list; | ||
| 202 | unsigned long colouroff; | ||
| 203 | void *s_mem; /* including colour offset */ | ||
| 204 | unsigned int inuse; /* num of objs active in slab */ | ||
| 205 | kmem_bufctl_t free; | ||
| 206 | unsigned short nodeid; | ||
| 207 | }; | ||
| 208 | |||
| 209 | /* | ||
| 210 | * struct slab_rcu | 194 | * struct slab_rcu |
| 211 | * | 195 | * |
| 212 | * slab_destroy on a SLAB_DESTROY_BY_RCU cache uses this structure to | 196 | * slab_destroy on a SLAB_DESTROY_BY_RCU cache uses this structure to |
| @@ -219,8 +203,6 @@ struct slab { | |||
| 219 | * | 203 | * |
| 220 | * rcu_read_lock before reading the address, then rcu_read_unlock after | 204 | * rcu_read_lock before reading the address, then rcu_read_unlock after |
| 221 | * taking the spinlock within the structure expected at that address. | 205 | * taking the spinlock within the structure expected at that address. |
| 222 | * | ||
| 223 | * We assume struct slab_rcu can overlay struct slab when destroying. | ||
| 224 | */ | 206 | */ |
| 225 | struct slab_rcu { | 207 | struct slab_rcu { |
| 226 | struct rcu_head head; | 208 | struct rcu_head head; |
| @@ -229,6 +211,27 @@ struct slab_rcu { | |||
| 229 | }; | 211 | }; |
| 230 | 212 | ||
| 231 | /* | 213 | /* |
| 214 | * struct slab | ||
| 215 | * | ||
| 216 | * Manages the objs in a slab. Placed either at the beginning of mem allocated | ||
| 217 | * for a slab, or allocated from an general cache. | ||
| 218 | * Slabs are chained into three list: fully used, partial, fully free slabs. | ||
| 219 | */ | ||
| 220 | struct slab { | ||
| 221 | union { | ||
| 222 | struct { | ||
| 223 | struct list_head list; | ||
| 224 | unsigned long colouroff; | ||
| 225 | void *s_mem; /* including colour offset */ | ||
| 226 | unsigned int inuse; /* num of objs active in slab */ | ||
| 227 | kmem_bufctl_t free; | ||
| 228 | unsigned short nodeid; | ||
| 229 | }; | ||
| 230 | struct slab_rcu __slab_cover_slab_rcu; | ||
| 231 | }; | ||
| 232 | }; | ||
| 233 | |||
| 234 | /* | ||
| 232 | * struct array_cache | 235 | * struct array_cache |
| 233 | * | 236 | * |
| 234 | * Purpose: | 237 | * Purpose: |
| @@ -2147,8 +2150,6 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp) | |||
| 2147 | * | 2150 | * |
| 2148 | * @name must be valid until the cache is destroyed. This implies that | 2151 | * @name must be valid until the cache is destroyed. This implies that |
| 2149 | * the module calling this has to destroy the cache before getting unloaded. | 2152 | * the module calling this has to destroy the cache before getting unloaded. |
| 2150 | * Note that kmem_cache_name() is not guaranteed to return the same pointer, | ||
| 2151 | * therefore applications must manage it themselves. | ||
| 2152 | * | 2153 | * |
| 2153 | * The flags are | 2154 | * The flags are |
| 2154 | * | 2155 | * |
| @@ -2288,8 +2289,8 @@ kmem_cache_create (const char *name, size_t size, size_t align, | |||
| 2288 | if (ralign < align) { | 2289 | if (ralign < align) { |
| 2289 | ralign = align; | 2290 | ralign = align; |
| 2290 | } | 2291 | } |
| 2291 | /* disable debug if not aligning with REDZONE_ALIGN */ | 2292 | /* disable debug if necessary */ |
| 2292 | if (ralign & (__alignof__(unsigned long long) - 1)) | 2293 | if (ralign > __alignof__(unsigned long long)) |
| 2293 | flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER); | 2294 | flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER); |
| 2294 | /* | 2295 | /* |
| 2295 | * 4) Store it. | 2296 | * 4) Store it. |
| @@ -2315,8 +2316,8 @@ kmem_cache_create (const char *name, size_t size, size_t align, | |||
| 2315 | */ | 2316 | */ |
| 2316 | if (flags & SLAB_RED_ZONE) { | 2317 | if (flags & SLAB_RED_ZONE) { |
| 2317 | /* add space for red zone words */ | 2318 | /* add space for red zone words */ |
| 2318 | cachep->obj_offset += align; | 2319 | cachep->obj_offset += sizeof(unsigned long long); |
| 2319 | size += align + sizeof(unsigned long long); | 2320 | size += 2 * sizeof(unsigned long long); |
| 2320 | } | 2321 | } |
| 2321 | if (flags & SLAB_STORE_USER) { | 2322 | if (flags & SLAB_STORE_USER) { |
| 2322 | /* user store requires one word storage behind the end of | 2323 | /* user store requires one word storage behind the end of |
| @@ -3840,12 +3841,6 @@ unsigned int kmem_cache_size(struct kmem_cache *cachep) | |||
| 3840 | } | 3841 | } |
| 3841 | EXPORT_SYMBOL(kmem_cache_size); | 3842 | EXPORT_SYMBOL(kmem_cache_size); |
| 3842 | 3843 | ||
| 3843 | const char *kmem_cache_name(struct kmem_cache *cachep) | ||
| 3844 | { | ||
| 3845 | return cachep->name; | ||
| 3846 | } | ||
| 3847 | EXPORT_SYMBOL_GPL(kmem_cache_name); | ||
| 3848 | |||
| 3849 | /* | 3844 | /* |
| 3850 | * This initializes kmem_list3 or resizes various caches for all nodes. | 3845 | * This initializes kmem_list3 or resizes various caches for all nodes. |
| 3851 | */ | 3846 | */ |
| @@ -666,12 +666,6 @@ unsigned int kmem_cache_size(struct kmem_cache *c) | |||
| 666 | } | 666 | } |
| 667 | EXPORT_SYMBOL(kmem_cache_size); | 667 | EXPORT_SYMBOL(kmem_cache_size); |
| 668 | 668 | ||
| 669 | const char *kmem_cache_name(struct kmem_cache *c) | ||
| 670 | { | ||
| 671 | return c->name; | ||
| 672 | } | ||
| 673 | EXPORT_SYMBOL(kmem_cache_name); | ||
| 674 | |||
| 675 | int kmem_cache_shrink(struct kmem_cache *d) | 669 | int kmem_cache_shrink(struct kmem_cache *d) |
| 676 | { | 670 | { |
| 677 | return 0; | 671 | return 0; |
| @@ -281,11 +281,40 @@ static inline int slab_index(void *p, struct kmem_cache *s, void *addr) | |||
| 281 | return (p - addr) / s->size; | 281 | return (p - addr) / s->size; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | static inline size_t slab_ksize(const struct kmem_cache *s) | ||
| 285 | { | ||
| 286 | #ifdef CONFIG_SLUB_DEBUG | ||
| 287 | /* | ||
| 288 | * Debugging requires use of the padding between object | ||
| 289 | * and whatever may come after it. | ||
| 290 | */ | ||
| 291 | if (s->flags & (SLAB_RED_ZONE | SLAB_POISON)) | ||
| 292 | return s->objsize; | ||
| 293 | |||
| 294 | #endif | ||
| 295 | /* | ||
| 296 | * If we have the need to store the freelist pointer | ||
| 297 | * back there or track user information then we can | ||
| 298 | * only use the space before that information. | ||
| 299 | */ | ||
| 300 | if (s->flags & (SLAB_DESTROY_BY_RCU | SLAB_STORE_USER)) | ||
| 301 | return s->inuse; | ||
| 302 | /* | ||
| 303 | * Else we can use all the padding etc for the allocation | ||
| 304 | */ | ||
| 305 | return s->size; | ||
| 306 | } | ||
| 307 | |||
| 308 | static inline int order_objects(int order, unsigned long size, int reserved) | ||
| 309 | { | ||
| 310 | return ((PAGE_SIZE << order) - reserved) / size; | ||
| 311 | } | ||
| 312 | |||
| 284 | static inline struct kmem_cache_order_objects oo_make(int order, | 313 | static inline struct kmem_cache_order_objects oo_make(int order, |
| 285 | unsigned | ||
