Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 11843
b: refs/heads/master
c: 68860ec
h: refs/heads/master
i:
  11841: cca6754
  11839: c30a76a
v: v3
  • Loading branch information
Paul Jackson authored and Linus Torvalds committed Oct 31, 2005
1 parent 961ae7c commit d6ebb6c
Show file tree
Hide file tree
Showing 4 changed files with 75 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: fb5eeeee44edb248b4837416966f19731f497f79
refs/heads/master: 68860ec10bcc07ab4f89f9d940e3b77ae5ca13b3
6 changes: 6 additions & 0 deletions trunk/include/linux/mempolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ struct mempolicy *get_vma_policy(struct task_struct *task,

extern void numa_default_policy(void);
extern void numa_policy_init(void);
extern void numa_policy_rebind(const nodemask_t *old, const nodemask_t *new);
extern struct mempolicy default_policy;

#else
Expand Down Expand Up @@ -226,6 +227,11 @@ static inline void numa_default_policy(void)
{
}

static inline void numa_policy_rebind(const nodemask_t *old,
const nodemask_t *new)
{
}

#endif /* CONFIG_NUMA */
#endif /* __KERNEL__ */

Expand Down
4 changes: 4 additions & 0 deletions trunk/kernel/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/kernel.h>
#include <linux/kmod.h>
#include <linux/list.h>
#include <linux/mempolicy.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/mount.h>
Expand Down Expand Up @@ -600,6 +601,7 @@ static void refresh_mems(void)

if (current->cpuset_mems_generation != my_cpusets_mem_gen) {
struct cpuset *cs;
nodemask_t oldmem = current->mems_allowed;

down(&callback_sem);
task_lock(current);
Expand All @@ -608,6 +610,8 @@ static void refresh_mems(void)
current->cpuset_mems_generation = cs->mems_generation;
task_unlock(current);
up(&callback_sem);
if (!nodes_equal(oldmem, current->mems_allowed))
numa_policy_rebind(&oldmem, &current->mems_allowed);
}
}

Expand Down
64 changes: 64 additions & 0 deletions trunk/mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ long do_get_mempolicy(int *policy, nodemask_t *nmask,
struct vm_area_struct *vma = NULL;
struct mempolicy *pol = current->mempolicy;

cpuset_update_current_mems_allowed();
if (flags & ~(unsigned long)(MPOL_F_NODE|MPOL_F_ADDR))
return -EINVAL;
if (flags & MPOL_F_ADDR) {
Expand Down Expand Up @@ -1206,3 +1207,66 @@ void numa_default_policy(void)
{
do_set_mempolicy(MPOL_DEFAULT, NULL);
}

/* Migrate a policy to a different set of nodes */
static void rebind_policy(struct mempolicy *pol, const nodemask_t *old,
const nodemask_t *new)
{
nodemask_t tmp;

if (!pol)
return;

switch (pol->policy) {
case MPOL_DEFAULT:
break;
case MPOL_INTERLEAVE:
nodes_remap(tmp, pol->v.nodes, *old, *new);
pol->v.nodes = tmp;
current->il_next = node_remap(current->il_next, *old, *new);
break;
case MPOL_PREFERRED:
pol->v.preferred_node = node_remap(pol->v.preferred_node,
*old, *new);
break;
case MPOL_BIND: {
nodemask_t nodes;
struct zone **z;
struct zonelist *zonelist;

nodes_clear(nodes);
for (z = pol->v.zonelist->zones; *z; z++)
node_set((*z)->zone_pgdat->node_id, nodes);
nodes_remap(tmp, nodes, *old, *new);
nodes = tmp;

zonelist = bind_zonelist(&nodes);

/* If no mem, then zonelist is NULL and we keep old zonelist.
* If that old zonelist has no remaining mems_allowed nodes,
* then zonelist_policy() will "FALL THROUGH" to MPOL_DEFAULT.
*/

if (zonelist) {
/* Good - got mem - substitute new zonelist */
kfree(pol->v.zonelist);
pol->v.zonelist = zonelist;
}
break;
}
default:
BUG();
break;
}
}

/*
* Someone moved this task to different nodes. Fixup mempolicies.
*
* TODO - fixup current->mm->vma and shmfs/tmpfs/hugetlbfs policies as well,
* once we have a cpuset mechanism to mark which cpuset subtree is migrating.
*/
void numa_policy_rebind(const nodemask_t *old, const nodemask_t *new)
{
rebind_policy(current->mempolicy, old, new);
}

0 comments on commit d6ebb6c

Please sign in to comment.