cpumask: avoid cast-away-const for deprecated cpu_*_map.
Subsystems (2)
PATCH 1/1 cpumask: avoid cast-away-const for deprecated cpu_*_map.
Impact: fix potential (non-x86) SMP boot failure with some gcc versions
The deprecated cpu_*_map are currently #defined to the new cpu_*_mask, except without the const. Some versions of gcc seem to dislike this, and I suspect this will break boot for some archs with the "wrong" gcc version.
So play it safe and use real vars until we kill them all (replacements are init_*_map(), set_cpu_*() and cpu_*_mask).
PowerPC and Alpha have reported warnings, and James Bottomley encountered worse: gcc was simply not changing cpu_possible_map, causing boot failure (fixed by using init_cpu_possible()).
See also:
Alpha gcc 4.2 warning fix:
ee0c468bb151aad23281660152d2894f1e214238 Voyager bug report: lkml: [PATCH] voyager: fix cpu bootmaps Message-Id: <[email protected]> (Merged without comments in 92ab78315c638515d0e81b0c70b2082f713582d9)
Signed-off-by Rusty Russell <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc Mike Travis <[email protected]>
--- include/linux/cpumask.h | 14 +++++++++----- kernel/cpu.c | 10 ++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-)
include/linux/cpumask.h +9 -5
@@ -487,11 +487,15 @@ extern const struct cpumask *const cpu_pextern const struct cpumask *const cpu_present_mask;extern const struct cpumask *const cpu_active_mask; -/* These strip const, as traditionally they weren't const. */ -#define cpu_possible_map (*(cpumask_t *)cpu_possible_mask) -#define cpu_online_map (*(cpumask_t *)cpu_online_mask) -#define cpu_present_map (*(cpumask_t *)cpu_present_mask) -#define cpu_active_map (*(cpumask_t *)cpu_active_mask) +/* Deprecated: use cpu_*_mask and set_cpu_*(). */ +#define cpu_possible_map (*_cpu_possible_mask_nonconst) +#define cpu_online_map (*_cpu_online_mask_nonconst) +#define cpu_present_map (*_cpu_present_mask_nonconst) +#define cpu_active_map (*_cpu_active_mask_nonconst) +extern struct cpumask *_cpu_possible_mask_nonconst; +extern struct cpumask *_cpu_online_mask_nonconst; +extern struct cpumask *_cpu_present_mask_nonconst; +extern struct cpumask *_cpu_active_mask_nonconst;#if NR_CPUS >1 #define num_online_cpus () cpumask_weight(cpu_online_mask)
kernel/cpu.c +10 -0
@@ -565,3 +565,13 @@ void init_cpu_online(const struct cpumas {cpumask_copy (to_cpumask (cpu_online_bits), src); } + +/* Deprecated accessors. */ +struct cpumask *_cpu_possible_mask_nonconst =to_cpumask (cpu_possible_bits); +EXPORT_SYMBOL (_cpu_possible_mask_nonconst); +struct cpumask *_cpu_online_mask_nonconst =to_cpumask (cpu_online_bits); +EXPORT_SYMBOL (_cpu_online_mask_nonconst); +struct cpumask *_cpu_present_mask_nonconst =to_cpumask (cpu_present_bits); +EXPORT_SYMBOL (_cpu_present_mask_nonconst); +struct cpumask *_cpu_active_mask_nonconst =to_cpumask (cpu_active_bits); +EXPORT_SYMBOL (_cpu_active_mask_nonconst);