Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 276840
b: refs/heads/master
c: b246272
h: refs/heads/master
v: v3
  • Loading branch information
David Rientjes authored and Linus Torvalds committed Dec 20, 2011
1 parent b53abca commit a4bf47f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 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: 511585a28e5b5fd1cac61e601e42efc4c5dd64b5
refs/heads/master: b246272ecc5ac68c743b15c9e41a2275f7ce70e2
29 changes: 24 additions & 5 deletions trunk/kernel/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ static inline struct cpuset *task_cs(struct task_struct *task)
struct cpuset, css);
}

#ifdef CONFIG_NUMA
static inline bool task_has_mempolicy(struct task_struct *task)
{
return task->mempolicy;
}
#else
static inline bool task_has_mempolicy(struct task_struct *task)
{
return false;
}
#endif


/* bits in struct cpuset flags field */
typedef enum {
CS_CPU_EXCLUSIVE,
Expand Down Expand Up @@ -949,7 +962,7 @@ static void cpuset_migrate_mm(struct mm_struct *mm, const nodemask_t *from,
static void cpuset_change_task_nodemask(struct task_struct *tsk,
nodemask_t *newmems)
{
bool masks_disjoint = !nodes_intersects(*newmems, tsk->mems_allowed);
bool need_loop;

repeat:
/*
Expand All @@ -962,6 +975,14 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk,
return;

task_lock(tsk);
/*
* Determine if a loop is necessary if another thread is doing
* get_mems_allowed(). If at least one node remains unchanged and
* tsk does not have a mempolicy, then an empty nodemask will not be
* possible when mems_allowed is larger than a word.
*/
need_loop = task_has_mempolicy(tsk) ||
!nodes_intersects(*newmems, tsk->mems_allowed);
nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems);
mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP1);

Expand All @@ -981,11 +1002,9 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk,

/*
* Allocation of memory is very fast, we needn't sleep when waiting
* for the read-side. No wait is necessary, however, if at least one
* node remains unchanged.
* for the read-side.
*/
while (masks_disjoint &&
ACCESS_ONCE(tsk->mems_allowed_change_disable)) {
while (need_loop && ACCESS_ONCE(tsk->mems_allowed_change_disable)) {
task_unlock(tsk);
if (!task_curr(tsk))
yield();
Expand Down

0 comments on commit a4bf47f

Please sign in to comment.