diff options
-rw-r--r-- | kernel/cpuset.c | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index f9d4807c869f..ef0974c73b4b 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -76,8 +76,14 @@ struct cpuset { | |||
76 | struct cgroup_subsys_state css; | 76 | struct cgroup_subsys_state css; |
77 | 77 | ||
78 | unsigned long flags; /* "unsigned long" so bitops work */ | 78 | unsigned long flags; /* "unsigned long" so bitops work */ |
79 | cpumask_var_t cpus_allowed; /* CPUs allowed to tasks in cpuset */ | 79 | |
80 | nodemask_t mems_allowed; /* Memory Nodes allowed to tasks */ | 80 | /* user-configured CPUs and Memory Nodes allow to tasks */ |
81 | cpumask_var_t cpus_allowed; | ||
82 | nodemask_t mems_allowed; | ||
83 | |||
84 | /* effective CPUs and Memory Nodes allow to tasks */ | ||
85 | cpumask_var_t effective_cpus; | ||
86 | nodemask_t effective_mems; | ||
81 | 87 | ||
82 | /* | 88 | /* |
83 | * This is old Memory Nodes tasks took on. | 89 | * This is old Memory Nodes tasks took on. |
@@ -376,13 +382,20 @@ static struct cpuset *alloc_trial_cpuset(struct cpuset *cs) | |||
376 | if (!trial) | 382 | if (!trial) |
377 | return NULL; | 383 | return NULL; |
378 | 384 | ||
379 | if (!alloc_cpumask_var(&trial->cpus_allowed, GFP_KERNEL)) { | 385 | if (!alloc_cpumask_var(&trial->cpus_allowed, GFP_KERNEL)) |
380 | kfree(trial); | 386 | goto free_cs; |
381 | return NULL; | 387 | if (!alloc_cpumask_var(&trial->effective_cpus, GFP_KERNEL)) |
382 | } | 388 | goto free_cpus; |
383 | cpumask_copy(trial->cpus_allowed, cs->cpus_allowed); | ||
384 | 389 | ||
390 | cpumask_copy(trial->cpus_allowed, cs->cpus_allowed); | ||
391 | cpumask_copy(trial->effective_cpus, cs->effective_cpus); | ||
385 | return trial; | 392 | return trial; |
393 | |||
394 | free_cpus: | ||
395 | free_cpumask_var(trial->cpus_allowed); | ||
396 | free_cs: | ||
397 | kfree(trial); | ||
398 | return NULL; | ||
386 | } | 399 | } |
387 | 400 | ||
388 | /** | 401 | /** |
@@ -391,6 +404,7 @@ static struct cpuset *alloc_trial_cpuset(struct cpuset *cs) | |||
391 | */ | 404 | */ |
392 | static void free_trial_cpuset(struct cpuset *trial) | 405 | static void free_trial_cpuset(struct cpuset *trial) |
393 | { | 406 | { |
407 | free_cpumask_var(trial->effective_cpus); | ||
394 | free_cpumask_var(trial->cpus_allowed); | 408 | free_cpumask_var(trial->cpus_allowed); |
395 | kfree(trial); | 409 | kfree(trial); |
396 | } | 410 | } |
@@ -1848,18 +1862,26 @@ cpuset_css_alloc(struct cgroup_subsys_state *parent_css) | |||
1848 | cs = kzalloc(sizeof(*cs), GFP_KERNEL); | 1862 | cs = kzalloc(sizeof(*cs), GFP_KERNEL); |
1849 | if (!cs) | 1863 | if (!cs) |
1850 | return ERR_PTR(-ENOMEM); | 1864 | return ERR_PTR(-ENOMEM); |
1851 | if (!alloc_cpumask_var(&cs->cpus_allowed, GFP_KERNEL)) { | 1865 | if (!alloc_cpumask_var(&cs->cpus_allowed, GFP_KERNEL)) |
1852 | kfree(cs); | 1866 | goto free_cs; |
1853 | return ERR_PTR(-ENOMEM); | 1867 | if (!alloc_cpumask_var(&cs->effective_cpus, GFP_KERNEL)) |
1854 | } | 1868 | goto free_cpus; |
1855 | 1869 | ||
1856 | set_bit(CS_SCHED_LOAD_BALANCE, &cs->flags); | 1870 | set_bit(CS_SCHED_LOAD_BALANCE, &cs->flags); |
1857 | cpumask_clear(cs->cpus_allowed); | 1871 | cpumask_clear(cs->cpus_allowed); |
1858 | nodes_clear(cs->mems_allowed); | 1872 | nodes_clear(cs->mems_allowed); |
1873 | cpumask_clear(cs->effective_cpus); | ||
1874 | nodes_clear(cs->effective_mems); | ||
1859 | fmeter_init(&cs->fmeter); | 1875 | fmeter_init(&cs->fmeter); |
1860 | cs->relax_domain_level = -1; | 1876 | cs->relax_domain_level = -1; |
1861 | 1877 | ||
1862 | return &cs->css; | 1878 | return &cs->css; |
1879 | |||
1880 | free_cpus: | ||
1881 | free_cpumask_var(cs->cpus_allowed); | ||
1882 | free_cs: | ||
1883 | kfree(cs); | ||
1884 | return ERR_PTR(-ENOMEM); | ||
1863 | } | 1885 | } |
1864 | 1886 | ||
1865 | static int cpuset_css_online(struct cgroup_subsys_state *css) | 1887 | static int cpuset_css_online(struct cgroup_subsys_state *css) |
@@ -1882,6 +1904,13 @@ static int cpuset_css_online(struct cgroup_subsys_state *css) | |||
1882 | 1904 | ||
1883 | cpuset_inc(); | 1905 | cpuset_inc(); |
1884 | 1906 | ||
1907 | mutex_lock(&callback_mutex); | ||
1908 | if (cgroup_on_dfl(cs->css.cgroup)) { | ||
1909 | cpumask_copy(cs->effective_cpus, parent->effective_cpus); | ||
1910 | cs->effective_mems = parent->effective_mems; | ||
1911 | } | ||
1912 | mutex_unlock(&callback_mutex); | ||
1913 | |||
1885 | if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags)) | 1914 | if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags)) |
1886 | goto out_unlock; | 1915 | goto out_unlock; |
1887 | 1916 | ||
@@ -1941,6 +1970,7 @@ static void cpuset_css_free(struct cgroup_subsys_state *css) | |||
1941 | { | 1970 | { |
1942 | struct cpuset *cs = css_cs(css); | 1971 | struct cpuset *cs = css_cs(css); |
1943 | 1972 | ||
1973 | free_cpumask_var(cs->effective_cpus); | ||
1944 | free_cpumask_var(cs->cpus_allowed); | 1974 | free_cpumask_var(cs->cpus_allowed); |
1945 | kfree(cs); | 1975 | kfree(cs); |
1946 | } | 1976 | } |
@@ -1969,9 +1999,13 @@ int __init cpuset_init(void) | |||
1969 | 1999 | ||
1970 | if (!alloc_cpumask_var(&top_cpuset.cpus_allowed, GFP_KERNEL)) | 2000 | if (!alloc_cpumask_var(&top_cpuset.cpus_allowed, GFP_KERNEL)) |
1971 | BUG(); | 2001 | BUG(); |
2002 | if (!alloc_cpumask_var(&top_cpuset.effective_cpus, GFP_KERNEL)) | ||
2003 | BUG(); | ||
1972 | 2004 | ||
1973 | cpumask_setall(top_cpuset.cpus_allowed); | 2005 | cpumask_setall(top_cpuset.cpus_allowed); |
1974 | nodes_setall(top_cpuset.mems_allowed); | 2006 | nodes_setall(top_cpuset.mems_allowed); |
2007 | cpumask_setall(top_cpuset.effective_cpus); | ||
2008 | nodes_setall(top_cpuset.effective_mems); | ||
1975 | 2009 | ||
1976 | fmeter_init(&top_cpuset.fmeter); | 2010 | fmeter_init(&top_cpuset.fmeter); |
1977 | set_bit(CS_SCHED_LOAD_BALANCE, &top_cpuset.flags); | 2011 | set_bit(CS_SCHED_LOAD_BALANCE, &top_cpuset.flags); |
@@ -2207,6 +2241,9 @@ void __init cpuset_init_smp(void) | |||
2207 | top_cpuset.mems_allowed = node_states[N_MEMORY]; | 2241 | top_cpuset.mems_allowed = node_states[N_MEMORY]; |
2208 | top_cpuset.old_mems_allowed = top_cpuset.mems_allowed; | 2242 | top_cpuset.old_mems_allowed = top_cpuset.mems_allowed; |
2209 | 2243 | ||
2244 | cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask); | ||
2245 | top_cpuset.effective_mems = node_states[N_MEMORY]; | ||
2246 | |||
2210 | register_hotmemory_notifier(&cpuset_track_online_nodes_nb); | 2247 | register_hotmemory_notifier(&cpuset_track_online_nodes_nb); |
2211 | } | 2248 | } |
2212 | 2249 | ||