Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93993
b: refs/heads/master
c: 4c50bc0
h: refs/heads/master
i:
  93991: 7b53617
v: v3
  • Loading branch information
David Rientjes authored and Linus Torvalds committed Apr 28, 2008
1 parent e5d3242 commit d74cdff
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 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: 7ea931c9fc80c4d0a4306c30ec92eb0f1d922a0b
refs/heads/master: 4c50bc0116cf3cc35e7152d6a8424b4db65f52d6
3 changes: 2 additions & 1 deletion trunk/include/linux/mempolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ enum {

/* Flags for set_mempolicy */
#define MPOL_F_STATIC_NODES (1 << 15)
#define MPOL_F_RELATIVE_NODES (1 << 14)

/*
* MPOL_MODE_FLAGS is the union of all possible optional mode flags passed to
* either set_mempolicy() or mbind().
*/
#define MPOL_MODE_FLAGS (MPOL_F_STATIC_NODES)
#define MPOL_MODE_FLAGS (MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES)

/* Flags for get_mempolicy */
#define MPOL_F_NODE (1<<0) /* return next IL mode instead of node mask */
Expand Down
33 changes: 31 additions & 2 deletions trunk/mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ static int is_valid_nodemask(nodemask_t *nodemask)

static inline int mpol_store_user_nodemask(const struct mempolicy *pol)
{
return pol->flags & MPOL_F_STATIC_NODES;
return pol->flags & (MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES);
}

static void mpol_relative_nodemask(nodemask_t *ret, const nodemask_t *orig,
const nodemask_t *rel)
{
nodemask_t tmp;
nodes_fold(tmp, *orig, nodes_weight(*rel));
nodes_onto(*ret, tmp, *rel);
}

/* Create a new policy */
Expand All @@ -157,7 +165,12 @@ static struct mempolicy *mpol_new(unsigned short mode, unsigned short flags,
return ERR_PTR(-ENOMEM);
atomic_set(&policy->refcnt, 1);
cpuset_update_task_memory_state();
nodes_and(cpuset_context_nmask, *nodes, cpuset_current_mems_allowed);
if (flags & MPOL_F_RELATIVE_NODES)
mpol_relative_nodemask(&cpuset_context_nmask, nodes,
&cpuset_current_mems_allowed);
else
nodes_and(cpuset_context_nmask, *nodes,
cpuset_current_mems_allowed);
switch (mode) {
case MPOL_INTERLEAVE:
if (nodes_empty(*nodes) || nodes_empty(cpuset_context_nmask))
Expand Down Expand Up @@ -873,6 +886,9 @@ asmlinkage long sys_mbind(unsigned long start, unsigned long len,
mode &= ~MPOL_MODE_FLAGS;
if (mode >= MPOL_MAX)
return -EINVAL;
if ((mode_flags & MPOL_F_STATIC_NODES) &&
(mode_flags & MPOL_F_RELATIVE_NODES))
return -EINVAL;
err = get_nodes(&nodes, nmask, maxnode);
if (err)
return err;
Expand All @@ -891,6 +907,8 @@ asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask,
mode &= ~MPOL_MODE_FLAGS;
if ((unsigned int)mode >= MPOL_MAX)
return -EINVAL;
if ((flags & MPOL_F_STATIC_NODES) && (flags & MPOL_F_RELATIVE_NODES))
return -EINVAL;
err = get_nodes(&nodes, nmask, maxnode);
if (err)
return err;
Expand Down Expand Up @@ -1745,10 +1763,12 @@ static void mpol_rebind_policy(struct mempolicy *pol,
{
nodemask_t tmp;
int static_nodes;
int relative_nodes;

if (!pol)
return;
static_nodes = pol->flags & MPOL_F_STATIC_NODES;
relative_nodes = pol->flags & MPOL_F_RELATIVE_NODES;
if (!mpol_store_user_nodemask(pol) &&
nodes_equal(pol->w.cpuset_mems_allowed, *newmask))
return;
Expand All @@ -1761,6 +1781,9 @@ static void mpol_rebind_policy(struct mempolicy *pol,
case MPOL_INTERLEAVE:
if (static_nodes)
nodes_and(tmp, pol->w.user_nodemask, *newmask);
else if (relative_nodes)
mpol_relative_nodemask(&tmp, &pol->w.user_nodemask,
newmask);
else {
nodes_remap(tmp, pol->v.nodes,
pol->w.cpuset_mems_allowed, *newmask);
Expand All @@ -1783,6 +1806,10 @@ static void mpol_rebind_policy(struct mempolicy *pol,
pol->v.preferred_node = node;
else
pol->v.preferred_node = -1;
} else if (relative_nodes) {
mpol_relative_nodemask(&tmp, &pol->w.user_nodemask,
newmask);
pol->v.preferred_node = first_node(tmp);
} else {
pol->v.preferred_node = node_remap(pol->v.preferred_node,
pol->w.cpuset_mems_allowed, *newmask);
Expand Down Expand Up @@ -1878,6 +1905,8 @@ static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)

if (flags & MPOL_F_STATIC_NODES)
p += sprintf(p, "%sstatic", need_bar++ ? "|" : "");
if (flags & MPOL_F_RELATIVE_NODES)
p += sprintf(p, "%srelative", need_bar++ ? "|" : "");
}

if (!nodes_empty(nodes)) {
Expand Down
6 changes: 6 additions & 0 deletions trunk/mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,12 @@ static int shmem_parse_mpol(char *value, unsigned short *policy,
if (flags) {
if (!strcmp(flags, "static"))
*mode_flags |= MPOL_F_STATIC_NODES;
if (!strcmp(flags, "relative"))
*mode_flags |= MPOL_F_RELATIVE_NODES;

if ((*mode_flags & MPOL_F_STATIC_NODES) &&
(*mode_flags & MPOL_F_RELATIVE_NODES))
err = 1;
}
out:
/* Restore string for error message */
Expand Down

0 comments on commit d74cdff

Please sign in to comment.