Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 18911
b: refs/heads/master
c: dc85da1
h: refs/heads/master
i:
  18909: 2db648a
  18907: 8521910
  18903: 113640f
  18895: c24547a
  18879: 283b781
v: v3
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Jan 19, 2006
1 parent 12d1b65 commit e8906c1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fc0abb1451c64c79ac80665d5ba74450ce274e4d
refs/heads/master: dc85da15d42b0efc792b0f5eab774dc5dbc1ceec
1 change: 1 addition & 0 deletions trunk/include/linux/mempolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new);
extern struct mempolicy default_policy;
extern struct zonelist *huge_zonelist(struct vm_area_struct *vma,
unsigned long addr);
extern unsigned slab_node(struct mempolicy *policy);

extern int policy_zone;

Expand Down
30 changes: 30 additions & 0 deletions trunk/mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,36 @@ static unsigned interleave_nodes(struct mempolicy *policy)
return nid;
}

/*
* Depending on the memory policy provide a node from which to allocate the
* next slab entry.
*/
unsigned slab_node(struct mempolicy *policy)
{
if (in_interrupt())
return numa_node_id();

switch (policy->policy) {
case MPOL_INTERLEAVE:
return interleave_nodes(policy);

case MPOL_BIND:
/*
* Follow bind policy behavior and start allocation at the
* first node.
*/
return policy->v.zonelist->zones[0]->zone_pgdat->node_id;

case MPOL_PREFERRED:
if (policy->v.preferred_node >= 0)
return policy->v.preferred_node;
/* Fall through */

default:
return numa_node_id();
}
}

/* Do static interleaving for a VMA with known offset. */
static unsigned offset_il_node(struct mempolicy *pol,
struct vm_area_struct *vma, unsigned long off)
Expand Down
12 changes: 12 additions & 0 deletions trunk/mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
#include <linux/rcupdate.h>
#include <linux/string.h>
#include <linux/nodemask.h>
#include <linux/mempolicy.h>
#include <linux/mutex.h>

#include <asm/uaccess.h>
Expand Down Expand Up @@ -773,6 +774,8 @@ static struct array_cache *alloc_arraycache(int node, int entries,
}

#ifdef CONFIG_NUMA
static void *__cache_alloc_node(kmem_cache_t *, gfp_t, int);

static inline struct array_cache **alloc_alien_cache(int node, int limit)
{
struct array_cache **ac_ptr;
Expand Down Expand Up @@ -2570,6 +2573,15 @@ static inline void *____cache_alloc(kmem_cache_t *cachep, gfp_t flags)
void *objp;
struct array_cache *ac;

#ifdef CONFIG_NUMA
if (current->mempolicy) {
int nid = slab_node(current->mempolicy);

if (nid != numa_node_id())
return __cache_alloc_node(cachep, flags, nid);
}
#endif

check_irq_off();
ac = ac_data(cachep);
if (likely(ac->avail)) {
Expand Down

0 comments on commit e8906c1

Please sign in to comment.