diff options
-rw-r--r-- | kernel/cpuset.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 312961ef3ccc..0b361a0b58f6 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -1487,7 +1487,6 @@ static void cpuset_attach(struct cgroup_subsys_state *css, | |||
1487 | { | 1487 | { |
1488 | /* static buf protected by cpuset_mutex */ | 1488 | /* static buf protected by cpuset_mutex */ |
1489 | static nodemask_t cpuset_attach_nodemask_to; | 1489 | static nodemask_t cpuset_attach_nodemask_to; |
1490 | struct mm_struct *mm; | ||
1491 | struct task_struct *task; | 1490 | struct task_struct *task; |
1492 | struct task_struct *leader = cgroup_taskset_first(tset); | 1491 | struct task_struct *leader = cgroup_taskset_first(tset); |
1493 | struct cpuset *cs = css_cs(css); | 1492 | struct cpuset *cs = css_cs(css); |
@@ -1515,26 +1514,31 @@ static void cpuset_attach(struct cgroup_subsys_state *css, | |||
1515 | } | 1514 | } |
1516 | 1515 | ||
1517 | /* | 1516 | /* |
1518 | * Change mm, possibly for multiple threads in a threadgroup. This is | 1517 | * Change mm, possibly for multiple threads in a threadgroup. This |
1519 | * expensive and may sleep. | 1518 | * is expensive and may sleep and should be moved outside migration |
1519 | * path proper. | ||
1520 | */ | 1520 | */ |
1521 | cpuset_attach_nodemask_to = cs->effective_mems; | 1521 | cpuset_attach_nodemask_to = cs->effective_mems; |
1522 | mm = get_task_mm(leader); | 1522 | if (thread_group_leader(leader)) { |
1523 | if (mm) { | 1523 | struct mm_struct *mm = get_task_mm(leader); |
1524 | mpol_rebind_mm(mm, &cpuset_attach_nodemask_to); | 1524 | |
1525 | 1525 | if (mm) { | |
1526 | /* | 1526 | mpol_rebind_mm(mm, &cpuset_attach_nodemask_to); |
1527 | * old_mems_allowed is the same with mems_allowed here, except | 1527 | |
1528 | * if this task is being moved automatically due to hotplug. | 1528 | /* |
1529 | * In that case @mems_allowed has been updated and is empty, | 1529 | * old_mems_allowed is the same with mems_allowed |
1530 | * so @old_mems_allowed is the right nodesets that we migrate | 1530 | * here, except if this task is being moved |
1531 | * mm from. | 1531 | * automatically due to hotplug. In that case |
1532 | */ | 1532 | * @mems_allowed has been updated and is empty, so |
1533 | if (is_memory_migrate(cs)) { | 1533 | * @old_mems_allowed is the right nodesets that we |
1534 | cpuset_migrate_mm(mm, &oldcs->old_mems_allowed, | 1534 | * migrate mm from. |
1535 | &cpuset_attach_nodemask_to); | 1535 | */ |
1536 | if (is_memory_migrate(cs)) { | ||
1537 | cpuset_migrate_mm(mm, &oldcs->old_mems_allowed, | ||
1538 | &cpuset_attach_nodemask_to); | ||
1539 | } | ||
1540 | mmput(mm); | ||
1536 | } | 1541 | } |
1537 | mmput(mm); | ||
1538 | } | 1542 | } |
1539 | 1543 | ||
1540 | cs->old_mems_allowed = cpuset_attach_nodemask_to; | 1544 | cs->old_mems_allowed = cpuset_attach_nodemask_to; |