Skip to content

Commit 14577be

Browse files
committed
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: slub: Dont define useless label in the !CONFIG_CMPXCHG_LOCAL case slab,rcu: don't assume the size of struct rcu_head slub,rcu: don't assume the size of struct rcu_head slub: automatically reserve bytes at the end of slab Lockless (and preemptless) fastpaths for slub slub: Get rid of slab_free_hook_irq() slub: min_partial needs to be in first cacheline slub: fix ksize() build error slub: fix kmemcheck calls to match ksize() hints Revert "slab: Fix missing DEBUG_SLAB last user" mm: Remove support for kmem_cache_name()
2 parents 09b9cc4 + e8c500c commit 14577be

5 files changed

Lines changed: 333 additions & 103 deletions

File tree

‎include/linux/slab.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ void kmem_cache_destroy(struct kmem_cache *);
105105
int kmem_cache_shrink(struct kmem_cache *);
106106
void kmem_cache_free(struct kmem_cache *, void *);
107107
unsigned int kmem_cache_size(struct kmem_cache *);
108-
const char *kmem_cache_name(struct kmem_cache *);
109108

110109
/*
111110
* Please use this macro to create slab caches. Simply specify the

‎include/linux/slub_def.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ enum stat_item {
3535
NR_SLUB_STAT_ITEMS };
3636

3737
struct kmem_cache_cpu {
38-
void **freelist; /* Pointer to first free per cpu object */
38+
void **freelist; /* Pointer to next available object */
39+
#ifdef CONFIG_CMPXCHG_LOCAL
40+
unsigned long tid; /* Globally unique transaction id */
41+
#endif
3942
struct page *page; /* The slab from which we are allocating */
4043
int node; /* The node of the page (or -1 for debug) */
4144
#ifdef CONFIG_SLUB_STATS
@@ -70,6 +73,7 @@ struct kmem_cache {
7073
struct kmem_cache_cpu __percpu *cpu_slab;
7174
/* Used for retriving partial slabs etc */
7275
unsigned long flags;
76+
unsigned long min_partial;
7377
int size; /* The size of an object including meta data */
7478
int objsize; /* The size of an object without meta data */
7579
int offset; /* Free pointer offset. */
@@ -83,7 +87,7 @@ struct kmem_cache {
8387
void (*ctor)(void *);
8488
int inuse; /* Offset to metadata */
8589
int align; /* Alignment */
86-
unsigned long min_partial;
90+
int reserved; /* Reserved bytes at the end of slabs */
8791
const char *name; /* Name (only for display!) */
8892
struct list_head list; /* List of slab caches */
8993
#ifdef CONFIG_SYSFS

‎mm/slab.c‎

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,6 @@ typedef unsigned int kmem_bufctl_t;
190190
#define BUFCTL_ACTIVE (((kmem_bufctl_t)(~0U))-2)
191191
#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3)
192192

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-
209193
/*
210194
* struct slab_rcu
211195
*
@@ -219,15 +203,34 @@ struct slab {
219203
*
220204
* rcu_read_lock before reading the address, then rcu_read_unlock after
221205
* taking the spinlock within the structure expected at that address.
222-
*
223-
* We assume struct slab_rcu can overlay struct slab when destroying.
224206
*/
225207
struct slab_rcu {
226208
struct rcu_head head;
227209
struct kmem_cache *cachep;
228210
void *addr;
229211
};
230212

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+
231234
/*
232235
* struct array_cache
233236
*
@@ -2147,8 +2150,6 @@ static int __init_refok setup_cpu_cache(struct kmem_cache *cachep, gfp_t gfp)
21472150
*
21482151
* @name must be valid until the cache is destroyed. This implies that
21492152
* 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.
21522153
*
21532154
* The flags are
21542155
*
@@ -2288,8 +2289,8 @@ kmem_cache_create (const char *name, size_t size, size_t align,
22882289
if (ralign < align) {
22892290
ralign = align;
22902291
}
2291-
/* disable debug if not aligning with REDZONE_ALIGN */
2292-
if (ralign & (__alignof__(unsigned long long) - 1))
2292+
/* disable debug if necessary */
2293+
if (ralign > __alignof__(unsigned long long))
22932294
flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
22942295
/*
22952296
* 4) Store it.
@@ -2315,8 +2316,8 @@ kmem_cache_create (const char *name, size_t size, size_t align,
23152316
*/
23162317
if (flags & SLAB_RED_ZONE) {
23172318
/* add space for red zone words */
2318-
cachep->obj_offset += align;
2319-
size += align + sizeof(unsigned long long);
2319+
cachep->obj_offset += sizeof(unsigned long long);
2320+
size += 2 * sizeof(unsigned long long);
23202321
}
23212322
if (flags & SLAB_STORE_USER) {
23222323
/* user store requires one word storage behind the end of
@@ -3840,12 +3841,6 @@ unsigned int kmem_cache_size(struct kmem_cache *cachep)
38403841
}
38413842
EXPORT_SYMBOL(kmem_cache_size);
38423843

3843-
const char *kmem_cache_name(struct kmem_cache *cachep)
3844-
{
3845-
return cachep->name;
3846-
}
3847-
EXPORT_SYMBOL_GPL(kmem_cache_name);
3848-
38493844
/*
38503845
* This initializes kmem_list3 or resizes various caches for all nodes.
38513846
*/

‎mm/slob.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,6 @@ unsigned int kmem_cache_size(struct kmem_cache *c)
666666
}
667667
EXPORT_SYMBOL(kmem_cache_size);
668668

669-
const char *kmem_cache_name(struct kmem_cache *c)
670-
{
671-
return c->name;
672-
}
673-
EXPORT_SYMBOL(kmem_cache_name);
674-
675669
int kmem_cache_shrink(struct kmem_cache *d)
676670
{
677671
return 0;

0 commit comments

Comments
 (0)