Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 82920
b: refs/heads/master
c: 7c2e132
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Lameter committed Feb 4, 2008
1 parent ef5e141 commit 42eb634
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 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: 9824601ead957a29e35d539e43266c003f7b085b
refs/heads/master: 7c2e132c54c79af4e524154074b9a02c3c0d6072
31 changes: 15 additions & 16 deletions trunk/mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,19 +1198,15 @@ static __always_inline int slab_trylock(struct page *page)
/*
* Management of partially allocated slabs
*/
static void add_partial_tail(struct kmem_cache_node *n, struct page *page)
static void add_partial(struct kmem_cache_node *n,
struct page *page, int tail)
{
spin_lock(&n->list_lock);
n->nr_partial++;
list_add_tail(&page->lru, &n->partial);
spin_unlock(&n->list_lock);
}

static void add_partial(struct kmem_cache_node *n, struct page *page)
{
spin_lock(&n->list_lock);
n->nr_partial++;
list_add(&page->lru, &n->partial);
if (tail)
list_add_tail(&page->lru, &n->partial);
else
list_add(&page->lru, &n->partial);
spin_unlock(&n->list_lock);
}

Expand Down Expand Up @@ -1339,15 +1335,15 @@ static struct page *get_partial(struct kmem_cache *s, gfp_t flags, int node)
*
* On exit the slab lock will have been dropped.
*/
static void unfreeze_slab(struct kmem_cache *s, struct page *page)
static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
{
struct kmem_cache_node *n = get_node(s, page_to_nid(page));

ClearSlabFrozen(page);
if (page->inuse) {

if (page->freelist)
add_partial(n, page);
add_partial(n, page, tail);
else if (SlabDebug(page) && (s->flags & SLAB_STORE_USER))
add_full(n, page);
slab_unlock(page);
Expand All @@ -1362,7 +1358,7 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page)
* partial list stays small. kmem_cache_shrink can
* reclaim empty slabs from the partial list.
*/
add_partial_tail(n, page);
add_partial(n, page, 1);
slab_unlock(page);
} else {
slab_unlock(page);
Expand All @@ -1377,6 +1373,7 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page)
static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
{
struct page *page = c->page;
int tail = 1;
/*
* Merge cpu freelist into freelist. Typically we get here
* because both freelists are empty. So this is unlikely
Expand All @@ -1385,6 +1382,8 @@ static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
while (unlikely(c->freelist)) {
void **object;

tail = 0; /* Hot objects. Put the slab first */

/* Retrieve object from cpu_freelist */
object = c->freelist;
c->freelist = c->freelist[c->offset];
Expand All @@ -1395,7 +1394,7 @@ static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
page->inuse--;
}
c->page = NULL;
unfreeze_slab(s, page);
unfreeze_slab(s, page, tail);
}

static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
Expand Down Expand Up @@ -1617,7 +1616,7 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
* then add it.
*/
if (unlikely(!prior))
add_partial_tail(get_node(s, page_to_nid(page)), page);
add_partial(get_node(s, page_to_nid(page)), page, 1);

out_unlock:
slab_unlock(page);
Expand Down Expand Up @@ -2025,7 +2024,7 @@ static struct kmem_cache_node *early_kmem_cache_node_alloc(gfp_t gfpflags,
#endif
init_kmem_cache_node(n);
atomic_long_inc(&n->nr_slabs);
add_partial(n, page);
add_partial(n, page, 0);
return n;
}

Expand Down

0 comments on commit 42eb634

Please sign in to comment.