diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-10 09:12:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-10 09:12:18 -0500 |
commit | 4e9b1c184cadbece3694603de5f880b6e35bd7a7 (patch) | |
tree | 8ae2ab8a4eaab4d46b4460284fd5ee475ce9a42d | |
parent | 0176260fc30842e358cf34afa7dcd9413db44822 (diff) | |
parent | 36c401a44abcc389a00f9cd14892c9cf9bf0780d (diff) |
Merge branch 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
[IA64] fix typo in cpumask_of_pcibus()
x86: fix x86_32 builds for summit and es7000 arch's
cpumask: use work_on_cpu in acpi-cpufreq.c for read_measured_perf_ctrs
cpumask: use work_on_cpu in acpi-cpufreq.c for drv_read and drv_write
cpumask: use cpumask_var_t in acpi-cpufreq.c
cpumask: use work_on_cpu in acpi/cstate.c
cpumask: convert struct cpufreq_policy to cpumask_var_t
cpumask: replace CPUMASK_ALLOC etc with cpumask_var_t
x86: cleanup remaining cpumask_t ops in smpboot code
cpumask: update pci_bus_show_cpuaffinity to use new cpumask API
cpumask: update local_cpus_show to use new cpumask API
ia64: cpumask fix for is_affinity_mask_valid()
23 files changed, 363 insertions, 268 deletions
diff --git a/arch/ia64/include/asm/irq.h b/arch/ia64/include/asm/irq.h index 36429a532630..5282546cdf82 100644 --- a/arch/ia64/include/asm/irq.h +++ b/arch/ia64/include/asm/irq.h | |||
@@ -27,7 +27,7 @@ irq_canonicalize (int irq) | |||
27 | } | 27 | } |
28 | 28 | ||
29 | extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); | 29 | extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); |
30 | bool is_affinity_mask_valid(cpumask_var_t cpumask); | 30 | bool is_affinity_mask_valid(const struct cpumask *cpumask); |
31 | 31 | ||
32 | #define is_affinity_mask_valid is_affinity_mask_valid | 32 | #define is_affinity_mask_valid is_affinity_mask_valid |
33 | 33 | ||
diff --git a/arch/ia64/include/asm/topology.h b/arch/ia64/include/asm/topology.h index 76a33a91ca69..32f3af1641c5 100644 --- a/arch/ia64/include/asm/topology.h +++ b/arch/ia64/include/asm/topology.h | |||
@@ -124,7 +124,7 @@ extern void arch_fix_phys_package_id(int num, u32 slot); | |||
124 | 124 | ||
125 | #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \ | 125 | #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \ |
126 | cpu_all_mask : \ | 126 | cpu_all_mask : \ |
127 | cpumask_from_node(pcibus_to_node(bus))) | 127 | cpumask_of_node(pcibus_to_node(bus))) |
128 | 128 | ||
129 | #include <asm-generic/topology.h> | 129 | #include <asm-generic/topology.h> |
130 | 130 | ||
diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c index 95ff16cb05d8..a58f64ca9f0e 100644 --- a/arch/ia64/kernel/irq.c +++ b/arch/ia64/kernel/irq.c | |||
@@ -102,17 +102,14 @@ static char irq_redir [NR_IRQS]; // = { [0 ... NR_IRQS-1] = 1 }; | |||
102 | 102 | ||
103 | void set_irq_affinity_info (unsigned int irq, int hwid, int redir) | 103 | void set_irq_affinity_info (unsigned int irq, int hwid, int redir) |
104 | { | 104 | { |
105 | cpumask_t mask = CPU_MASK_NONE; | ||
106 | |||
107 | cpu_set(cpu_logical_id(hwid), mask); | ||
108 | |||
109 | if (irq < NR_IRQS) { | 105 | if (irq < NR_IRQS) { |
110 | irq_desc[irq].affinity = mask; | 106 | cpumask_copy(&irq_desc[irq].affinity, |
107 | cpumask_of(cpu_logical_id(hwid))); | ||
111 | irq_redir[irq] = (char) (redir & 0xff); | 108 | irq_redir[irq] = (char) (redir & 0xff); |
112 | } | 109 | } |
113 | } | 110 | } |
114 | 111 | ||
115 | bool is_affinity_mask_valid(cpumask_var_t cpumask) | 112 | bool is_affinity_mask_valid(const struct cpumask *cpumask) |
116 | { | 113 | { |
117 | if (ia64_platform_is("sn2")) { | 114 | if (ia64_platform_is("sn2")) { |
118 | /* Only allow one CPU to be specified in the smp_affinity mask */ | 115 | /* Only allow one CPU to be specified in the smp_affinity mask */ |
@@ -128,7 +125,7 @@ bool is_affinity_mask_valid(cpumask_var_t cpumask) | |||
128 | unsigned int vectors_in_migration[NR_IRQS]; | 125 | unsigned int vectors_in_migration[NR_IRQS]; |
129 | 126 | ||
130 | /* | 127 | /* |
131 | * Since cpu_online_map is already updated, we just need to check for | 128 | * Since cpu_online_mask is already updated, we just need to check for |
132 | * affinity that has zeros | 129 | * affinity that has zeros |
133 | */ | 130 | */ |
134 | static void migrate_irqs(void) | 131 | static void migrate_irqs(void) |
@@ -158,7 +155,7 @@ static void migrate_irqs(void) | |||
158 | */ | 155 | */ |
159 | vectors_in_migration[irq] = irq; | 156 | vectors_in_migration[irq] = irq; |
160 | 157 | ||
161 | new_cpu = any_online_cpu(cpu_online_map); | 158 | new_cpu = cpumask_any(cpu_online_mask); |
162 | 159 | ||
163 | /* | 160 | /* |
164 | * Al three are essential, currently WARN_ON.. maybe panic? | 161 | * Al three are essential, currently WARN_ON.. maybe panic? |
@@ -191,7 +188,7 @@ void fixup_irqs(void) | |||
191 | * Find a new timesync master | 188 | * Find a new timesync master |
192 | */ | 189 | */ |
193 | if (smp_processor_id() == time_keeper_id) { | 190 | if (smp_processor_id() == time_keeper_id) { |
194 | time_keeper_id = first_cpu(cpu_online_map); | 191 | time_keeper_id = cpumask_first(cpu_online_mask); |
195 | printk ("CPU %d is now promoted to time-keeper master\n", time_keeper_id); | 192 | printk ("CPU %d is now promoted to time-keeper master\n", time_keeper_id); |
196 | } | 193 | } |
197 | 194 | ||
diff --git a/arch/x86/include/asm/es7000/apic.h b/arch/x86/include/asm/es7000/apic.h index bc53d5ef1386..c58b9cc74465 100644 --- a/arch/x86/include/asm/es7000/apic.h +++ b/arch/x86/include/asm/es7000/apic.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef __ASM_ES7000_APIC_H | 1 | #ifndef __ASM_ES7000_APIC_H |
2 | #define __ASM_ES7000_APIC_H | 2 | #define __ASM_ES7000_APIC_H |
3 | 3 | ||
4 | #include <linux/gfp.h> | ||
5 | |||
4 | #define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu) | 6 | #define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu) |
5 | #define esr_disable (1) | 7 | #define esr_disable (1) |
6 | 8 | ||
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 830b9fcb6427..19953df61c52 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h | |||
@@ -18,9 +18,26 @@ | |||
18 | #include <asm/pda.h> | 18 | #include <asm/pda.h> |
19 | #include <asm/thread_info.h> | 19 | #include <asm/thread_info.h> |
20 | 20 | ||
21 | #ifdef CONFIG_X86_64 | ||
22 | |||
23 | extern cpumask_var_t cpu_callin_mask; | ||
24 | extern cpumask_var_t cpu_callout_mask; | ||
25 | extern cpumask_var_t cpu_initialized_mask; | ||
26 | extern cpumask_var_t cpu_sibling_setup_mask; | ||
27 | |||
28 | #else /* CONFIG_X86_32 */ | ||
29 | |||
30 | extern cpumask_t cpu_callin_map; | ||
21 | extern cpumask_t cpu_callout_map; | 31 | extern cpumask_t cpu_callout_map; |
22 | extern cpumask_t cpu_initialized; | 32 | extern cpumask_t cpu_initialized; |
23 | extern cpumask_t cpu_callin_map; | 33 | extern cpumask_t cpu_sibling_setup_map; |
34 | |||
35 | #define cpu_callin_mask ((struct cpumask *)&cpu_callin_map) | ||
36 | #define cpu_callout_mask ((struct cpumask *)&cpu_callout_map) | ||
37 | #define cpu_initialized_mask ((struct cpumask *)&cpu_initialized) | ||
38 | #define cpu_sibling_setup_mask ((struct cpumask *)&cpu_sibling_setup_map) | ||
39 | |||
40 | #endif /* CONFIG_X86_32 */ | ||
24 | 41 | ||
25 | extern void (*mtrr_hook)(void); | 42 | extern void (*mtrr_hook)(void); |
26 | extern void zap_low_mappings(void); | 43 | extern void zap_low_mappings(void); |
@@ -29,7 +46,6 @@ extern int __cpuinit get_local_pda(int cpu); | |||
29 | 46 | ||
30 | extern int smp_num_siblings; | 47 | extern int smp_num_siblings; |
31 | extern unsigned int num_processors; | 48 | extern unsigned int num_processors; |
32 | extern cpumask_t cpu_initialized; | ||
33 | 49 | ||
34 | DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); | 50 | DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); |
35 | DECLARE_PER_CPU(cpumask_t, cpu_core_map); | 51 | DECLARE_PER_CPU(cpumask_t, cpu_core_map); |
@@ -38,6 +54,16 @@ DECLARE_PER_CPU(u16, cpu_llc_id); | |||
38 | DECLARE_PER_CPU(int, cpu_number); | 54 | DECLARE_PER_CPU(int, cpu_number); |
39 | #endif | 55 | #endif |
40 | 56 | ||
57 | static inline struct cpumask *cpu_sibling_mask(int cpu) | ||
58 | { | ||
59 | return &per_cpu(cpu_sibling_map, cpu); | ||
60 | } | ||
61 | |||
62 | static inline struct cpumask *cpu_core_mask(int cpu) | ||
63 | { | ||
64 | return &per_cpu(cpu_core_map, cpu); | ||
65 | } | ||
66 | |||
41 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); | 67 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); |
42 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); | 68 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); |
43 | 69 | ||
@@ -149,7 +175,7 @@ void smp_store_cpu_info(int id); | |||
149 | /* We don't mark CPUs online until __cpu_up(), so we need another measure */ | 175 | /* We don't mark CPUs online until __cpu_up(), so we need another measure */ |
150 | static inline int num_booting_cpus(void) | 176 | static inline int num_booting_cpus(void) |
151 | { | 177 | { |
152 | return cpus_weight(cpu_callout_map); | 178 | return cpumask_weight(cpu_callout_mask); |
153 | } | 179 | } |
154 | #else | 180 | #else |
155 | static inline void prefill_possible_map(void) | 181 | static inline void prefill_possible_map(void) |
diff --git a/arch/x86/include/asm/summit/apic.h b/arch/x86/include/asm/summit/apic.h index 4bb5fb34f030..93d2c8667cfe 100644 --- a/arch/x86/include/asm/summit/apic.h +++ b/arch/x86/include/asm/summit/apic.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __ASM_SUMMIT_APIC_H | 2 | #define __ASM_SUMMIT_APIC_H |
3 | 3 | ||
4 | #include <asm/smp.h> | 4 | #include <asm/smp.h> |
5 | #include <linux/gfp.h> | ||
5 | 6 | ||
6 | #define esr_disable (1) | 7 | #define esr_disable (1) |
7 | #define NO_BALANCE_IRQ (0) | 8 | #define NO_BALANCE_IRQ (0) |
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c index a4805b3b4095..bbbe4bbb6f34 100644 --- a/arch/x86/kernel/acpi/cstate.c +++ b/arch/x86/kernel/acpi/cstate.c | |||
@@ -67,35 +67,15 @@ static short mwait_supported[ACPI_PROCESSOR_MAX_POWER]; | |||
67 | 67 | ||
68 | #define NATIVE_CSTATE_BEYOND_HALT (2) | 68 | #define NATIVE_CSTATE_BEYOND_HALT (2) |
69 | 69 | ||
70 | int acpi_processor_ffh_cstate_probe(unsigned int cpu, | 70 | static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) |
71 | struct acpi_processor_cx *cx, struct acpi_power_register *reg) | ||
72 | { | 71 | { |
73 | struct cstate_entry *percpu_entry; | 72 | struct acpi_processor_cx *cx = _cx; |
74 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 73 | long retval; |
75 | |||
76 | cpumask_t saved_mask; | ||
77 | int retval; | ||
78 | unsigned int eax, ebx, ecx, edx; | 74 | unsigned int eax, ebx, ecx, edx; |
79 | unsigned int edx_part; | 75 | unsigned int edx_part; |
80 | unsigned int cstate_type; /* C-state type and not ACPI C-state type */ | 76 | unsigned int cstate_type; /* C-state type and not ACPI C-state type */ |
81 | unsigned int num_cstate_subtype; | 77 | unsigned int num_cstate_subtype; |
82 | 78 | ||
83 | if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF ) | ||
84 | return -1; | ||
85 | |||
86 | if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT) | ||
87 | return -1; | ||
88 | |||
89 | percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu); | ||
90 | percpu_entry->states[cx->index].eax = 0; | ||
91 | percpu_entry->states[cx->index].ecx = 0; | ||
92 | |||
93 | /* Make sure we are running on right CPU */ | ||
94 | saved_mask = current->cpus_allowed; | ||
95 | retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | ||
96 | if (retval) | ||
97 | return -1; | ||
98 | |||
99 | cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); | 79 | cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); |
100 | 80 | ||
101 | /* Check whether this particular cx_type (in CST) is supported or not */ | 81 | /* Check whether this particular cx_type (in CST) is supported or not */ |
@@ -116,21 +96,45 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu, | |||
116 | retval = -1; | 96 | retval = -1; |
117 | goto out; | 97 | goto out; |
118 | } | 98 | } |
119 | percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK; | ||
120 | |||
121 | /* Use the hint in CST */ | ||
122 | percpu_entry->states[cx->index].eax = cx->address; | ||
123 | 99 | ||
124 | if (!mwait_supported[cstate_type]) { | 100 | if (!mwait_supported[cstate_type]) { |
125 | mwait_supported[cstate_type] = 1; | 101 | mwait_supported[cstate_type] = 1; |
126 | printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " | 102 | printk(KERN_DEBUG |
127 | "state\n", cx->type); | 103 | "Monitor-Mwait will be used to enter C-%d " |
104 | "state\n", cx->type); | ||
128 | } | 105 | } |
129 | snprintf(cx->desc, ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", | 106 | snprintf(cx->desc, |
130 | cx->address); | 107 | ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", |
131 | 108 | cx->address); | |
132 | out: | 109 | out: |
133 | set_cpus_allowed_ptr(current, &saved_mask); | 110 | return retval; |
111 | } | ||
112 | |||
113 | int acpi_processor_ffh_cstate_probe(unsigned int cpu, | ||
114 | struct acpi_processor_cx *cx, struct acpi_power_register *reg) | ||
115 | { | ||
116 | struct cstate_entry *percpu_entry; | ||
117 | struct cpuinfo_x86 *c = &cpu_data(cpu); | ||
118 | long retval; | ||
119 | |||
120 | if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF) | ||
121 | return -1; | ||
122 | |||
123 | if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT) | ||
124 | return -1; | ||
125 | |||
126 | percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu); | ||
127 | percpu_entry->states[cx->index].eax = 0; | ||
128 | percpu_entry->states[cx->index].ecx = 0; | ||
129 | |||
130 | /* Make sure we are running on right CPU */ | ||
131 | |||
132 | retval = work_on_cpu(cpu, acpi_processor_ffh_cstate_probe_cpu, cx); | ||
133 | if (retval == 0) { | ||
134 | /* Use the hint in CST */ | ||
135 | percpu_entry->states[cx->index].eax = cx->address; | ||
136 | percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK; | ||
137 | } | ||
134 | return retval; | 138 | return retval; |
135 | } | 139 | } |
136 | EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe); | 140 | EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe); |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 3f95a40f718a..83492b1f93b1 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -40,6 +40,26 @@ | |||
40 | 40 | ||
41 | #include "cpu.h" | 41 | #include "cpu.h" |
42 | 42 | ||
43 | #ifdef CONFIG_X86_64 | ||
44 | |||
45 | /* all of these masks are initialized in setup_cpu_local_masks() */ | ||
46 | cpumask_var_t cpu_callin_mask; | ||
47 | cpumask_var_t cpu_callout_mask; | ||
48 | cpumask_var_t cpu_initialized_mask; | ||
49 | |||
50 | /* representing cpus for which sibling maps can be computed */ | ||
51 | cpumask_var_t cpu_sibling_setup_mask; | ||
52 | |||
53 | #else /* CONFIG_X86_32 */ | ||
54 | |||
55 | cpumask_t cpu_callin_map; | ||
56 | cpumask_t cpu_callout_map; | ||
57 | cpumask_t cpu_initialized; | ||
58 | cpumask_t cpu_sibling_setup_map; | ||
59 | |||
60 | #endif /* CONFIG_X86_32 */ | ||
61 | |||
62 | |||
43 | static struct cpu_dev *this_cpu __cpuinitdata; | 63 | static struct cpu_dev *this_cpu __cpuinitdata; |
44 | 64 | ||
45 | #ifdef CONFIG_X86_64 | 65 | #ifdef CONFIG_X86_64 |
@@ -856,8 +876,6 @@ static __init int setup_disablecpuid(char *arg) | |||
856 | } | 876 | } |
857 | __setup("clearcpuid=", setup_disablecpuid); | 877 | __setup("clearcpuid=", setup_disablecpuid); |
858 | 878 | ||
859 | cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE; | ||
860 | |||
861 | #ifdef CONFIG_X86_64 | 879 | #ifdef CONFIG_X86_64 |
862 | struct x8664_pda **_cpu_pda __read_mostly; | 880 | struct x8664_pda **_cpu_pda __read_mostly; |
863 | EXPORT_SYMBOL(_cpu_pda); | 881 | EXPORT_SYMBOL(_cpu_pda); |
@@ -976,7 +994,7 @@ void __cpuinit cpu_init(void) | |||
976 | 994 | ||
977 | me = current; | 995 | me = current; |
978 | 996 | ||
979 | if (cpu_test_and_set(cpu, cpu_initialized)) | 997 | if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) |
980 | panic("CPU#%d already initialized!\n", cpu); | 998 | panic("CPU#%d already initialized!\n", cpu); |
981 | 999 | ||
982 | printk(KERN_INFO "Initializing CPU#%d\n", cpu); | 1000 | printk(KERN_INFO "Initializing CPU#%d\n", cpu); |
@@ -1085,7 +1103,7 @@ void __cpuinit cpu_init(void) | |||
1085 | struct tss_struct *t = &per_cpu(init_tss, cpu); | 1103 | struct tss_struct *t = &per_cpu(init_tss, cpu); |
1086 | struct thread_struct *thread = &curr->thread; | 1104 | struct thread_struct *thread = &curr->thread; |
1087 | 1105 | ||
1088 | if (cpu_test_and_set(cpu, cpu_initialized)) { | 1106 | if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) { |
1089 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); | 1107 | printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); |
1090 | for (;;) local_irq_enable(); | 1108 | for (;;) local_irq_enable(); |
1091 | } | 1109 | } |
diff --git a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index 28102ad1a363..06fcd8f9323c 100644 --- a/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c | |||
@@ -145,13 +145,14 @@ typedef union { | |||
145 | 145 | ||
146 | struct drv_cmd { | 146 | struct drv_cmd { |
147 | unsigned int type; | 147 | unsigned int type; |
148 | cpumask_t mask; | 148 | cpumask_var_t mask; |
149 | drv_addr_union addr; | 149 | drv_addr_union addr; |
150 | u32 val; | 150 | u32 val; |
151 | }; | 151 | }; |
152 | 152 | ||
153 | static void do_drv_read(struct drv_cmd *cmd) | 153 | static long do_drv_read(void *_cmd) |
154 | { | 154 | { |
155 | struct drv_cmd *cmd = _cmd; | ||
155 | u32 h; | 156 | u32 h; |
156 | 157 | ||
157 | switch (cmd->type) { | 158 | switch (cmd->type) { |
@@ -166,10 +167,12 @@ static void do_drv_read(struct drv_cmd *cmd) | |||
166 | default: | 167 | default: |
167 | break; | 168 | break; |
168 | } | 169 | } |
170 | return 0; | ||
169 | } | 171 | } |
170 | 172 | ||
171 | static void do_drv_write(struct drv_cmd *cmd) | 173 | static long do_drv_write(void *_cmd) |
172 | { | 174 | { |
175 | struct drv_cmd *cmd = _cmd; | ||
173 | u32 lo, hi; | 176 | u32 lo, hi; |
174 | 177 | ||
175 | switch (cmd->type) { | 178 | switch (cmd->type) { |
@@ -186,48 +189,41 @@ static void do_drv_write(struct drv_cmd *cmd) | |||
186 | default: | 189 | default: |
187 | break; | 190 | break; |
188 | } | 191 | } |
192 | return 0; | ||
189 | } | 193 | } |
190 | 194 | ||
191 | static void drv_read(struct drv_cmd *cmd) | 195 | static void drv_read(struct drv_cmd *cmd) |
192 | { | 196 | { |
193 | cpumask_t saved_mask = current->cpus_allowed; | ||
194 | cmd->val = 0; | 197 | cmd->val = 0; |
195 | 198 | ||
196 | set_cpus_allowed_ptr(current, &cmd->mask); | 199 | work_on_cpu(cpumask_any(cmd->mask), do_drv_read, cmd); |
197 | do_drv_read(cmd); | ||
198 | set_cpus_allowed_ptr(current, &saved_mask); | ||
199 | } | 200 | } |
200 | 201 | ||
201 | static void drv_write(struct drv_cmd *cmd) | 202 | static void drv_write(struct drv_cmd *cmd) |
202 | { | 203 | { |
203 | cpumask_t saved_mask = current->cpus_allowed; | ||
204 | unsigned int i; | 204 | unsigned int i; |
205 | 205 | ||
206 | for_each_cpu_mask_nr(i, cmd->mask) { | 206 | for_each_cpu(i, cmd->mask) { |
207 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); | 207 | work_on_cpu(i, do_drv_write, cmd); |
208 | do_drv_write(cmd); | ||
209 | } | 208 | } |
210 | |||
211 | set_cpus_allowed_ptr(current, &saved_mask); | ||
212 | return; | ||
213 | } | 209 | } |
214 | 210 | ||
215 | static u32 get_cur_val(const cpumask_t *mask) | 211 | static u32 get_cur_val(const struct cpumask *mask) |
216 | { | 212 | { |
217 | struct acpi_processor_performance *perf; | 213 | struct acpi_processor_performance *perf; |
218 | struct drv_cmd cmd; | 214 | struct drv_cmd cmd; |
219 | 215 | ||
220 | if (unlikely(cpus_empty(*mask))) | 216 | if (unlikely(cpumask_empty(mask))) |
221 | return 0; | 217 | return 0; |
222 | 218 | ||
223 | switch (per_cpu(drv_data, first_cpu(*mask))->cpu_feature) { | 219 | switch (per_cpu(drv_data, cpumask_first(mask))->cpu_feature) { |
224 | case SYSTEM_INTEL_MSR_CAPABLE: | 220 | case SYSTEM_INTEL_MSR_CAPABLE: |
225 | cmd.type = SYSTEM_INTEL_MSR_CAPABLE; | 221 | cmd.type = SYSTEM_INTEL_MSR_CAPABLE; |
226 | cmd.addr.msr.reg = MSR_IA32_PERF_STATUS; | 222 | cmd.addr.msr.reg = MSR_IA32_PERF_STATUS; |
227 | break; | 223 | break; |
228 | case SYSTEM_IO_CAPABLE: | 224 | case SYSTEM_IO_CAPABLE: |
229 | cmd.type = SYSTEM_IO_CAPABLE; | 225 | cmd.type = SYSTEM_IO_CAPABLE; |
230 | perf = per_cpu(drv_data, first_cpu(*mask))->acpi_data; | 226 | perf = per_cpu(drv_data, cpumask_first(mask))->acpi_data; |
231 | cmd.addr.io.port = perf->control_register.address; | 227 | cmd.addr.io.port = perf->control_register.address; |
232 | cmd.addr.io.bit_width = perf->control_register.bit_width; | 228 | cmd.addr.io.bit_width = perf->control_register.bit_width; |
233 | break; | 229 | break; |
@@ -235,15 +231,44 @@ static u32 get_cur_val(const cpumask_t *mask) | |||
235 | return 0; | 231 | return 0; |
236 | } | 232 | } |
237 | 233 | ||
238 | cmd.mask = *mask; | 234 | if (unlikely(!alloc_cpumask_var(&cmd.mask, GFP_KERNEL))) |
235 | return 0; | ||
236 | |||
237 | cpumask_copy(cmd.mask, mask); | ||
239 | 238 | ||
240 | drv_read(&cmd); | 239 | drv_read(&cmd); |
241 | 240 | ||
241 | free_cpumask_var(cmd.mask); | ||
242 | |||
242 | dprintk("get_cur_val = %u\n", cmd.val); | 243 | dprintk("get_cur_val = %u\n", cmd.val); |
243 | 244 | ||
244 | return cmd.val; | 245 | return cmd.val; |
245 | } | 246 | } |
246 | 247 | ||
248 | struct perf_cur { | ||
249 | union { | ||
250 | struct { | ||
251 | u32 lo; | ||
252 | u32 hi; | ||
253 | } split; | ||
254 | u64 whole; | ||
255 | } aperf_cur, mperf_cur; | ||
256 | }; | ||
257 | |||
258 | |||
259 | static long read_measured_perf_ctrs(void *_cur) | ||
260 | { | ||
261 | struct perf_cur *cur = _cur; | ||
262 | |||
263 | rdmsr(MSR_IA32_APERF, cur->aperf_cur.split.lo, cur->aperf_cur.split.hi); | ||
264 | rdmsr(MSR_IA32_MPERF, cur->mperf_cur.split.lo, cur->mperf_cur.split.hi); | ||
265 | |||
266 | wrmsr(MSR_IA32_APERF, 0, 0); | ||
267 | wrmsr(MSR_IA32_MPERF, 0, 0); | ||
268 | |||
269 | return 0; | ||
270 | } | ||
271 | |||
247 | /* | 272 | /* |
248 | * Return the measured active (C0) frequency on this CPU since last call | 273 | * Return the measured active (C0) frequency on this CPU since last call |
249 | * to this function. | 274 | * to this function. |
@@ -260,31 +285,12 @@ static u32 get_cur_val(const cpumask_t *mask) | |||
260 | static unsigned int get_measured_perf(struct cpufreq_policy *policy, | 285 | static unsigned int get_measured_perf(struct cpufreq_policy *policy, |
261 | unsigned int cpu) | 286 | unsigned int cpu) |
262 | { | 287 | { |
263 | union { | 288 | struct perf_cur cur; |
264 | struct { | ||
265 | u32 lo; | ||
266 | u32 hi; | ||
267 | } split; | ||
268 | u64 whole; | ||
269 | } aperf_cur, mperf_cur; | ||
270 | |||
271 | cpumask_t saved_mask; | ||
272 | unsigned int perf_percent; | 289 | unsigned int perf_percent; |
273 | unsigned int retval; | 290 | unsigned int retval; |
274 | 291 | ||
275 | saved_mask = current->cpus_allowed; | 292 | if (!work_on_cpu(cpu, read_measured_perf_ctrs, &cur)) |
276 | set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); | ||
277 | if (get_cpu() != cpu) { | ||
278 | /* We were not able to run on requested processor */ | ||
279 | put_cpu(); | ||
280 | return 0; | 293 | return 0; |
281 | } | ||
282 | |||
283 | rdmsr(MSR_IA32_APERF, aperf_cur.split.lo, aperf_cur.split.hi); | ||
284 | rdmsr(MSR_IA32_MPERF, mperf_cur.split.lo, mperf_cur.split.hi); | ||
285 | |||
286 | wrmsr(MSR_IA32_APERF, 0,0); | ||
287 | wrmsr(MSR_IA32_MPERF, 0,0); | ||
288 | 294 | ||
289 | #ifdef __i386__ | 295 | #ifdef __i386__ |
290 | /* | 296 | /* |
@@ -292,37 +298,39 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy, | |||
292 | * Get an approximate value. Return failure in case we cannot get | 298 | * Get an approximate value. Return failure in case we cannot get |
293 | * an approximate value. | 299 | * an approximate value. |
294 | */ | 300 | */ |
295 | if (unlikely(aperf_cur.split.hi || mperf_cur.split.hi)) { | 301 | if (unlikely(cur.aperf_cur.split.hi || cur.mperf_cur.split.hi)) { |
296 | int shift_count; | 302 | int shift_count; |
297 | u32 h; | 303 | u32 h; |
298 | 304 | ||
299 | h = max_t(u32, aperf_cur.split.hi, mperf_cur.split.hi); | 305 | h = max_t(u32, cur.aperf_cur.split.hi, cur.mperf_cur.split.hi); |
300 | shift_count = fls(h); | 306 | shift_count = fls(h); |
301 | 307 | ||
302 | aperf_cur.whole >>= shift_count; | 308 | cur.aperf_cur.whole >>= shift_count; |
303 | mperf_cur.whole >>= shift_count; | 309 | cur.mperf_cur.whole >>= shift_count; |
304 | } | 310 | } |
305 | 311 | ||
306 | if (((unsigned long)(-1) / 100) < aperf_cur.split.lo) { | 312 | if (((unsigned long)(-1) / 100) < cur.aperf_cur.split.lo) { |
307 | int shift_count = 7; | 313 | int shift_count = 7; |
308 | aperf_cur.split.lo >>= shift_count; | 314 | cur.aperf_cur.split.lo >>= shift_count; |
309 | mperf_cur.split.lo >>= shift_count; | 315 | cur.mperf_cur.split.lo >>= shift_count; |
310 | } | 316 | } |
311 | 317 | ||
312 | if (aperf_cur.split.lo && mperf_cur.split.lo) | 318 | if (cur.aperf_cur.split.lo && cur.mperf_cur.split.lo) |
313 | perf_percent = (aperf_cur.split.lo * 100) / mperf_cur.split.lo; | 319 | perf_percent = (cur.aperf_cur.split.lo * 100) / |
320 | cur.mperf_cur.split.lo; | ||
314 | else | 321 | else |
315 | perf_percent = 0; | 322 | perf_percent = 0; |
316 | 323 | ||
317 | #else | 324 | #else |
318 | if (unlikely(((unsigned long)(-1) / 100) < aperf_cur.whole)) { | 325 | if (unlikely(((unsigned long)(-1) / 100) < cur.aperf_cur.whole)) { |
319 | int shift_count = 7; | 326 | int shift_count = 7; |
320 | aperf_cur.whole >>= shift_count; | 327 | cur.aperf_cur.whole >>= shift_count; |
321 | mperf_cur.whole >>= shift_count; | 328 | cur.mperf_cur.whole >>= shift_count; |
322 | } | 329 | } |
323 | 330 | ||
324 | if (aperf_cur.whole && mperf_cur.whole) | 331 | if (cur.aperf_cur.whole && cur.mperf_cur.whole) |
325 | perf_percent = (aperf_cur.whole * 100) / mperf_cur.whole; | 332 | perf_percent = (cur.aperf_cur.whole * 100) / |
333 | cur.mperf_cur.whole; | ||
326 | else | 334 | else |
327 | perf_percent = 0; | 335 | perf_percent = 0; |
328 | 336 | ||
@@ -330,10 +338,6 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy, | |||
330 | 338 | ||
331 | retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100; | 339 | retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100; |
332 | 340 | ||
333 | put_cpu(); | ||
334 | set_cpus_allowed_ptr(current, &saved_mask); | ||
335 | |||
336 | dprintk("cpu %d: performance percent %d\n", cpu, perf_percent); | ||
337 | return retval; | 341 | return retval; |
338 | } | 342 | } |
339 | 343 | ||
@@ -351,7 +355,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) | |||
351 | } | 355 | } |
352 | 356 | ||
353 | cached_freq = data->freq_table[data->acpi_data->state].frequency; | 357 | cached_freq = data->freq_table[data->acpi_data->state].frequency; |
354 | freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data); | 358 | freq = extract_freq(get_cur_val(cpumask_of(cpu)), data); |
355 | if (freq != cached_freq) { | 359 | if (freq != cached_freq) { |
356 | /* | 360 | /* |
357 | * The dreaded BIOS frequency change behind our back. | 361 | * The dreaded BIOS frequency change behind our back. |
@@ -386,7 +390,6 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
386 | struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu); | 390 | struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu); |
387 | struct acpi_processor_performance *perf; | 391 | struct acpi_processor_performance *perf; |
388 | struct cpufreq_freqs freqs; | 392 | struct cpufreq_freqs freqs; |
389 | cpumask_t online_policy_cpus; | ||
390 | struct drv_cmd cmd; | 393 | struct drv_cmd cmd; |
391 | unsigned int next_state = 0; /* Index into freq_table */ | 394 | unsigned int next_state = 0; /* Index into freq_table */ |
392 | unsigned int next_perf_state = 0; /* Index into perf table */ | 395 | unsigned int next_perf_state = 0; /* Index into perf table */ |
@@ -401,20 +404,18 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
401 | return -ENODEV; | 404 | return -ENODEV; |
402 | } | 405 | } |
403 | 406 | ||
407 | if (unlikely(!alloc_cpumask_var(&cmd.mask, GFP_KERNEL))) | ||
408 | return -ENOMEM; | ||
409 | |||
404 | perf = data->acpi_data; | 410 | perf = data->acpi_data; |
405 | result = cpufreq_frequency_table_target(policy, | 411 | result = cpufreq_frequency_table_target(policy, |
406 | data->freq_table, | 412 | data->freq_table, |
407 | target_freq, | 413 | target_freq, |
408 | relation, &next_state); | 414 | relation, &next_state); |
409 | if (unlikely(result)) | 415 | if (unlikely(result)) { |
410 | return -ENODEV; | 416 | result = -ENODEV; |
411 | 417 | goto out; | |
412 | #ifdef CONFIG_HOTPLUG_CPU | 418 | } |
413 | /* cpufreq holds the hotplug lock, so we are safe from here on */ | ||
414 | cpus_and(online_policy_cpus, cpu_online_map, policy->cpus); | ||
415 | #else | ||
416 | online_policy_cpus = policy->cpus; | ||
417 | #endif | ||
418 | 419 | ||
419 | next_perf_state = data->freq_table[next_state].index; | 420 | next_perf_state = data->freq_table[next_state].index; |
420 | if (perf->state == next_perf_state) { | 421 | if (perf->state == next_perf_state) { |
@@ -425,7 +426,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
425 | } else { | 426 | } else { |
426 | dprintk("Already at target state (P%d)\n", | 427 | dprintk("Already at target state (P%d)\n", |
427 | next_perf_state); | 428 | next_perf_state); |
428 | return 0; | 429 | goto out; |
429 | } | 430 | } |
430 | } | 431 | } |
431 | 432 | ||
@@ -444,19 +445,19 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
444 | cmd.val = (u32) perf->states[next_perf_state].control; | 445 | cmd.val = (u32) perf->states[next_perf_state].control; |
445 | break; | 446 | break; |
446 | default: | 447 | default: |
447 | return -ENODEV; | 448 | result = -ENODEV; |
449 | goto out; | ||
448 | } | 450 | } |
449 | 451 | ||
450 | cpus_clear(cmd.mask); | 452 | /* cpufreq holds the hotplug lock, so we are safe from here on */ |
451 | |||
452 | if (policy->shared_type != CPUFREQ_SHARED_TYPE_ANY) | 453 | if (policy->shared_type != CPUFREQ_SHARED_TYPE_ANY) |
453 | cmd.mask = online_policy_cpus; | 454 | cpumask_and(cmd.mask, cpu_online_mask, policy->cpus); |
454 | else | 455 | else |
455 | cpu_set(policy->cpu, cmd.mask); | 456 | cpumask_copy(cmd.mask, cpumask_of(policy->cpu)); |
456 | 457 | ||
457 | freqs.old = perf->states[perf->state].core_frequency * 1000; | 458 | freqs.old = perf->states[perf->state].core_frequency * 1000; |
458 | freqs.new = data->freq_table[next_state].frequency; | 459 | freqs.new = data->freq_table[next_state].frequency; |
459 | for_each_cpu_mask_nr(i, cmd.mask) { | 460 | for_each_cpu(i, cmd.mask) { |
460 | freqs.cpu = i; | 461 | freqs.cpu = i; |
461 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 462 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); |
462 | } | 463 | } |
@@ -464,19 +465,22 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
464 | drv_write(&cmd); | 465 | drv_write(&cmd); |
465 | 466 | ||
466 | if (acpi_pstate_strict) { | 467 | if (acpi_pstate_strict) { |
467 | if (!check_freqs(&cmd.mask, freqs.new, data)) { | 468 | if (!check_freqs(cmd.mask, freqs.new, data)) { |
468 | dprintk("acpi_cpufreq_target failed (%d)\n", | 469 | dprintk("acpi_cpufreq_target failed (%d)\n", |
469 | policy->cpu); | 470 | policy->cpu); |
470 | return -EAGAIN; | 471 | result = -EAGAIN; |
472 | goto out; | ||
471 | } | 473 | } |
472 | } | 474 | } |
473 | 475 | ||
474 | for_each_cpu_mask_nr(i, cmd.mask) { | 476 | for_each_cpu(i, cmd.mask) { |
475 | freqs.cpu = i; | 477 | freqs.cpu = i; |
476 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 478 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); |
477 | } | 479 | } |
478 | perf->state = next_perf_state; | 480 | perf->state = next_perf_state; |
479 | 481 | ||
482 | out: | ||
483 | free_cpumask_var(cmd.mask); | ||
480 | return result; | 484 | return result; |
481 | } | 485 | } |
482 | 486 | ||
@@ -626,15 +630,15 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
626 | */ | 630 | */ |
627 | if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || | 631 | if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || |
628 | policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { | 632 | policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { |
629 | cpumask_copy(&policy->cpus, perf->shared_cpu_map); | 633 | cpumask_copy(policy->cpus, perf->shared_cpu_map); |
630 | } | 634 | } |
631 | cpumask_copy(&policy->related_cpus, perf->shared_cpu_map); | 635 | cpumask_copy(policy->related_cpus, perf->shared_cpu_map); |
632 | 636 | ||
633 | #ifdef CONFIG_SMP | 637 | #ifdef CONFIG_SMP |
634 | dmi_check_system(sw_any_bug_dmi_table); | 638 | dmi_check_system(sw_any_bug_dmi_table); |
635 | if (bios_with_sw_any_bug && cpus_weight(policy->cpus) == 1) { | 639 | if (bios_with_sw_any_bug && cpumask_weight(policy->cpus) == 1) { |
636 | policy->shared_type = CPUFREQ_SHARED_TYPE_ALL; | 640 | policy->shared_type = CPUFREQ_SHARED_TYPE_ALL; |
637 | policy->cpus = per_cpu(cpu_core_map, cpu); | 641 | cpumask_copy(policy->cpus, cpu_core_mask(cpu)); |
638 | } | 642 | } |
639 | #endif | 643 | #endif |
640 | 644 | ||
diff --git a/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c b/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c index beea4466b063..b585e04cbc9e 100644 --- a/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c +++ b/arch/x86/kernel/cpu/cpufreq/p4-clockmod.c | |||
@@ -122,7 +122,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
122 | return 0; | 122 | return 0; |
123 | 123 | ||
124 | /* notifiers */ | 124 | /* notifiers */ |
125 | for_each_cpu_mask_nr(i, policy->cpus) { | 125 | for_each_cpu(i, policy->cpus) { |
126 | freqs.cpu = i; | 126 | freqs.cpu = i; |
127 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 127 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); |
128 | } | 128 | } |
@@ -130,11 +130,11 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
130 | /* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software | 130 | /* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software |
131 | * Developer's Manual, Volume 3 | 131 | * Developer's Manual, Volume 3 |
132 | */ | 132 | */ |
133 | for_each_cpu_mask_nr(i, policy->cpus) | 133 | for_each_cpu(i, policy->cpus) |
134 | cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); | 134 | cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); |
135 | 135 | ||
136 | /* notifiers */ | 136 | /* notifiers */ |
137 | for_each_cpu_mask_nr(i, policy->cpus) { | 137 | for_each_cpu(i, policy->cpus) { |
138 | freqs.cpu = i; | 138 | freqs.cpu = i; |
139 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 139 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); |
140 | } | 140 | } |
@@ -203,7 +203,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy) | |||
203 | unsigned int i; | 203 | unsigned int i; |
204 | 204 | ||
205 | #ifdef CONFIG_SMP | 205 | #ifdef CONFIG_SMP |
206 | policy->cpus = per_cpu(cpu_sibling_map, policy->cpu); | 206 | cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu)); |
207 | #endif | 207 | #endif |
208 | 208 | ||
209 | /* Errata workaround */ | 209 | /* Errata workaround */ |
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c index c3c9adbaa26f..5c28b37dea11 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c | |||
@@ -1199,10 +1199,10 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
1199 | set_cpus_allowed_ptr(current, &oldmask); | 1199 | set_cpus_allowed_ptr(current, &oldmask); |
1200 | 1200 | ||
1201 | if (cpu_family == CPU_HW_PSTATE) | 1201 | if (cpu_family == CPU_HW_PSTATE) |
1202 | pol->cpus = cpumask_of_cpu(pol->cpu); | 1202 | cpumask_copy(pol->cpus, cpumask_of(pol->cpu)); |
1203 | else | 1203 | else |
1204 | pol->cpus = per_cpu(cpu_core_map, pol->cpu); | 1204 | cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu)); |
1205 | data->available_cores = &(pol->cpus); | 1205 | data->available_cores = pol->cpus; |
1206 | 1206 | ||
1207 | /* Take a crude guess here. | 1207 | /* Take a crude guess here. |
1208 | * That guess was in microseconds, so multiply with 1000 */ | 1208 | * That guess was in microseconds, so multiply with 1000 */ |
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h index 65cfb5d7f77f..8ecc75b6c7c3 100644 --- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.h +++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.h | |||
@@ -53,7 +53,7 @@ struct powernow_k8_data { | |||
53 | /* we need to keep track of associated cores, but let cpufreq | 53 | /* we need to keep track of associated cores, but let cpufreq |
54 | * handle hotplug events - so just point at cpufreq pol->cpus | 54 | * handle hotplug events - so just point at cpufreq pol->cpus |
55 | * structure */ | 55 | * structure */ |
56 | cpumask_t *available_cores; | 56 | struct cpumask *available_cores; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | 59 | ||
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c index f0ea6fa2f53c..f08998278a3a 100644 --- a/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c +++ b/arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c | |||
@@ -458,11 +458,6 @@ static int centrino_verify (struct cpufreq_policy *policy) | |||
458 | * | 458 | * |
459 | * Sets a new CPUFreq policy. | 459 | * Sets a new CPUFreq policy. |
460 | */ | 460 | */ |
461 | struct allmasks { | ||
462 | cpumask_t saved_mask; | ||
463 | cpumask_t covered_cpus; | ||
464 | }; | ||
465 | |||
466 | static int centrino_target (struct cpufreq_policy *policy, | 461 | static int centrino_target (struct cpufreq_policy *policy, |
467 | unsigned int target_freq, | 462 | unsigned int target_freq, |
468 | unsigned int relation) | 463 | unsigned int relation) |
@@ -472,12 +467,15 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
472 | struct cpufreq_freqs freqs; | 467 | struct cpufreq_freqs freqs; |
473 | int retval = 0; | 468 | int retval = 0; |
474 | unsigned int j, k, first_cpu, tmp; | 469 | unsigned int j, k, first_cpu, tmp; |
475 | CPUMASK_ALLOC(allmasks); | 470 | cpumask_var_t saved_mask, covered_cpus; |
476 | CPUMASK_PTR(saved_mask, allmasks); | ||
477 | CPUMASK_PTR(covered_cpus, allmasks); | ||
478 | 471 | ||
479 | if (unlikely(allmasks == NULL)) | 472 | if (unlikely(!alloc_cpumask_var(&saved_mask, GFP_KERNEL))) |
480 | return -ENOMEM; | 473 | return -ENOMEM; |
474 | if (unlikely(!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))) { | ||
475 | free_cpumask_var(saved_mask); | ||
476 | return -ENOMEM; | ||
477 | } | ||
478 | cpumask_copy(saved_mask, ¤t->cpus_allowed); | ||
481 | 479 | ||
482 | if (unlikely(per_cpu(centrino_model, cpu) == NULL)) { | 480 | if (unlikely(per_cpu(centrino_model, cpu) == NULL)) { |
483 | retval = -ENODEV; | 481 | retval = -ENODEV; |
@@ -493,11 +491,9 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
493 | goto out; | 491 | goto out; |
494 | } | 492 | } |
495 | 493 | ||
496 | *saved_mask = current->cpus_allowed; | ||
497 | first_cpu = 1; | 494 | first_cpu = 1; |
498 | cpus_clear(*covered_cpus); | 495 | for_each_cpu(j, policy->cpus) { |
499 | for_each_cpu_mask_nr(j, policy->cpus) { | 496 | const struct cpumask *mask; |
500 | const cpumask_t *mask; | ||
501 | 497 | ||
502 | /* cpufreq holds the hotplug lock, so we are safe here */ | 498 | /* cpufreq holds the hotplug lock, so we are safe here */ |
503 | if (!cpu_online(j)) | 499 | if (!cpu_online(j)) |
@@ -508,9 +504,9 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
508 | * Make sure we are running on CPU that wants to change freq | 504 | * Make sure we are running on CPU that wants to change freq |
509 | */ | 505 | */ |
510 | if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) | 506 | if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) |
511 | mask = &policy->cpus; | 507 | mask = policy->cpus; |
512 | else | 508 | else |
513 | mask = &cpumask_of_cpu(j); | 509 | mask = cpumask_of(j); |
514 | 510 | ||
515 | set_cpus_allowed_ptr(current, mask); | 511 | set_cpus_allowed_ptr(current, mask); |
516 | preempt_disable(); | 512 | preempt_disable(); |
@@ -542,7 +538,7 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
542 | dprintk("target=%dkHz old=%d new=%d msr=%04x\n", | 538 | dprintk("target=%dkHz old=%d new=%d msr=%04x\n", |
543 | target_freq, freqs.old, freqs.new, msr); | 539 | target_freq, freqs.old, freqs.new, msr); |
544 | 540 | ||
545 | for_each_cpu_mask_nr(k, policy->cpus) { | 541 | for_each_cpu(k, policy->cpus) { |
546 | if (!cpu_online(k)) | 542 | if (!cpu_online(k)) |
547 | continue; | 543 | continue; |
548 | freqs.cpu = k; | 544 | freqs.cpu = k; |
@@ -567,7 +563,7 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
567 | preempt_enable(); | 563 | preempt_enable(); |
568 | } | 564 | } |
569 | 565 | ||
570 | for_each_cpu_mask_nr(k, policy->cpus) { | 566 | for_each_cpu(k, policy->cpus) { |
571 | if (!cpu_online(k)) | 567 | if (!cpu_online(k)) |
572 | continue; | 568 | continue; |
573 | freqs.cpu = k; | 569 | freqs.cpu = k; |
@@ -590,7 +586,7 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
590 | tmp = freqs.new; | 586 | tmp = freqs.new; |
591 | freqs.new = freqs.old; | 587 | freqs.new = freqs.old; |
592 | freqs.old = tmp; | 588 | freqs.old = tmp; |
593 | for_each_cpu_mask_nr(j, policy->cpus) { | 589 | for_each_cpu(j, policy->cpus) { |
594 | if (!cpu_online(j)) | 590 | if (!cpu_online(j)) |
595 | continue; | 591 | continue; |
596 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 592 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); |
@@ -605,7 +601,8 @@ migrate_end: | |||
605 | preempt_enable(); | 601 | preempt_enable(); |
606 | set_cpus_allowed_ptr(current, saved_mask); | 602 | set_cpus_allowed_ptr(current, saved_mask); |
607 | out: | 603 | out: |
608 | CPUMASK_FREE(allmasks); | 604 | free_cpumask_var(saved_mask); |
605 | free_cpumask_var(covered_cpus); | ||
609 | return retval; | 606 | return retval; |
610 | } | 607 | } |
611 | 608 | ||
diff --git a/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c b/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c index 04d0376b64b0..dedc1e98f168 100644 --- a/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c +++ b/arch/x86/kernel/cpu/cpufreq/speedstep-ich.c | |||
@@ -229,7 +229,7 @@ static unsigned int speedstep_detect_chipset (void) | |||
229 | return 0; | 229 | return 0; |
230 | } | 230 | } |
231 | 231 | ||
232 | static unsigned int _speedstep_get(const cpumask_t *cpus) | 232 | static unsigned int _speedstep_get(const struct cpumask *cpus) |
233 | { | 233 | { |
234 | unsigned int speed; | 234 | unsigned int speed; |
235 | cpumask_t cpus_allowed; | 235 | cpumask_t cpus_allowed; |
@@ -244,7 +244,7 @@ static unsigned int _speedstep_get(const cpumask_t *cpus) | |||
244 | 244 | ||
245 | static unsigned int speedstep_get(unsigned int cpu) | 245 | static unsigned int speedstep_get(unsigned int cpu) |
246 | { | 246 | { |
247 | return _speedstep_get(&cpumask_of_cpu(cpu)); | 247 | return _speedstep_get(cpumask_of(cpu)); |
248 | } | 248 | } |
249 | 249 | ||
250 | /** | 250 | /** |
@@ -267,7 +267,7 @@ static int speedstep_target (struct cpufreq_policy *policy, | |||
267 | if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate)) | 267 | if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate)) |
268 | return -EINVAL; | 268 | return -EINVAL; |
269 | 269 | ||
270 | freqs.old = _speedstep_get(&policy->cpus); | 270 | freqs.old = _speedstep_get(policy->cpus); |
271 | freqs.new = speedstep_freqs[newstate].frequency; | 271 | freqs.new = speedstep_freqs[newstate].frequency; |
272 | freqs.cpu = policy->cpu; | 272 | freqs.cpu = policy->cpu; |
273 | 273 | ||
@@ -279,20 +279,20 @@ static int speedstep_target (struct cpufreq_policy *policy, | |||
279 | 279 | ||
280 | cpus_allowed = current->cpus_allowed; | 280 | cpus_allowed = current->cpus_allowed; |
281 | 281 | ||
282 | for_each_cpu_mask_nr(i, policy->cpus) { | 282 | for_each_cpu(i, policy->cpus) { |
283 | freqs.cpu = i; | 283 | freqs.cpu = i; |
284 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 284 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); |
285 | } | 285 | } |
286 | 286 | ||
287 | /* switch to physical CPU where state is to be changed */ | 287 | /* switch to physical CPU where state is to be changed */ |
288 | set_cpus_allowed_ptr(current, &policy->cpus); | 288 | set_cpus_allowed_ptr(current, policy->cpus); |
289 | 289 | ||
290 | speedstep_set_state(newstate); | 290 | speedstep_set_state(newstate); |
291 | 291 | ||
292 | /* allow to be run on all CPUs */ | 292 | /* allow to be run on all CPUs */ |
293 | set_cpus_allowed_ptr(current, &cpus_allowed); | 293 | set_cpus_allowed_ptr(current, &cpus_allowed); |
294 | 294 | ||
295 | for_each_cpu_mask_nr(i, policy->cpus) { | 295 | for_each_cpu(i, policy->cpus) { |
296 | freqs.cpu = i; | 296 | freqs.cpu = i; |
297 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); | 297 | cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); |
298 | } | 298 | } |
@@ -322,11 +322,11 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) | |||
322 | 322 | ||
323 | /* only run on CPU to be set, or on its sibling */ | 323 | /* only run on CPU to be set, or on its sibling */ |
324 | #ifdef CONFIG_SMP | 324 | #ifdef CONFIG_SMP |
325 | policy->cpus = per_cpu(cpu_sibling_map, policy->cpu); | 325 | cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu)); |
326 | #endif | 326 | #endif |
327 | 327 | ||
328 | cpus_allowed = current->cpus_allowed; | 328 | cpus_allowed = current->cpus_allowed; |
329 | set_cpus_allowed_ptr(current, &policy->cpus); | 329 | set_cpus_allowed_ptr(current, policy->cpus); |
330 | 330 | ||
331 | /* detect low and high frequency and transition latency */ | 331 | /* detect low and high frequency and transition latency */ |
332 | result = speedstep_get_freqs(speedstep_processor, | 332 | result = speedstep_get_freqs(speedstep_processor, |
@@ -339,7 +339,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) | |||
339 | return result; | 339 | return result; |
340 | 340 | ||
341 | /* get current speed setting */ | 341 | /* get current speed setting */ |
342 | speed = _speedstep_get(&policy->cpus); | 342 | speed = _speedstep_get(policy->cpus); |
343 | if (!speed) | 343 | if (!speed) |
344 | return -EIO; | 344 | return -EIO; |
345 | 345 | ||
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c index a4b619c33106..aa55764602b1 100644 --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c | |||
@@ -131,7 +131,27 @@ static void __init setup_cpu_pda_map(void) | |||
131 | /* point to new pointer table */ | 131 | /* point to new pointer table */ |
132 | _cpu_pda = new_cpu_pda; | 132 | _cpu_pda = new_cpu_pda; |
133 | } | 133 | } |
134 | #endif | 134 | |
135 | #endif /* CONFIG_SMP && CONFIG_X86_64 */ | ||
136 | |||
137 | #ifdef CONFIG_X86_64 | ||
138 | |||
139 | /* correctly size the local cpu masks */ | ||
140 | static void setup_cpu_local_masks(void) | ||
141 | { | ||
142 | alloc_bootmem_cpumask_var(&cpu_initialized_mask); | ||
143 | alloc_bootmem_cpumask_var(&cpu_callin_mask); | ||
144 | alloc_bootmem_cpumask_var(&cpu_callout_mask); | ||
145 | alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask); | ||
146 | } | ||
147 | |||
148 | #else /* CONFIG_X86_32 */ | ||
149 | |||
150 | static inline void setup_cpu_local_masks(void) | ||
151 | { | ||
152 | } | ||
153 | |||
154 | #endif /* CONFIG_X86_32 */ | ||
135 | 155 | ||
136 | /* | 156 | /* |
137 | * Great future plan: | 157 | * Great future plan: |
@@ -187,6 +207,9 @@ void __init setup_per_cpu_areas(void) | |||
187 | 207 | ||
188 | /* Setup node to cpumask map */ | 208 | /* Setup node to cpumask map */ |
189 | setup_node_to_cpumask_map(); | 209 | setup_node_to_cpumask_map(); |
210 | |||
211 | /* Setup cpu initialized, callin, callout masks */ | ||
212 | setup_cpu_local_masks(); | ||
190 | } | 213 | } |
191 | 214 | ||
192 | #endif | 215 | #endif |
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c index beea2649a240..182135ba1eaf 100644 --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c | |||
@@ -128,16 +128,23 @@ void native_send_call_func_single_ipi(int cpu) | |||
128 | 128 | ||
129 | void native_send_call_func_ipi(const struct cpumask *mask) | 129 | void native_send_call_func_ipi(const struct cpumask *mask) |
130 | { | 130 | { |
131 | cpumask_t allbutself; | 131 | cpumask_var_t allbutself; |
132 | 132 | ||
133 | allbutself = cpu_online_map; | 133 | if (!alloc_cpumask_var(&allbutself, GFP_ATOMIC)) { |
134 | cpu_clear(smp_processor_id(), allbutself); | 134 | send_IPI_mask(mask, CALL_FUNCTION_VECTOR); |
135 | return; | ||
136 | } | ||
135 | 137 | ||
136 | if (cpus_equal(*mask, allbutself) && | 138 | cpumask_copy(allbutself, cpu_online_mask); |
137 | cpus_equal(cpu_online_map, cpu_callout_map)) | 139 | cpumask_clear_cpu(smp_processor_id(), allbutself); |
140 | |||
141 | if (cpumask_equal(mask, allbutself) && | ||
142 | cpumask_equal(cpu_online_mask, cpu_callout_mask)) | ||
138 | send_IPI_allbutself(CALL_FUNCTION_VECTOR); | 143 | send_IPI_allbutself(CALL_FUNCTION_VECTOR); |
139 | else | 144 | else |
140 | send_IPI_mask(mask, CALL_FUNCTION_VECTOR); | 145 | send_IPI_mask(mask, CALL_FUNCTION_VECTOR); |
146 | |||
147 | free_cpumask_var(allbutself); | ||
141 | } | 148 | } |
142 | 149 | ||
143 | /* | 150 | /* |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 6bd4d9b73870..00e17e589482 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -102,9 +102,6 @@ EXPORT_SYMBOL(smp_num_siblings); | |||
102 | /* Last level cache ID of each logical CPU */ | 102 | /* Last level cache ID of each logical CPU */ |
103 | DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID; | 103 | DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID; |
104 | 104 | ||
105 | cpumask_t cpu_callin_map; | ||
106 | cpumask_t cpu_callout_map; | ||
107 | |||
108 | /* representing HT siblings of each logical CPU */ | 105 | /* representing HT siblings of each logical CPU */ |
109 | DEFINE_PER_CPU(cpumask_t, cpu_sibling_map); | 106 | DEFINE_PER_CPU(cpumask_t, cpu_sibling_map); |
110 | EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); | 107 | EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); |
@@ -120,9 +117,6 @@ EXPORT_PER_CPU_SYMBOL(cpu_info); | |||
120 | static atomic_t init_deasserted; | 117 | static atomic_t init_deasserted; |
121 | 118 | ||
122 | 119 | ||
123 | /* representing cpus for which sibling maps can be computed */ | ||
124 | static cpumask_t cpu_sibling_setup_map; | ||
125 | |||
126 | /* Set if we find a B stepping CPU */ | 120 | /* Set if we find a B stepping CPU */ |
127 | static int __cpuinitdata smp_b_stepping; | 121 | static int __cpuinitdata smp_b_stepping; |
128 | 122 | ||
@@ -140,7 +134,7 @@ EXPORT_SYMBOL(cpu_to_node_map); | |||
140 | static void map_cpu_to_node(int cpu, int node) | 134 | static void map_cpu_to_node(int cpu, int node) |
141 | { | 135 | { |
142 | printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node); | 136 | printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node); |
143 | cpu_set(cpu, node_to_cpumask_map[node]); | 137 | cpumask_set_cpu(cpu, &node_to_cpumask_map[node]); |
144 | cpu_to_node_map[cpu] = node; | 138 | cpu_to_node_map[cpu] = node; |
145 | } | 139 | } |
146 | 140 | ||
@@ -151,7 +145,7 @@ static void unmap_cpu_to_node(int cpu) | |||
151 | 145 | ||
152 | printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu); | 146 | printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu); |
153 | for (node = 0; node < MAX_NUMNODES; node++) | 147 | for (node = 0; node < MAX_NUMNODES; node++) |
154 | cpu_clear(cpu, node_to_cpumask_map[node]); | 148 | cpumask_clear_cpu(cpu, &node_to_cpumask_map[node]); |
155 | cpu_to_node_map[cpu] = 0; | 149 | cpu_to_node_map[cpu] = 0; |
156 | } | 150 | } |
157 | #else /* !(CONFIG_NUMA && CONFIG_X86_32) */ | 151 | #else /* !(CONFIG_NUMA && CONFIG_X86_32) */ |
@@ -209,7 +203,7 @@ static void __cpuinit smp_callin(void) | |||
209 | */ | 203 | */ |
210 | phys_id = read_apic_id(); | 204 | phys_id = read_apic_id(); |
211 | cpuid = smp_processor_id(); | 205 | cpuid = smp_processor_id(); |
212 | if (cpu_isset(cpuid, cpu_callin_map)) { | 206 | if (cpumask_test_cpu(cpuid, cpu_callin_mask)) { |
213 | panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, | 207 | panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, |
214 | phys_id, cpuid); | 208 | phys_id, cpuid); |
215 | } | 209 | } |
@@ -231,7 +225,7 @@ static void __cpuinit smp_callin(void) | |||
231 | /* | 225 | /* |
232 | * Has the boot CPU finished it's STARTUP sequence? | 226 | * Has the boot CPU finished it's STARTUP sequence? |
233 | */ | 227 | */ |
234 | if (cpu_isset(cpuid, cpu_callout_map)) | 228 | if (cpumask_test_cpu(cpuid, cpu_callout_mask)) |
235 | break; | 229 | break; |
236 | cpu_relax(); | 230 | cpu_relax(); |
237 | } | 231 | } |
@@ -274,7 +268,7 @@ static void __cpuinit smp_callin(void) | |||
274 | /* | 268 | /* |
275 | * Allow the master to continue. | 269 | * Allow the master to continue. |
276 | */ | 270 | */ |
277 | cpu_set(cpuid, cpu_callin_map); | 271 | cpumask_set_cpu(cpuid, cpu_callin_mask); |
278 | } | 272 | } |
279 | 273 | ||
280 | static int __cpuinitdata unsafe_smp; | 274 | static int __cpuinitdata unsafe_smp; |
@@ -332,7 +326,7 @@ notrace static void __cpuinit start_secondary(void *unused) | |||
332 | ipi_call_lock(); | 326 | ipi_call_lock(); |
333 | lock_vector_lock(); | 327 | lock_vector_lock(); |
334 | __setup_vector_irq(smp_processor_id()); | 328 | __setup_vector_irq(smp_processor_id()); |
335 | cpu_set(smp_processor_id(), cpu_online_map); | 329 | set_cpu_online(smp_processor_id(), true); |
336 | unlock_vector_lock(); | 330 | unlock_vector_lock(); |
337 | ipi_call_unlock(); | 331 | ipi_call_unlock(); |
338 | per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; | 332 | per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; |
@@ -438,50 +432,52 @@ void __cpuinit set_cpu_sibling_map(int cpu) | |||
438 | int i; | 432 | int i; |
439 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 433 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
440 | 434 | ||
441 | cpu_set(cpu, cpu_sibling_setup_map); | 435 | cpumask_set_cpu(cpu, cpu_sibling_setup_mask); |
442 | 436 | ||
443 | if (smp_num_siblings > 1) { | 437 | if (smp_num_siblings > 1) { |
444 | for_each_cpu_mask_nr(i, cpu_sibling_setup_map) { | 438 | for_each_cpu(i, cpu_sibling_setup_mask) { |
445 | if (c->phys_proc_id == cpu_data(i).phys_proc_id && | 439 | struct cpuinfo_x86 *o = &cpu_data(i); |
446 | c->cpu_core_id == cpu_data(i).cpu_core_id) { | 440 | |
447 | cpu_set(i, per_cpu(cpu_sibling_map, cpu)); | 441 | if (c->phys_proc_id == o->phys_proc_id && |
448 | cpu_set(cpu, per_cpu(cpu_sibling_map, i)); | 442 | c->cpu_core_id == o->cpu_core_id) { |
449 | cpu_set(i, per_cpu(cpu_core_map, cpu)); | 443 | cpumask_set_cpu(i, cpu_sibling_mask(cpu)); |
450 | cpu_set(cpu, per_cpu(cpu_core_map, i)); | 444 | cpumask_set_cpu(cpu, cpu_sibling_mask(i)); |
451 | cpu_set(i, c->llc_shared_map); | 445 | cpumask_set_cpu(i, cpu_core_mask(cpu)); |
452 | cpu_set(cpu, cpu_data(i).llc_shared_map); | 446 | cpumask_set_cpu(cpu, cpu_core_mask(i)); |
447 | cpumask_set_cpu(i, &c->llc_shared_map); | ||
448 | cpumask_set_cpu(cpu, &o->llc_shared_map); | ||
453 | } | 449 | } |
454 | } | 450 | } |
455 | } else { | 451 | } else { |
456 | cpu_set(cpu, per_cpu(cpu_sibling_map, cpu)); | 452 | cpumask_set_cpu(cpu, cpu_sibling_mask(cpu)); |
457 | } | 453 | } |
458 | 454 | ||
459 | cpu_set(cpu, c->llc_shared_map); | 455 | cpumask_set_cpu(cpu, &c->llc_shared_map); |
460 | 456 | ||
461 | if (current_cpu_data.x86_max_cores == 1) { | 457 | if (current_cpu_data.x86_max_cores == 1) { |
462 | per_cpu(cpu_core_map, cpu) = per_cpu(cpu_sibling_map, cpu); | 458 | cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu)); |
463 | c->booted_cores = 1; | 459 | c->booted_cores = 1; |
464 | return; | 460 | return; |
465 | } | 461 | } |
466 | 462 | ||
467 | for_each_cpu_mask_nr(i, cpu_sibling_setup_map) { | 463 | for_each_cpu(i, cpu_sibling_setup_mask) { |
468 | if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && | 464 | if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && |
469 | per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { | 465 | per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { |
470 | cpu_set(i, c->llc_shared_map); | 466 | cpumask_set_cpu(i, &c->llc_shared_map); |
471 | cpu_set(cpu, cpu_data(i).llc_shared_map); | 467 | cpumask_set_cpu(cpu, &cpu_data(i).llc_shared_map); |
472 | } | 468 | } |
473 | if (c->phys_proc_id == cpu_data(i).phys_proc_id) { | 469 | if (c->phys_proc_id == cpu_data(i).phys_proc_id) { |
474 | cpu_set(i, per_cpu(cpu_core_map, cpu)); | 470 | cpumask_set_cpu(i, cpu_core_mask(cpu)); |
475 | cpu_set(cpu, per_cpu(cpu_core_map, i)); | 471 | cpumask_set_cpu(cpu, cpu_core_mask(i)); |
476 | /* | 472 | /* |
477 | * Does this new cpu bringup a new core? | 473 | * Does this new cpu bringup a new core? |
478 | */ | 474 | */ |
479 | if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1) { | 475 | if (cpumask_weight(cpu_sibling_mask(cpu)) == 1) { |
480 | /* | 476 | /* |
481 | * for each core in package, increment | 477 | * for each core in package, increment |
482 | * the booted_cores for this new cpu | 478 | * the booted_cores for this new cpu |
483 | */ | 479 | */ |
484 | if (first_cpu(per_cpu(cpu_sibling_map, i)) == i) | 480 | if (cpumask_first(cpu_sibling_mask(i)) == i) |
485 | c->booted_cores++; | 481 | c->booted_cores++; |
486 | /* | 482 | /* |
487 | * increment the core count for all | 483 | * increment the core count for all |
@@ -504,7 +500,7 @@ const struct cpumask *cpu_coregroup_mask(int cpu) | |||
504 | * And for power savings, we return cpu_core_map | 500 | * And for power savings, we return cpu_core_map |
505 | */ | 501 | */ |
506 | if (sched_mc_power_savings || sched_smt_power_savings) | 502 | if (sched_mc_power_savings || sched_smt_power_savings) |
507 | return &per_cpu(cpu_core_map, cpu); | 503 | return cpu_core_mask(cpu); |
508 | else | 504 | else |
509 | return &c->llc_shared_map; | 505 | return &c->llc_shared_map; |
510 | } | 506 | } |
@@ -523,7 +519,7 @@ static void impress_friends(void) | |||
523 | */ | 519 | */ |
524 | pr_debug("Before bogomips.\n"); | 520 | pr_debug("Before bogomips.\n"); |
525 | for_each_possible_cpu(cpu) | 521 | for_each_possible_cpu(cpu) |
526 | if (cpu_isset(cpu, cpu_callout_map)) | 522 | if (cpumask_test_cpu(cpu, cpu_callout_mask)) |
527 | bogosum += cpu_data(cpu).loops_per_jiffy; | 523 | bogosum += cpu_data(cpu).loops_per_jiffy; |
528 | printk(KERN_INFO | 524 | printk(KERN_INFO |
529 | "Total of %d processors activated (%lu.%02lu BogoMIPS).\n", | 525 | "Total of %d processors activated (%lu.%02lu BogoMIPS).\n", |
@@ -904,19 +900,19 @@ do_rest: | |||
904 | * allow APs to start initializing. | 900 | * allow APs to start initializing. |
905 | */ | 901 | */ |
906 | pr_debug("Before Callout %d.\n", cpu); | 902 | pr_debug("Before Callout %d.\n", cpu); |
907 | cpu_set(cpu, cpu_callout_map); | 903 | cpumask_set_cpu(cpu, cpu_callout_mask); |
908 | pr_debug("After Callout %d.\n", cpu); | 904 | pr_debug("After Callout %d.\n", cpu); |
909 | 905 | ||
910 | /* | 906 | /* |
911 | * Wait 5s total for a response | 907 | * Wait 5s total for a response |
912 | */ | 908 | */ |
913 | for (timeout = 0; timeout < 50000; timeout++) { | 909 | for (timeout = 0; timeout < 50000; timeout++) { |
914 | if (cpu_isset(cpu, cpu_callin_map)) | 910 | if (cpumask_test_cpu(cpu, cpu_callin_mask)) |
915 | break; /* It has booted */ | 911 | break; /* It has booted */ |
916 | udelay(100); | 912 | udelay(100); |
917 | } | 913 | } |
918 | 914 | ||
919 | if (cpu_isset(cpu, cpu_callin_map)) { | 915 | if (cpumask_test_cpu(cpu, cpu_callin_mask)) { |
920 | /* number CPUs logically, starting from 1 (BSP is 0) */ | 916 | /* number CPUs logically, starting from 1 (BSP is 0) */ |
921 | pr_debug("OK.\n"); | 917 | pr_debug("OK.\n"); |
922 | printk(KERN_INFO "CPU%d: ", cpu); | 918 | printk(KERN_INFO "CPU%d: ", cpu); |
@@ -941,9 +937,14 @@ restore_state: | |||
941 | if (boot_error) { | 937 | if (boot_error) { |
942 | /* Try to put things back the way they were before ... */ | 938 | /* Try to put things back the way they were before ... */ |
943 | numa_remove_cpu(cpu); /* was set by numa_add_cpu */ | 939 | numa_remove_cpu(cpu); /* was set by numa_add_cpu */ |
944 | cpu_clear(cpu, cpu_callout_map); /* was set by do_boot_cpu() */ | 940 | |
945 | cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */ | 941 | /* was set by do_boot_cpu() */ |
946 | cpu_clear(cpu, cpu_present_map); | 942 | cpumask_clear_cpu(cpu, cpu_callout_mask); |
943 | |||
944 | /* was set by cpu_init() */ | ||
945 | cpumask_clear_cpu(cpu, cpu_initialized_mask); | ||
946 | |||
947 | set_cpu_present(cpu, false); | ||
947 | per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID; | 948 | per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID; |
948 | } | 949 | } |
949 | 950 | ||
@@ -977,7 +978,7 @@ int __cpuinit native_cpu_up(unsigned int cpu) | |||
977 | /* | 978 | /* |
978 | * Already booted CPU? | 979 | * Already booted CPU? |
979 | */ | 980 | */ |
980 | if (cpu_isset(cpu, cpu_callin_map)) { | 981 | if (cpumask_test_cpu(cpu, cpu_callin_mask)) { |
981 | pr_debug("do_boot_cpu %d Already started\n", cpu); | 982 | pr_debug("do_boot_cpu %d Already started\n", cpu); |
982 | return -ENOSYS; | 983 | return -ENOSYS; |
983 | } | 984 | } |
@@ -1032,8 +1033,9 @@ int __cpuinit native_cpu_up(unsigned int cpu) | |||
1032 | */ | 1033 | */ |
1033 | static __init void disable_smp(void) | 1034 | static __init void disable_smp(void) |
1034 | { | 1035 | { |
1035 | cpu_present_map = cpumask_of_cpu(0); | 1036 | /* use the read/write pointers to the present and possible maps */ |
1036 | cpu_possible_map = cpumask_of_cpu(0); | 1037 | cpumask_copy(&cpu_present_map, cpumask_of(0)); |
1038 | cpumask_copy(&cpu_possible_map, cpumask_of(0)); | ||
1037 | smpboot_clear_io_apic_irqs(); | 1039 | smpboot_clear_io_apic_irqs(); |
1038 | 1040 | ||
1039 | if (smp_found_config) | 1041 | if (smp_found_config) |
@@ -1041,8 +1043,8 @@ static __init void disable_smp(void) | |||
1041 | else | 1043 | else |
1042 | physid_set_mask_of_physid(0, &phys_cpu_present_map); | 1044 | physid_set_mask_of_physid(0, &phys_cpu_present_map); |
1043 | map_cpu_to_logical_apicid(); | 1045 | map_cpu_to_logical_apicid(); |
1044 | cpu_set(0, per_cpu(cpu_sibling_map, 0)); | 1046 | cpumask_set_cpu(0, cpu_sibling_mask(0)); |
1045 | cpu_set(0, per_cpu(cpu_core_map, 0)); | 1047 | cpumask_set_cpu(0, cpu_core_mask(0)); |
1046 | } | 1048 | } |
1047 | 1049 | ||
1048 | /* | 1050 | /* |
@@ -1064,14 +1066,14 @@ static int __init smp_sanity_check(unsigned max_cpus) | |||
1064 | nr = 0; | 1066 | nr = 0; |
1065 | for_each_present_cpu(cpu) { | 1067 | for_each_present_cpu(cpu) { |
1066 | if (nr >= 8) | 1068 | if (nr >= 8) |
1067 | cpu_clear(cpu, cpu_present_map); | 1069 | set_cpu_present(cpu, false); |
1068 | nr++; | 1070 | nr++; |
1069 | } | 1071 | } |
1070 | 1072 | ||
1071 | nr = 0; | 1073 | nr = 0; |
1072 | for_each_possible_cpu(cpu) { | 1074 | for_each_possible_cpu(cpu) { |
1073 | if (nr >= 8) | 1075 | if (nr >= 8) |
1074 | cpu_clear(cpu, cpu_possible_map); | 1076 | set_cpu_possible(cpu, false); |
1075 | nr++; | 1077 | nr++; |
1076 | } | 1078 | } |
1077 | 1079 | ||
@@ -1167,7 +1169,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) | |||
1167 | preempt_disable(); | 1169 | preempt_disable(); |
1168 | smp_cpu_index_default(); | 1170 | smp_cpu_index_default(); |
1169 | current_cpu_data = boot_cpu_data; | 1171 | current_cpu_data = boot_cpu_data; |
1170 | cpu_callin_map = cpumask_of_cpu(0); | 1172 | cpumask_copy(cpu_callin_mask, cpumask_of(0)); |
1171 | mb(); | 1173 | mb(); |
1172 | /* | 1174 | /* |
1173 | * Setup boot CPU information | 1175 | * Setup boot CPU information |
@@ -1242,8 +1244,8 @@ void __init native_smp_prepare_boot_cpu(void) | |||
1242 | init_gdt(me); | 1244 | init_gdt(me); |
1243 | #endif | 1245 | #endif |
1244 | switch_to_new_gdt(); | 1246 | switch_to_new_gdt(); |
1245 | /* already set me in cpu_online_map in boot_cpu_init() */ | 1247 | /* already set me in cpu_online_mask in boot_cpu_init() */ |
1246 | cpu_set(me, cpu_callout_map); | 1248 | cpumask_set_cpu(me, cpu_callout_mask); |
1247 | per_cpu(cpu_state, me) = CPU_ONLINE; | 1249 | per_cpu(cpu_state, me) = CPU_ONLINE; |
1248 | } | 1250 | } |
1249 | 1251 | ||
@@ -1311,7 +1313,7 @@ __init void prefill_possible_map(void) | |||
1311 | possible, max_t(int, possible - num_processors, 0)); | 1313 | possible, max_t(int, possible - num_processors, 0)); |
1312 | 1314 | ||
1313 | for (i = 0; i < possible; i++) | 1315 | for (i = 0; i < possible; i++) |
1314 | cpu_set(i, cpu_possible_map); | 1316 | set_cpu_possible(i, true); |
1315 | 1317 | ||
1316 | nr_cpu_ids = possible; | 1318 | nr_cpu_ids = possible; |
1317 | } | 1319 | } |
@@ -1323,31 +1325,31 @@ static void remove_siblinginfo(int cpu) | |||
1323 | int sibling; | 1325 | int sibling; |
1324 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 1326 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
1325 | 1327 | ||
1326 | for_each_cpu_mask_nr(sibling, per_cpu(cpu_core_map, cpu)) { | 1328 | for_each_cpu(sibling, cpu_core_mask(cpu)) { |
1327 | cpu_clear(cpu, per_cpu(cpu_core_map, sibling)); | 1329 | cpumask_clear_cpu(cpu, cpu_core_mask(sibling)); |
1328 | /*/ | 1330 | /*/ |
1329 | * last thread sibling in this cpu core going down | 1331 | * last thread sibling in this cpu core going down |
1330 | */ | 1332 | */ |
1331 | if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1) | 1333 | if (cpumask_weight(cpu_sibling_mask(cpu)) == 1) |
1332 | cpu_data(sibling).booted_cores--; | 1334 | cpu_data(sibling).booted_cores--; |
1333 | } | 1335 | } |
1334 | 1336 | ||
1335 | for_each_cpu_mask_nr(sibling, per_cpu(cpu_sibling_map, cpu)) | 1337 | for_each_cpu(sibling, cpu_sibling_mask(cpu)) |
1336 | cpu_clear(cpu, per_cpu(cpu_sibling_map, sibling)); | 1338 | cpumask_clear_cpu(cpu, cpu_sibling_mask(sibling)); |
1337 | cpus_clear(per_cpu(cpu_sibling_map, cpu)); | 1339 | cpumask_clear(cpu_sibling_mask(cpu)); |
1338 | cpus_clear(per_cpu(cpu_core_map, cpu)); | 1340 | cpumask_clear(cpu_core_mask(cpu)); |
1339 | c->phys_proc_id = 0; | 1341 | c->phys_proc_id = 0; |
1340 | c->cpu_core_id = 0; | 1342 | c->cpu_core_id = 0; |
1341 | cpu_clear(cpu, cpu_sibling_setup_map); | 1343 | cpumask_clear_cpu(cpu, cpu_sibling_setup_mask); |
1342 | } | 1344 | } |
1343 | 1345 | ||
1344 | static void __ref remove_cpu_from_maps(int cpu) | 1346 | static void __ref remove_cpu_from_maps(int cpu) |
1345 | { | 1347 | { |
1346 | cpu_clear(cpu, cpu_online_map); | 1348 | set_cpu_online(cpu, false); |
1347 | cpu_clear(cpu, cpu_callout_map); | 1349 | cpumask_clear_cpu(cpu, cpu_callout_mask); |
1348 | cpu_clear(cpu, cpu_callin_map); | 1350 | cpumask_clear_cpu(cpu, cpu_callin_mask); |
1349 | /* was set by cpu_init() */ | 1351 | /* was set by cpu_init() */ |
1350 | cpu_clear(cpu, cpu_initialized); | 1352 | cpumask_clear_cpu(cpu, cpu_initialized_mask); |
1351 | numa_remove_cpu(cpu); | 1353 | numa_remove_cpu(cpu); |
1352 | } | 1354 | } |
1353 | 1355 | ||
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 01dde80597f7..b55cb67435bd 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -584,12 +584,12 @@ out: | |||
584 | return i; | 584 | return i; |
585 | } | 585 | } |
586 | 586 | ||
587 | static ssize_t show_cpus(cpumask_t mask, char *buf) | 587 | static ssize_t show_cpus(const struct cpumask *mask, char *buf) |
588 | { | 588 | { |
589 | ssize_t i = 0; | 589 | ssize_t i = 0; |
590 | unsigned int cpu; | 590 | unsigned int cpu; |
591 | 591 | ||
592 | for_each_cpu_mask_nr(cpu, mask) { | 592 | for_each_cpu(cpu, mask) { |
593 | if (i) | 593 | if (i) |
594 | i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " "); | 594 | i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " "); |
595 | i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u", cpu); | 595 | i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u", cpu); |
@@ -606,7 +606,7 @@ static ssize_t show_cpus(cpumask_t mask, char *buf) | |||
606 | */ | 606 | */ |
607 | static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) | 607 | static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) |
608 | { | 608 | { |
609 | if (cpus_empty(policy->related_cpus)) | 609 | if (cpumask_empty(policy->related_cpus)) |
610 | return show_cpus(policy->cpus, buf); | 610 | return show_cpus(policy->cpus, buf); |
611 | return show_cpus(policy->related_cpus, buf); | 611 | return show_cpus(policy->related_cpus, buf); |
612 | } | 612 | } |
@@ -806,9 +806,20 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
806 | ret = -ENOMEM; | 806 | ret = -ENOMEM; |
807 | goto nomem_out; | 807 | goto nomem_out; |
808 | } | 808 | } |
809 | if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) { | ||
810 | kfree(policy); | ||
811 | ret = -ENOMEM; | ||
812 | goto nomem_out; | ||
813 | } | ||
814 | if (!alloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) { | ||
815 | free_cpumask_var(policy->cpus); | ||
816 | kfree(policy); | ||
817 | ret = -ENOMEM; | ||
818 | goto nomem_out; | ||
819 | } | ||
809 | 820 | ||
810 | policy->cpu = cpu; | 821 | policy->cpu = cpu; |
811 | policy->cpus = cpumask_of_cpu(cpu); | 822 | cpumask_copy(policy->cpus, cpumask_of(cpu)); |
812 | 823 | ||
813 | /* Initially set CPU itself as the policy_cpu */ | 824 | /* Initially set CPU itself as the policy_cpu */ |
814 | per_cpu(policy_cpu, cpu) = cpu; | 825 | per_cpu(policy_cpu, cpu) = cpu; |
@@ -843,7 +854,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
843 | } | 854 | } |
844 | #endif | 855 | #endif |
845 | 856 | ||
846 | for_each_cpu_mask_nr(j, policy->cpus) { | 857 | for_each_cpu(j, policy->cpus) { |
847 | if (cpu == j) | 858 | if (cpu == j) |
848 | continue; | 859 | continue; |
849 | 860 | ||
@@ -861,7 +872,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
861 | goto err_out_driver_exit; | 872 | goto err_out_driver_exit; |
862 | 873 | ||
863 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 874 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
864 | managed_policy->cpus = policy->cpus; | 875 | cpumask_copy(managed_policy->cpus, policy->cpus); |
865 | per_cpu(cpufreq_cpu_data, cpu) = managed_policy; | 876 | per_cpu(cpufreq_cpu_data, cpu) = managed_policy; |
866 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 877 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
867 | 878 | ||
@@ -916,14 +927,14 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
916 | } | 927 | } |
917 | 928 | ||
918 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 929 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
919 | for_each_cpu_mask_nr(j, policy->cpus) { | 930 | for_each_cpu(j, policy->cpus) { |
920 | per_cpu(cpufreq_cpu_data, j) = policy; | 931 | per_cpu(cpufreq_cpu_data, j) = policy; |
921 | per_cpu(policy_cpu, j) = policy->cpu; | 932 | per_cpu(policy_cpu, j) = policy->cpu; |
922 | } | 933 | } |
923 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 934 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
924 | 935 | ||
925 | /* symlink affected CPUs */ | 936 | /* symlink affected CPUs */ |
926 | for_each_cpu_mask_nr(j, policy->cpus) { | 937 | for_each_cpu(j, policy->cpus) { |
927 | if (j == cpu) | 938 | if (j == cpu) |
928 | continue; | 939 | continue; |
929 | if (!cpu_online(j)) | 940 | if (!cpu_online(j)) |
@@ -963,7 +974,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
963 | 974 | ||
964 | err_out_unregister: | 975 | err_out_unregister: |
965 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 976 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
966 | for_each_cpu_mask_nr(j, policy->cpus) | 977 | for_each_cpu(j, policy->cpus) |
967 | per_cpu(cpufreq_cpu_data, j) = NULL; | 978 | per_cpu(cpufreq_cpu_data, j) = NULL; |
968 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 979 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
969 | 980 | ||
@@ -1024,7 +1035,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1024 | */ | 1035 | */ |
1025 | if (unlikely(cpu != data->cpu)) { | 1036 | if (unlikely(cpu != data->cpu)) { |
1026 | dprintk("removing link\n"); | 1037 | dprintk("removing link\n"); |
1027 | cpu_clear(cpu, data->cpus); | 1038 | cpumask_clear_cpu(cpu, data->cpus); |
1028 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1039 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1029 | sysfs_remove_link(&sys_dev->kobj, "cpufreq"); | 1040 | sysfs_remove_link(&sys_dev->kobj, "cpufreq"); |
1030 | cpufreq_cpu_put(data); | 1041 | cpufreq_cpu_put(data); |
@@ -1045,8 +1056,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1045 | * per_cpu(cpufreq_cpu_data) while holding the lock, and remove | 1056 | * per_cpu(cpufreq_cpu_data) while holding the lock, and remove |
1046 | * the sysfs links afterwards. | 1057 | * the sysfs links afterwards. |
1047 | */ | 1058 | */ |
1048 | if (unlikely(cpus_weight(data->cpus) > 1)) { | 1059 | if (unlikely(cpumask_weight(data->cpus) > 1)) { |
1049 | for_each_cpu_mask_nr(j, data->cpus) { | 1060 | for_each_cpu(j, data->cpus) { |
1050 | if (j == cpu) | 1061 | if (j == cpu) |
1051 | continue; | 1062 | continue; |
1052 | per_cpu(cpufreq_cpu_data, j) = NULL; | 1063 | per_cpu(cpufreq_cpu_data, j) = NULL; |
@@ -1055,8 +1066,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1055 | 1066 | ||
1056 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1067 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1057 | 1068 | ||
1058 | if (unlikely(cpus_weight(data->cpus) > 1)) { | 1069 | if (unlikely(cpumask_weight(data->cpus) > 1)) { |
1059 | for_each_cpu_mask_nr(j, data->cpus) { | 1070 | for_each_cpu(j, data->cpus) { |
1060 | if (j == cpu) | 1071 | if (j == cpu) |
1061 | continue; | 1072 | continue; |
1062 | dprintk("removing link for cpu %u\n", j); | 1073 | dprintk("removing link for cpu %u\n", j); |
@@ -1090,7 +1101,10 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1090 | if (cpufreq_driver->exit) | 1101 | if (cpufreq_driver->exit) |
1091 | cpufreq_driver->exit(data); | 1102 | cpufreq_driver->exit(data); |
1092 | 1103 | ||
1104 | free_cpumask_var(data->related_cpus); | ||
1105 | free_cpumask_var(data->cpus); | ||
1093 | kfree(data); | 1106 | kfree(data); |
1107 | per_cpu(cpufreq_cpu_data, cpu) = NULL; | ||
1094 | 1108 | ||
1095 | cpufreq_debug_enable_ratelimit(); | 1109 | cpufreq_debug_enable_ratelimit(); |
1096 | return 0; | 1110 | return 0; |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index e2657837d954..0320962c4ec5 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -498,7 +498,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
498 | return rc; | 498 | return rc; |
499 | } | 499 | } |
500 | 500 | ||
501 | for_each_cpu_mask_nr(j, policy->cpus) { | 501 | for_each_cpu(j, policy->cpus) { |
502 | struct cpu_dbs_info_s *j_dbs_info; | 502 | struct cpu_dbs_info_s *j_dbs_info; |
503 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | 503 | j_dbs_info = &per_cpu(cpu_dbs_info, j); |
504 | j_dbs_info->cur_policy = policy; | 504 | j_dbs_info->cur_policy = policy; |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 2ab3c12b88af..6a2b036c9389 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -400,7 +400,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
400 | /* Get Absolute Load - in terms of freq */ | 400 | /* Get Absolute Load - in terms of freq */ |
401 | max_load_freq = 0; | 401 | max_load_freq = 0; |
402 | 402 | ||
403 | for_each_cpu_mask_nr(j, policy->cpus) { | 403 | for_each_cpu(j, policy->cpus) { |
404 | struct cpu_dbs_info_s *j_dbs_info; | 404 | struct cpu_dbs_info_s *j_dbs_info; |
405 | cputime64_t cur_wall_time, cur_idle_time; | 405 | cputime64_t cur_wall_time, cur_idle_time; |
406 | unsigned int idle_time, wall_time; | 406 | unsigned int idle_time, wall_time; |
@@ -568,7 +568,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
568 | return rc; | 568 | return rc; |
569 | } | 569 | } |
570 | 570 | ||
571 | for_each_cpu_mask_nr(j, policy->cpus) { | 571 | for_each_cpu(j, policy->cpus) { |
572 | struct cpu_dbs_info_s *j_dbs_info; | 572 | struct cpu_dbs_info_s *j_dbs_info; |
573 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | 573 | j_dbs_info = &per_cpu(cpu_dbs_info, j); |
574 | j_dbs_info->cur_policy = policy; | 574 | j_dbs_info->cur_policy = policy; |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index c23619fb6c4b..db7ec14fa719 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -71,11 +71,11 @@ static ssize_t broken_parity_status_store(struct device *dev, | |||
71 | static ssize_t local_cpus_show(struct device *dev, | 71 | static ssize_t local_cpus_show(struct device *dev, |
72 | struct device_attribute *attr, char *buf) | 72 | struct device_attribute *attr, char *buf) |
73 | { | 73 | { |
74 | cpumask_t mask; | 74 | const struct cpumask *mask; |
75 | int len; | 75 | int len; |
76 | 76 | ||
77 | mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); | 77 | mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); |
78 | len = cpumask_scnprintf(buf, PAGE_SIZE-2, &mask); | 78 | len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); |
79 | buf[len++] = '\n'; | 79 | buf[len++] = '\n'; |
80 | buf[len] = '\0'; | 80 | buf[len] = '\0'; |
81 | return len; | 81 | return len; |
@@ -85,11 +85,11 @@ static ssize_t local_cpus_show(struct device *dev, | |||
85 | static ssize_t local_cpulist_show(struct device *dev, | 85 | static ssize_t local_cpulist_show(struct device *dev, |
86 | struct device_attribute *attr, char *buf) | 86 | struct device_attribute *attr, char *buf) |
87 | { | 87 | { |
88 | cpumask_t mask; | 88 | const struct cpumask *mask; |
89 | int len; | 89 | int len; |
90 | 90 | ||
91 | mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); | 91 | mask = cpumask_of_pcibus(to_pci_dev(dev)->bus); |
92 | len = cpulist_scnprintf(buf, PAGE_SIZE-2, &mask); | 92 | len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask); |
93 | buf[len++] = '\n'; | 93 | buf[len++] = '\n'; |
94 | buf[len] = '\0'; | 94 | buf[len] = '\0'; |
95 | return len; | 95 | return len; |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 303644614eea..55ec44a27e89 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -51,12 +51,12 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev, | |||
51 | char *buf) | 51 | char *buf) |
52 | { | 52 | { |
53 | int ret; | 53 | int ret; |
54 | cpumask_t cpumask; | 54 | const struct cpumask *cpumask; |
55 | 55 | ||
56 | cpumask = pcibus_to_cpumask(to_pci_bus(dev)); | 56 | cpumask = cpumask_of_pcibus(to_pci_bus(dev)); |
57 | ret = type? | 57 | ret = type? |
58 | cpulist_scnprintf(buf, PAGE_SIZE-2, &cpumask) : | 58 | cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask) : |
59 | cpumask_scnprintf(buf, PAGE_SIZE-2, &cpumask); | 59 | cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask); |
60 | buf[ret++] = '\n'; | 60 | buf[ret++] = '\n'; |
61 | buf[ret] = '\0'; | 61 | buf[ret] = '\0'; |
62 | return ret; | 62 | return ret; |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 484b3abf61bb..384b38d3e8e2 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -80,8 +80,8 @@ struct cpufreq_real_policy { | |||
80 | }; | 80 | }; |
81 | 81 | ||
82 | struct cpufreq_policy { | 82 | struct cpufreq_policy { |
83 | cpumask_t cpus; /* CPUs requiring sw coordination */ | 83 | cpumask_var_t cpus; /* CPUs requiring sw coordination */ |
84 | cpumask_t related_cpus; /* CPUs with any coordination */ | 84 | cpumask_var_t related_cpus; /* CPUs with any coordination */ |
85 | unsigned int shared_type; /* ANY or ALL affected CPUs | 85 | unsigned int shared_type; /* ANY or ALL affected CPUs |
86 | should set cpufreq */ | 86 | should set cpufreq */ |
87 | unsigned int cpu; /* cpu nr of registered CPU */ | 87 | unsigned int cpu; /* cpu nr of registered CPU */ |