From 7b4092692b2e026261a9b434f71ef9cef992e653 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 9 Feb 2009 09:35:13 +1100 Subject: module:remove-__module_get-BUG_ON Impact: fix spurious BUG_ON() triggered under load module_refcount() isn't reliable outside stop_machine(), as demonstrated by Karsten Keil , networking can trigger it under load (an inc on one cpu and dec on another while module_refcount() is tallying can give false results, for example). Almost noone should be using __module_get, but that's another issue. Cc: Karsten Keil Signed-off-by: Rusty Russell --- include/linux/module.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/module.h b/include/linux/module.h index f3b8329eb5b8..145a75528cc1 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -407,7 +407,6 @@ static inline local_t *__module_ref_addr(struct module *mod, int cpu) static inline void __module_get(struct module *module) { if (module) { - BUG_ON(module_refcount(module) == 0); local_inc(__module_ref_addr(module, get_cpu())); put_cpu(); } -- cgit v1.2.3 From 2bd9413a5deca2b0b764cad0e23dfabd28cbf7fc Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 9 Feb 2009 09:35:13 +1100 Subject: cpumask:remove-address-of-CPU_MASK_ALL (Thanks to Al Viro for reminding me of this, via Ingo) CPU_MASK_ALL is the (deprecated) "all bits set" cpumask, defined as so: #define CPU_MASK_ALL (cpumask_t) { { ... } } Taking the address of such a temporary is questionable at best, unfortunately 321a8e9d (cpumask: add CPU_MASK_ALL_PTR macro) added CPU_MASK_ALL_PTR: #define CPU_MASK_ALL_PTR (&CPU_MASK_ALL) Which formalizes this practice. One day gcc could bite us over this usage (though we seem to have gotten away with it so far). So replace everywhere which used &CPU_MASK_ALL or CPU_MASK_ALL_PTR with the modern "cpu_all_mask" (a real struct cpumask *), and remove CPU_MASK_ALL_PTR altogether. Also remove the confusing and deprecated large-NR_CPUS-only "cpu_mask_all". Signed-off-by: Rusty Russell Cc: Al Viro Cc: Mike Travis --- arch/mips/alchemy/common/time.c | 2 +- arch/sparc/include/asm/topology_64.h | 2 +- arch/x86/include/asm/es7000/apic.h | 2 +- arch/x86/include/asm/numaq/apic.h | 2 +- include/linux/cpumask.h | 6 ------ init/main.c | 7 +------ kernel/kmod.c | 2 +- kernel/kthread.c | 4 ++-- mm/pdflush.c | 2 +- 9 files changed, 9 insertions(+), 20 deletions(-) (limited to 'include/linux') diff --git a/arch/mips/alchemy/common/time.c b/arch/mips/alchemy/common/time.c index 6fd441d16af5..88a9db80eed1 100644 --- a/arch/mips/alchemy/common/time.c +++ b/arch/mips/alchemy/common/time.c @@ -89,7 +89,7 @@ static struct clock_event_device au1x_rtcmatch2_clockdev = { .irq = AU1000_RTC_MATCH2_INT, .set_next_event = au1x_rtcmatch2_set_next_event, .set_mode = au1x_rtcmatch2_set_mode, - .cpumask = CPU_MASK_ALL_PTR, + .cpumask = cpu_all_mask, }; static struct irqaction au1x_rtcmatch2_irqaction = { diff --git a/arch/sparc/include/asm/topology_64.h b/arch/sparc/include/asm/topology_64.h index 5bc0b8fd6374..bb24a085a82d 100644 --- a/arch/sparc/include/asm/topology_64.h +++ b/arch/sparc/include/asm/topology_64.h @@ -49,7 +49,7 @@ static inline int pcibus_to_node(struct pci_bus *pbus) node_to_cpumask(pcibus_to_node(bus))) #define cpumask_of_pcibus(bus) \ (pcibus_to_node(bus) == -1 ? \ - CPU_MASK_ALL_PTR : \ + cpu_all_mask : \ cpumask_of_node(pcibus_to_node(bus))) #define SD_NODE_INIT (struct sched_domain) { \ diff --git a/arch/x86/include/asm/es7000/apic.h b/arch/x86/include/asm/es7000/apic.h index c58b9cc74465..e7216f44bc5b 100644 --- a/arch/x86/include/asm/es7000/apic.h +++ b/arch/x86/include/asm/es7000/apic.h @@ -13,7 +13,7 @@ static inline int apic_id_registered(void) static inline const cpumask_t *target_cpus_cluster(void) { - return &CPU_MASK_ALL; + return cpu_all_mask; } static inline const cpumask_t *target_cpus(void) diff --git a/arch/x86/include/asm/numaq/apic.h b/arch/x86/include/asm/numaq/apic.h index bf37bc49bd8e..316f1969e096 100644 --- a/arch/x86/include/asm/numaq/apic.h +++ b/arch/x86/include/asm/numaq/apic.h @@ -9,7 +9,7 @@ static inline const cpumask_t *target_cpus(void) { - return &CPU_MASK_ALL; + return cpu_all_mask; } #define NO_BALANCE_IRQ (1) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 9f315382610b..e71b26df6a1e 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -324,8 +324,6 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu) [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \ } } -#define CPU_MASK_ALL_PTR (&CPU_MASK_ALL) - #else #define CPU_MASK_ALL \ @@ -334,10 +332,6 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu) [BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD \ } } -/* cpu_mask_all is in init/main.c */ -extern cpumask_t cpu_mask_all; -#define CPU_MASK_ALL_PTR (&cpu_mask_all) - #endif #define CPU_MASK_NONE \ diff --git a/init/main.c b/init/main.c index 844209453c02..730f1a1500de 100644 --- a/init/main.c +++ b/init/main.c @@ -359,11 +359,6 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { } #else -#if NR_CPUS > BITS_PER_LONG -cpumask_t cpu_mask_all __read_mostly = CPU_MASK_ALL; -EXPORT_SYMBOL(cpu_mask_all); -#endif - /* Setup number of possible processor ids */ int nr_cpu_ids __read_mostly = NR_CPUS; EXPORT_SYMBOL(nr_cpu_ids); @@ -834,7 +829,7 @@ static int __init kernel_init(void * unused) /* * init can run on any cpu. */ - set_cpus_allowed_ptr(current, CPU_MASK_ALL_PTR); + set_cpus_allowed_ptr(current, cpu_all_mask); /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. diff --git a/kernel/kmod.c b/kernel/kmod.c index a27a5f64443d..f0c8f545180d 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c @@ -167,7 +167,7 @@ static int ____call_usermodehelper(void *data) } /* We can run anywhere, unlike our parent keventd(). */ - set_cpus_allowed_ptr(current, CPU_MASK_ALL_PTR); + set_cpus_allowed_ptr(current, cpu_all_mask); /* * Our parent is keventd, which runs with elevated scheduling priority. diff --git a/kernel/kthread.c b/kernel/kthread.c index 4fbc456f393d..84bbadd4d021 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -110,7 +110,7 @@ static void create_kthread(struct kthread_create_info *create) */ sched_setscheduler(create->result, SCHED_NORMAL, ¶m); set_user_nice(create->result, KTHREAD_NICE_LEVEL); - set_cpus_allowed_ptr(create->result, CPU_MASK_ALL_PTR); + set_cpus_allowed_ptr(create->result, cpu_all_mask); } complete(&create->done); } @@ -240,7 +240,7 @@ int kthreadd(void *unused) set_task_comm(tsk, "kthreadd"); ignore_signals(tsk); set_user_nice(tsk, KTHREAD_NICE_LEVEL); - set_cpus_allowed_ptr(tsk, CPU_MASK_ALL_PTR); + set_cpus_allowed_ptr(tsk, cpu_all_mask); current->flags |= PF_NOFREEZE | PF_FREEZER_NOSIG; diff --git a/mm/pdflush.c b/mm/pdflush.c index 15de509b68fd..118905e3d788 100644 --- a/mm/pdflush.c +++ b/mm/pdflush.c @@ -191,7 +191,7 @@ static int pdflush(void *dummy) /* * Some configs put our parent kthread in a limited cpuset, - * which kthread() overrides, forcing cpus_allowed == CPU_MASK_ALL. + * which kthread() overrides, forcing cpus_allowed == cpu_all_mask. * Our needs are more modest - cut back to our cpusets cpus_allowed. * This is needed as pdflush's are dynamically created and destroyed. * The boottime pdflush's are easily placed w/o these 2 lines. -- cgit v1.2.3 From 20a46fa4315d345ac7565540fefcb008ea241923 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 9 Feb 2009 09:35:13 +1100 Subject: cpumask:fix-cpu_online_map-etc-assignment James Bottomley encountered a Voyager bug where gcc was discarding changes to cpu_possible_map, which is now #defined to cpu_possible_mask with the const cast away. The modern way is to use init_cpu_possible or set_cpu_possible, but not everyone is converted yet. I'm concerned that other archs might have similar problems, so let's expose the underlying bits for the moment (and prepend those names with __). (This also makes accessing cpu_*_mask slightly more efficient, rather than going via a pointer). Signed-off-by: Rusty Russell Cc: James.Bottomley@HansenPartnership.com Cc: Ingo Molnar Cc: Mike Travis --- include/linux/cpumask.h | 30 ++++++++++++++++++++---------- kernel/cpu.c | 44 ++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 34 deletions(-) (limited to 'include/linux') diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index e71b26df6a1e..1846731651d2 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -476,16 +476,26 @@ int __next_cpu_nr(int n, const cpumask_t *srcp); * only one CPU. */ -extern const struct cpumask *const cpu_possible_mask; -extern const struct cpumask *const cpu_online_mask; -extern 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) +#define cpu_possible_mask \ + ((const struct cpumask *)to_cpumask(__cpu_possible_bits)) +#define cpu_online_mask \ + ((const struct cpumask *)to_cpumask(__cpu_online_bits)) +#define cpu_present_mask \ + ((const struct cpumask *)to_cpumask(__cpu_present_bits)) +#define cpu_active_mask \ + ((const struct cpumask *)to_cpumask(__cpu_active_bits)) + +/* Deprecated non-const versions. */ +#define cpu_possible_map (*to_cpumask(__cpu_possible_bits)) +#define cpu_online_map (*to_cpumask(__cpu_online_bits)) +#define cpu_present_map (*to_cpumask(__cpu_present_bits)) +#define cpu_active_map (*to_cpumask(__cpu_active_bits)) + +/* Don't use these directly: use cpu_*_mask, set_cpu_* or init_cpu_*. */ +extern unsigned long __cpu_possible_bits[]; +extern unsigned long __cpu_online_bits[]; +extern unsigned long __cpu_present_bits[]; +extern unsigned long __cpu_active_bits[]; #if NR_CPUS > 1 #define num_online_cpus() cpumask_weight(cpu_online_mask) diff --git a/kernel/cpu.c b/kernel/cpu.c index 79e40f00dcb8..a9033184bfff 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -499,69 +499,65 @@ const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL; EXPORT_SYMBOL(cpu_all_bits); #ifdef CONFIG_INIT_ALL_POSSIBLE -static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly +DECLARE_BITMAP(__cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly = CPU_BITS_ALL; #else -static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly; +DECLARE_BITMAP(__cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly; #endif -const struct cpumask *const cpu_possible_mask = to_cpumask(cpu_possible_bits); -EXPORT_SYMBOL(cpu_possible_mask); +EXPORT_SYMBOL(__cpu_possible_bits); -static DECLARE_BITMAP(cpu_online_bits, CONFIG_NR_CPUS) __read_mostly; -const struct cpumask *const cpu_online_mask = to_cpumask(cpu_online_bits); -EXPORT_SYMBOL(cpu_online_mask); +DECLARE_BITMAP(__cpu_online_bits, CONFIG_NR_CPUS) __read_mostly; +EXPORT_SYMBOL(__cpu_online_bits); -static DECLARE_BITMAP(cpu_present_bits, CONFIG_NR_CPUS) __read_mostly; -const struct cpumask *const cpu_present_mask = to_cpumask(cpu_present_bits); -EXPORT_SYMBOL(cpu_present_mask); +DECLARE_BITMAP(__cpu_present_bits, CONFIG_NR_CPUS) __read_mostly; +EXPORT_SYMBOL(__cpu_present_bits); -static DECLARE_BITMAP(cpu_active_bits, CONFIG_NR_CPUS) __read_mostly; -const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits); -EXPORT_SYMBOL(cpu_active_mask); +DECLARE_BITMAP(__cpu_active_bits, CONFIG_NR_CPUS) __read_mostly; +EXPORT_SYMBOL(__cpu_active_bits); void set_cpu_possible(unsigned int cpu, bool possible) { if (possible) - cpumask_set_cpu(cpu, to_cpumask(cpu_possible_bits)); + cpumask_set_cpu(cpu, to_cpumask(__cpu_possible_bits)); else - cpumask_clear_cpu(cpu, to_cpumask(cpu_possible_bits)); + cpumask_clear_cpu(cpu, to_cpumask(__cpu_possible_bits)); } void set_cpu_present(unsigned int cpu, bool present) { if (present) - cpumask_set_cpu(cpu, to_cpumask(cpu_present_bits)); + cpumask_set_cpu(cpu, to_cpumask(__cpu_present_bits)); else - cpumask_clear_cpu(cpu, to_cpumask(cpu_present_bits)); + cpumask_clear_cpu(cpu, to_cpumask(__cpu_present_bits)); } void set_cpu_online(unsigned int cpu, bool online) { if (online) - cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits)); + cpumask_set_cpu(cpu, to_cpumask(__cpu_online_bits)); else - cpumask_clear_cpu(cpu, to_cpumask(cpu_online_bits)); + cpumask_clear_cpu(cpu, to_cpumask(__cpu_online_bits)); } void set_cpu_active(unsigned int cpu, bool active) { if (active) - cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits)); + cpumask_set_cpu(cpu, to_cpumask(__cpu_active_bits)); else - cpumask_clear_cpu(cpu, to_cpumask(cpu_active_bits)); + cpumask_clear_cpu(cpu, to_cpumask(__cpu_active_bits)); } void init_cpu_present(const struct cpumask *src) { - cpumask_copy(to_cpumask(cpu_present_bits), src); + cpumask_copy(to_cpumask(__cpu_present_bits), src); } void init_cpu_possible(const struct cpumask *src) { - cpumask_copy(to_cpumask(cpu_possible_bits), src); + cpumask_copy(to_cpumask(__cpu_possible_bits), src); } void init_cpu_online(const struct cpumask *src) { - cpumask_copy(to_cpumask(cpu_online_bits), src); + cpumask_copy(to_cpumask(__cpu_online_bits), src); } -- cgit v1.2.3