cpumask: partition_sched_domains takes array of cpumask_var_t
PATCH 2/14 cpumask: partition_sched_domains takes array of cpumask_var_t
Currently partition_sched_domains() takes a 'struct cpumask *doms_new' which is a kmalloc'ed array of cpumask_t. You can't have such an array if 'struct cpumask' is undefined, as we plan for CONFIG_CPUMASK_OFFSTACK=y.
So, we make this an array of cpumask_var_t instead: this is the same for the CONFIG_CPUMASK_OFFSTACK=n case, but requires multiple allocations for the CONFIG_CPUMASK_OFFSTACK=y case. Hence we add alloc_sched_domains() and free_sched_domains() functions.
To: Ingo Molnar <[email protected]>
To: Peter Zijlstra <[email protected]>
--- include/linux/sched.h | 8 ++++- kernel/cpuset.c | 19 ++++++------- kernel/sched.c | 68 +++++++++++++++++++++++++++++++++----------------- 3 files changed, 61 insertions(+), 34 deletions(-)
include/linux/sched.h +6 -2
@@ -934,8 +934,12 @@ static inline struct cpumask *sched_domareturn to_cpumask (sd->span); } -extern void partition_sched_domains (int ndoms_new,struct cpumask *doms_new, +extern void partition_sched_domains (int ndoms_new,cpumask_var_t doms_new[],struct sched_domain_attr *dattr_new); + +/* Allocate an array of sched domains, for partition_sched_domains(). */ +cpumask_var_t *alloc_sched_domains (unsigned int ndoms); +void free_sched_domains (cpumask_var_t doms[],unsigned int ndoms);/* Test a flag in parent sched domain */ static inline int test_sd_parent (struct sched_domain *sd,int flag)
@@ -951,7 +955,7 @@ struct sched_domain_attr;struct sched_domain_attr ;static inline void -partition_sched_domains (int ndoms_new,struct cpumask *doms_new, +partition_sched_domains (int ndoms_new,cpumask_var_t doms_new[],struct sched_domain_attr *dattr_new) { }
kernel/cpuset.c +9 -10
@@ -619,8 +619,7 @@ update_domain_attr_tree(struct sched_dom* element of the partition (one sched domain) to be passed to * partition_sched_domains(). */ -/* FIXME: see the FIXME in partition_sched_domains() */ -static int generate_sched_domains (struct cpumask **domains, +static int generate_sched_domains (cpumask_var_t **domains,struct sched_domain_attr **attributes) {LIST_HEAD (q);/* queue of cpusets to be scanned */
@@ -628,7 +627,7 @@ static int generate_sched_domains(structstruct cpuset **csa;/* array of all cpuset ptrs */ int csn;/* how many cpuset ptrs in csa so far */ int i, j, k;/* indices for partition finding loops */ -struct cpumask *doms;/* resulting partition; i.e. sched domains */ +cpumask_var_t *doms;/* resulting partition; i.e. sched domains */ struct sched_domain_attr *dattr;/* attributes for custom domains */ int ndoms =0 ;/* number of sched domains in result */ int nslot;/* next empty doms[] struct cpumask slot */
@@ -639,7 +638,8 @@ static int generate_sched_domains(struct/* Special case for the 99% of systems with one, full, sched domain */ if (is_sched_load_balance (&top_cpuset)) { - doms =kmalloc (cpumask_size (),GFP_KERNEL ); + ndoms =1 ; + doms =alloc_sched_domains (ndoms);if (!doms) goto done;
@@ -648,9 +648,8 @@ static int generate_sched_domains(struct *dattr =SD_ATTR_INIT ;update_domain_attr_tree (dattr, &top_cpuset); } -cpumask_copy (doms, top_cpuset.cpus_allowed); +cpumask_copy (doms[0 ], top_cpuset.cpus_allowed); - ndoms =1 ; goto done; }
@@ -718,7 +717,7 @@ restart:* Now we know how many domains to create. * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. */ - doms =kmalloc (ndoms *cpumask_size (),GFP_KERNEL ); + doms =alloc_sched_domains (ndoms);if (!doms) goto done;
@@ -738,7 +737,7 @@ restart:continue ; } - dp = doms + nslot; + dp = doms[nslot];if (nslot == ndoms) {static int warnings =10 ;
@@ -800,7 +799,7 @@ static void do_rebuild_sched_domains(strstatic void do_rebuild_sched_domains (struct work_struct *unused) {struct sched_domain_attr *attr; -struct cpumask *doms; +cpumask_var_t *doms;int ndoms;get_online_cpus ();
@@ -2054,7 +2053,7 @@ static int cpuset_track_online_cpus(stru unsigned long phase, void *unused_cpu) { struct sched_domain_attr *attr; -struct cpumask *doms; +cpumask_var_t *doms;int ndoms;switch (phase) {
kernel/sched.c +46 -22
138 lines not on this page · raw message
[tip:sched/core] cpumask: Partition_sched_domains takes array of cpumask_var_t
Commit-ID: acc3f5d7cabbfd6cec71f0c1f9900621fa2d6ae7 Gitweb: http://git.kernel.org/tip/acc3f5d7cabbfd6cec71f0c1f9900621fa2d6ae7 Author: Rusty Russell <[email protected]> AuthorDate: Tue, 3 Nov 2009 14:53:40 +1030 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 4 Nov 2009 13:16:40 +0100
cpumask: Partition_sched_domains takes array of cpumask_var_t
Currently partition_sched_domains() takes a 'struct cpumask *doms_new' which is a kmalloc'ed array of cpumask_t. You can't have such an array if 'struct cpumask' is undefined, as we plan for CONFIG_CPUMASK_OFFSTACK=y.
So, we make this an array of cpumask_var_t instead: this is the same for the CONFIG_CPUMASK_OFFSTACK=n case, but requires multiple allocations for the CONFIG_CPUMASK_OFFSTACK=y case. Hence we add alloc_sched_domains() and free_sched_domains() functions.
LKML-Reference: <[email protected]>
--- include/linux/sched.h | 8 ++++- kernel/cpuset.c | 19 ++++++------- kernel/sched.c | 68 +++++++++++++++++++++++++++++++++---------------- 3 files changed, 61 insertions(+), 34 deletions(-)
include/linux/sched.h +6 -2
@@ -1009,9 +1009,13 @@ static inline struct cpumask *sched_domain_span(struct sched_domain *sd)return to_cpumask (sd->span); } -extern void partition_sched_domains (int ndoms_new,struct cpumask *doms_new, +extern void partition_sched_domains (int ndoms_new,cpumask_var_t doms_new[],struct sched_domain_attr *dattr_new); +/* Allocate an array of sched domains, for partition_sched_domains(). */ +cpumask_var_t *alloc_sched_domains (unsigned int ndoms); +void free_sched_domains (cpumask_var_t doms[],unsigned int ndoms); +/* Test a flag in parent sched domain */ static inline int test_sd_parent (struct sched_domain *sd,int flag) {
@@ -1029,7 +1033,7 @@ unsigned long default_scale_smt_power(struct sched_domain *sd, int cpu);struct sched_domain_attr ;static inline void -partition_sched_domains (int ndoms_new,struct cpumask *doms_new, +partition_sched_domains (int ndoms_new,cpumask_var_t doms_new[],struct sched_domain_attr *dattr_new) { }
kernel/cpuset.c +9 -10
@@ -537,8 +537,7 @@ update_domain_attr_tree(struct sched_domain_attr *dattr, struct cpuset *c)* element of the partition (one sched domain) to be passed to * partition_sched_domains(). */ -/* FIXME: see the FIXME in partition_sched_domains() */ -static int generate_sched_domains (struct cpumask **domains, +static int generate_sched_domains (cpumask_var_t **domains,struct sched_domain_attr **attributes) {LIST_HEAD (q);/* queue of cpusets to be scanned */
@@ -546,7 +545,7 @@ static int generate_sched_domains(struct cpumask **domains,struct cpuset **csa;/* array of all cpuset ptrs */ int csn;/* how many cpuset ptrs in csa so far */ int i, j, k;/* indices for partition finding loops */ -struct cpumask *doms;/* resulting partition; i.e. sched domains */ +cpumask_var_t *doms;/* resulting partition; i.e. sched domains */ struct sched_domain_attr *dattr;/* attributes for custom domains */ int ndoms =0 ;/* number of sched domains in result */ int nslot;/* next empty doms[] struct cpumask slot */
@@ -557,7 +556,8 @@ static int generate_sched_domains(struct cpumask **domains,/* Special case for the 99% of systems with one, full, sched domain */ if (is_sched_load_balance (&top_cpuset)) { - doms =kmalloc (cpumask_size (),GFP_KERNEL ); + ndoms =1 ; + doms =alloc_sched_domains (ndoms);if (!doms) goto done;
@@ -566,9 +566,8 @@ static int generate_sched_domains(struct cpumask **domains, *dattr =SD_ATTR_INIT ;update_domain_attr_tree (dattr, &top_cpuset); } -cpumask_copy (doms, top_cpuset.cpus_allowed); +cpumask_copy (doms[0 ], top_cpuset.cpus_allowed); - ndoms =1 ; goto done; }
@@ -636,7 +635,7 @@ restart:* Now we know how many domains to create. * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. */ - doms =kmalloc (ndoms *cpumask_size (),GFP_KERNEL ); + doms =alloc_sched_domains (ndoms);if (!doms) goto done;
@@ -656,7 +655,7 @@ restart:continue ; } - dp = doms + nslot; + dp = doms[nslot];if (nslot == ndoms) {static int warnings =10 ;
@@ -718,7 +717,7 @@ done:static void do_rebuild_sched_domains (struct work_struct *unused) {struct sched_domain_attr *attr; -struct cpumask *doms; +cpumask_var_t *doms;int ndoms;get_online_cpus ();
@@ -2052,7 +2051,7 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb, unsigned long phase, void *unused_cpu) { struct sched_domain_attr *attr; -struct cpumask *doms; +cpumask_var_t *doms;int ndoms;switch (phase) {
kernel/sched.c +46 -22
138 lines not on this page · raw message