diff options
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r-- | kernel/cpuset.c | 59 |
1 files changed, 13 insertions, 46 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index a09ac2b9a661..1010cc61931f 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -964,7 +964,6 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk, | |||
964 | { | 964 | { |
965 | bool need_loop; | 965 | bool need_loop; |
966 | 966 | ||
967 | repeat: | ||
968 | /* | 967 | /* |
969 | * Allow tasks that have access to memory reserves because they have | 968 | * Allow tasks that have access to memory reserves because they have |
970 | * been OOM killed to get memory anywhere. | 969 | * been OOM killed to get memory anywhere. |
@@ -983,45 +982,19 @@ repeat: | |||
983 | */ | 982 | */ |
984 | need_loop = task_has_mempolicy(tsk) || | 983 | need_loop = task_has_mempolicy(tsk) || |
985 | !nodes_intersects(*newmems, tsk->mems_allowed); | 984 | !nodes_intersects(*newmems, tsk->mems_allowed); |
986 | nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems); | ||
987 | mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP1); | ||
988 | 985 | ||
989 | /* | 986 | if (need_loop) |
990 | * ensure checking ->mems_allowed_change_disable after setting all new | 987 | write_seqcount_begin(&tsk->mems_allowed_seq); |
991 | * allowed nodes. | ||
992 | * | ||
993 | * the read-side task can see an nodemask with new allowed nodes and | ||
994 | * old allowed nodes. and if it allocates page when cpuset clears newly | ||
995 | * disallowed ones continuous, it can see the new allowed bits. | ||
996 | * | ||
997 | * And if setting all new allowed nodes is after the checking, setting | ||
998 | * all new allowed nodes and clearing newly disallowed ones will be done | ||
999 | * continuous, and the read-side task may find no node to alloc page. | ||
1000 | */ | ||
1001 | smp_mb(); | ||
1002 | 988 | ||
1003 | /* | 989 | nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems); |
1004 | * Allocation of memory is very fast, we needn't sleep when waiting | 990 | mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP1); |
1005 | * for the read-side. | ||
1006 | */ | ||
1007 | while (need_loop && ACCESS_ONCE(tsk->mems_allowed_change_disable)) { | ||
1008 | task_unlock(tsk); | ||
1009 | if (!task_curr(tsk)) | ||
1010 | yield(); | ||
1011 | goto repeat; | ||
1012 | } | ||
1013 | |||
1014 | /* | ||
1015 | * ensure checking ->mems_allowed_change_disable before clearing all new | ||
1016 | * disallowed nodes. | ||
1017 | * | ||
1018 | * if clearing newly disallowed bits before the checking, the read-side | ||
1019 | * task may find no node to alloc page. | ||
1020 | */ | ||
1021 | smp_mb(); | ||
1022 | 991 | ||
1023 | mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP2); | 992 | mpol_rebind_task(tsk, newmems, MPOL_REBIND_STEP2); |
1024 | tsk->mems_allowed = *newmems; | 993 | tsk->mems_allowed = *newmems; |
994 | |||
995 | if (need_loop) | ||
996 | write_seqcount_end(&tsk->mems_allowed_seq); | ||
997 | |||
1025 | task_unlock(tsk); | 998 | task_unlock(tsk); |
1026 | } | 999 | } |
1027 | 1000 | ||
@@ -1399,8 +1372,7 @@ static nodemask_t cpuset_attach_nodemask_from; | |||
1399 | static nodemask_t cpuset_attach_nodemask_to; | 1372 | static nodemask_t cpuset_attach_nodemask_to; |
1400 | 1373 | ||
1401 | /* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */ | 1374 | /* Called by cgroups to determine if a cpuset is usable; cgroup_mutex held */ |
1402 | static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 1375 | static int cpuset_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) |
1403 | struct cgroup_taskset *tset) | ||
1404 | { | 1376 | { |
1405 | struct cpuset *cs = cgroup_cs(cgrp); | 1377 | struct cpuset *cs = cgroup_cs(cgrp); |
1406 | struct task_struct *task; | 1378 | struct task_struct *task; |
@@ -1436,8 +1408,7 @@ static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | |||
1436 | return 0; | 1408 | return 0; |
1437 | } | 1409 | } |
1438 | 1410 | ||
1439 | static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 1411 | static void cpuset_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) |
1440 | struct cgroup_taskset *tset) | ||
1441 | { | 1412 | { |
1442 | struct mm_struct *mm; | 1413 | struct mm_struct *mm; |
1443 | struct task_struct *task; | 1414 | struct task_struct *task; |
@@ -1833,8 +1804,7 @@ static int cpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont) | |||
1833 | * (and likewise for mems) to the new cgroup. Called with cgroup_mutex | 1804 | * (and likewise for mems) to the new cgroup. Called with cgroup_mutex |
1834 | * held. | 1805 | * held. |
1835 | */ | 1806 | */ |
1836 | static void cpuset_post_clone(struct cgroup_subsys *ss, | 1807 | static void cpuset_post_clone(struct cgroup *cgroup) |
1837 | struct cgroup *cgroup) | ||
1838 | { | 1808 | { |
1839 | struct cgroup *parent, *child; | 1809 | struct cgroup *parent, *child; |
1840 | struct cpuset *cs, *parent_cs; | 1810 | struct cpuset *cs, *parent_cs; |
@@ -1857,13 +1827,10 @@ static void cpuset_post_clone(struct cgroup_subsys *ss, | |||
1857 | 1827 | ||
1858 | /* | 1828 | /* |
1859 | * cpuset_create - create a cpuset | 1829 | * cpuset_create - create a cpuset |
1860 | * ss: cpuset cgroup subsystem | ||
1861 | * cont: control group that the new cpuset will be part of | 1830 | * cont: control group that the new cpuset will be part of |
1862 | */ | 1831 | */ |
1863 | 1832 | ||
1864 | static struct cgroup_subsys_state *cpuset_create( | 1833 | static struct cgroup_subsys_state *cpuset_create(struct cgroup *cont) |
1865 | struct cgroup_subsys *ss, | ||
1866 | struct cgroup *cont) | ||
1867 | { | 1834 | { |
1868 | struct cpuset *cs; | 1835 | struct cpuset *cs; |
1869 | struct cpuset *parent; | 1836 | struct cpuset *parent; |
@@ -1902,7 +1869,7 @@ static struct cgroup_subsys_state *cpuset_create( | |||
1902 | * will call async_rebuild_sched_domains(). | 1869 | * will call async_rebuild_sched_domains(). |
1903 | */ | 1870 | */ |
1904 | 1871 | ||
1905 | static void cpuset_destroy(struct cgroup_subsys *ss, struct cgroup *cont) | 1872 | static void cpuset_destroy(struct cgroup *cont) |
1906 | { | 1873 | { |
1907 | struct cpuset *cs = cgroup_cs(cont); | 1874 | struct cpuset *cs = cgroup_cs(cont); |
1908 | 1875 | ||