Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23508
b: refs/heads/master
c: 3ded175
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Mar 25, 2006
1 parent 63b05fb commit 365d467
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 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: c5e3b83e97be4e09961c0af101644643e5d03d17
refs/heads/master: 3ded175a4b7a4548f3358dcf5f3ad65f63cdb4ed
42 changes: 28 additions & 14 deletions trunk/mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,30 @@ static struct array_cache *alloc_arraycache(int node, int entries,
return nc;
}

/*
* Transfer objects in one arraycache to another.
* Locking must be handled by the caller.
*
* Return the number of entries transferred.
*/
static int transfer_objects(struct array_cache *to,
struct array_cache *from, unsigned int max)
{
/* Figure out how many entries to transfer */
int nr = min(min(from->avail, max), to->limit - to->avail);

if (!nr)
return 0;

memcpy(to->entry + to->avail, from->entry + from->avail -nr,
sizeof(void *) *nr);

from->avail -= nr;
to->avail += nr;
to->touched = 1;
return nr;
}

#ifdef CONFIG_NUMA
static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int);
static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
Expand Down Expand Up @@ -2680,20 +2704,10 @@ static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags)
BUG_ON(ac->avail > 0 || !l3);
spin_lock(&l3->list_lock);

if (l3->shared) {
struct array_cache *shared_array = l3->shared;
if (shared_array->avail) {
if (batchcount > shared_array->avail)
batchcount = shared_array->avail;
shared_array->avail -= batchcount;
ac->avail = batchcount;
memcpy(ac->entry,
&(shared_array->entry[shared_array->avail]),
sizeof(void *) * batchcount);
shared_array->touched = 1;
goto alloc_done;
}
}
/* See if we can refill from the shared array */
if (l3->shared && transfer_objects(ac, l3->shared, batchcount))
goto alloc_done;

while (batchcount > 0) {
struct list_head *entry;
struct slab *slabp;
Expand Down

0 comments on commit 365d467

Please sign in to comment.