sched: properly define the sched_group::cpumask and sched_domain::span fields
Properly document the variable-size structure tricks we are doing wrt. struct sched_group and sched_domain, and use the field[0] GCC extension instead of defining a vla array. Dont use unions for this, as pointed out by Linus. [ Impact: cleanup, un-confuse Sparse and LLVM ] Reported-by: Jeff Garzik <jeff@garzik.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> LKML-Reference: <alpine.LFD.2.01.0905180850110.3301@localhost.localdomain> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
2d02494f5a
commit
4200efd9ac
|
@ -839,7 +839,17 @@ struct sched_group {
|
||||||
*/
|
*/
|
||||||
u32 reciprocal_cpu_power;
|
u32 reciprocal_cpu_power;
|
||||||
|
|
||||||
unsigned long cpumask[];
|
/*
|
||||||
|
* The CPUs this group covers.
|
||||||
|
*
|
||||||
|
* NOTE: this field is variable length. (Allocated dynamically
|
||||||
|
* by attaching extra space to the end of the structure,
|
||||||
|
* depending on how many CPUs the kernel has booted up with)
|
||||||
|
*
|
||||||
|
* It is also be embedded into static data structures at build
|
||||||
|
* time. (See 'struct static_sched_group' in kernel/sched.c)
|
||||||
|
*/
|
||||||
|
unsigned long cpumask[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct cpumask *sched_group_cpus(struct sched_group *sg)
|
static inline struct cpumask *sched_group_cpus(struct sched_group *sg)
|
||||||
|
@ -925,8 +935,17 @@ struct sched_domain {
|
||||||
char *name;
|
char *name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* span of all CPUs in this domain */
|
/*
|
||||||
unsigned long span[];
|
* Span of all CPUs in this domain.
|
||||||
|
*
|
||||||
|
* NOTE: this field is variable length. (Allocated dynamically
|
||||||
|
* by attaching extra space to the end of the structure,
|
||||||
|
* depending on how many CPUs the kernel has booted up with)
|
||||||
|
*
|
||||||
|
* It is also be embedded into static data structures at build
|
||||||
|
* time. (See 'struct static_sched_domain' in kernel/sched.c)
|
||||||
|
*/
|
||||||
|
unsigned long span[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct cpumask *sched_domain_span(struct sched_domain *sd)
|
static inline struct cpumask *sched_domain_span(struct sched_domain *sd)
|
||||||
|
|
|
@ -7948,8 +7948,9 @@ int sched_smt_power_savings = 0, sched_mc_power_savings = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The cpus mask in sched_group and sched_domain hangs off the end.
|
* The cpus mask in sched_group and sched_domain hangs off the end.
|
||||||
* FIXME: use cpumask_var_t or dynamic percpu alloc to avoid wasting space
|
*
|
||||||
* for nr_cpu_ids < CONFIG_NR_CPUS.
|
* ( See the the comments in include/linux/sched.h:struct sched_group
|
||||||
|
* and struct sched_domain. )
|
||||||
*/
|
*/
|
||||||
struct static_sched_group {
|
struct static_sched_group {
|
||||||
struct sched_group sg;
|
struct sched_group sg;
|
||||||
|
|
Loading…
Reference in New Issue