Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 248622
b: refs/heads/master
c: 1759415
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Lameter authored and Pekka Enberg committed May 7, 2011
1 parent 2b3b75c commit 9c517ad
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 59 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8dc16c6c04b1a82d00a8464ccc08e1fe17d0ff82
refs/heads/master: 1759415e630e5db0dd2390df9f94892cbfb9a8a2
2 changes: 0 additions & 2 deletions trunk/include/linux/slub_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ enum stat_item {

struct kmem_cache_cpu {
void **freelist; /* Pointer to next available object */
#ifdef CONFIG_CMPXCHG_LOCAL
unsigned long tid; /* Globally unique transaction id */
#endif
struct page *page; /* The slab from which we are allocating */
int node; /* The node of the page (or -1 for debug) */
#ifdef CONFIG_SLUB_STATS
Expand Down
56 changes: 0 additions & 56 deletions trunk/mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,6 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
}
}

#ifdef CONFIG_CMPXCHG_LOCAL
#ifdef CONFIG_PREEMPT
/*
* Calculate the next globally unique transaction for disambiguiation
Expand Down Expand Up @@ -1611,17 +1610,12 @@ static inline void note_cmpxchg_failure(const char *n,
stat(s, CMPXCHG_DOUBLE_CPU_FAIL);
}

#endif

void init_kmem_cache_cpus(struct kmem_cache *s)
{
#ifdef CONFIG_CMPXCHG_LOCAL
int cpu;

for_each_possible_cpu(cpu)
per_cpu_ptr(s->cpu_slab, cpu)->tid = init_tid(cpu);
#endif

}
/*
* Remove the cpu slab
Expand Down Expand Up @@ -1654,9 +1648,7 @@ static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
page->inuse--;
}
c->page = NULL;
#ifdef CONFIG_CMPXCHG_LOCAL
c->tid = next_tid(c->tid);
#endif
unfreeze_slab(s, page, tail);
}

Expand Down Expand Up @@ -1791,7 +1783,6 @@ static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
{
void **object;
struct page *page;
#ifdef CONFIG_CMPXCHG_LOCAL
unsigned long flags;

local_irq_save(flags);
Expand All @@ -1802,7 +1793,6 @@ static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
* pointer.
*/
c = this_cpu_ptr(s->cpu_slab);
#endif
#endif

/* We handle __GFP_ZERO in the caller */
Expand Down Expand Up @@ -1831,10 +1821,8 @@ static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,

unlock_out:
slab_unlock(page);
#ifdef CONFIG_CMPXCHG_LOCAL
c->tid = next_tid(c->tid);
local_irq_restore(flags);
#endif
stat(s, ALLOC_SLOWPATH);
return object;

Expand Down Expand Up @@ -1873,9 +1861,7 @@ static void *__slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
}
if (!(gfpflags & __GFP_NOWARN) && printk_ratelimit())
slab_out_of_memory(s, gfpflags, node);
#ifdef CONFIG_CMPXCHG_LOCAL
local_irq_restore(flags);
#endif
return NULL;
debug:
if (!alloc_debug_processing(s, page, object, addr))
Expand All @@ -1902,20 +1888,12 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
{
void **object;
struct kmem_cache_cpu *c;
#ifdef CONFIG_CMPXCHG_LOCAL
unsigned long tid;
#else
unsigned long flags;
#endif

if (slab_pre_alloc_hook(s, gfpflags))
return NULL;

#ifndef CONFIG_CMPXCHG_LOCAL
local_irq_save(flags);
#else
redo:
#endif

/*
* Must read kmem_cache cpu data via this cpu ptr. Preemption is
Expand All @@ -1925,7 +1903,6 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
*/
c = __this_cpu_ptr(s->cpu_slab);

#ifdef CONFIG_CMPXCHG_LOCAL
/*
* The transaction ids are globally unique per cpu and per operation on
* a per cpu queue. Thus they can be guarantee that the cmpxchg_double
Expand All @@ -1934,15 +1911,13 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
*/
tid = c->tid;
barrier();
#endif

object = c->freelist;
if (unlikely(!object || !node_match(c, node)))

object = __slab_alloc(s, gfpflags, node, addr, c);

else {
#ifdef CONFIG_CMPXCHG_LOCAL
/*
* The cmpxchg will only match if there was no additonal
* operation and if we are on the right processor.
Expand All @@ -1963,16 +1938,9 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
note_cmpxchg_failure("slab_alloc", s, tid);
goto redo;
}
#else
c->freelist = get_freepointer(s, object);
#endif
stat(s, ALLOC_FASTPATH);
}

#ifndef CONFIG_CMPXCHG_LOCAL
local_irq_restore(flags);
#endif

if (unlikely(gfpflags & __GFP_ZERO) && object)
memset(object, 0, s->objsize);

Expand Down Expand Up @@ -2049,11 +2017,9 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
{
void *prior;
void **object = (void *)x;
#ifdef CONFIG_CMPXCHG_LOCAL
unsigned long flags;

local_irq_save(flags);
#endif
slab_lock(page);
stat(s, FREE_SLOWPATH);

Expand Down Expand Up @@ -2084,9 +2050,7 @@ static void __slab_free(struct kmem_cache *s, struct page *page,

out_unlock:
slab_unlock(page);
#ifdef CONFIG_CMPXCHG_LOCAL
local_irq_restore(flags);
#endif
return;

slab_empty:
Expand All @@ -2098,9 +2062,7 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
stat(s, FREE_REMOVE_PARTIAL);
}
slab_unlock(page);
#ifdef CONFIG_CMPXCHG_LOCAL
local_irq_restore(flags);
#endif
stat(s, FREE_SLAB);
discard_slab(s, page);
}
Expand All @@ -2121,20 +2083,11 @@ static __always_inline void slab_free(struct kmem_cache *s,
{
void **object = (void *)x;
struct kmem_cache_cpu *c;
#ifdef CONFIG_CMPXCHG_LOCAL
unsigned long tid;
#else
unsigned long flags;
#endif

slab_free_hook(s, x);

#ifndef CONFIG_CMPXCHG_LOCAL
local_irq_save(flags);

#else
redo:
#endif

/*
* Determine the currently cpus per cpu slab.
Expand All @@ -2144,15 +2097,12 @@ static __always_inline void slab_free(struct kmem_cache *s,
*/
c = __this_cpu_ptr(s->cpu_slab);

#ifdef CONFIG_CMPXCHG_LOCAL
tid = c->tid;
barrier();
#endif

if (likely(page == c->page && c->node != NUMA_NO_NODE)) {
set_freepointer(s, object, c->freelist);

#ifdef CONFIG_CMPXCHG_LOCAL
if (unlikely(!this_cpu_cmpxchg_double(
s->cpu_slab->freelist, s->cpu_slab->tid,
c->freelist, tid,
Expand All @@ -2161,16 +2111,10 @@ static __always_inline void slab_free(struct kmem_cache *s,
note_cmpxchg_failure("slab_free", s, tid);
goto redo;
}
#else
c->freelist = object;
#endif
stat(s, FREE_FASTPATH);
} else
__slab_free(s, page, x, addr);

#ifndef CONFIG_CMPXCHG_LOCAL
local_irq_restore(flags);
#endif
}

void kmem_cache_free(struct kmem_cache *s, void *x)
Expand Down

0 comments on commit 9c517ad

Please sign in to comment.