提交 4e9b1c18 编写于 作者: L Linus Torvalds

Merge branch 'cpus4096-for-linus' of...

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()
...@@ -27,7 +27,7 @@ irq_canonicalize (int irq) ...@@ -27,7 +27,7 @@ irq_canonicalize (int irq)
} }
extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); extern void set_irq_affinity_info (unsigned int irq, int dest, int redir);
bool is_affinity_mask_valid(cpumask_var_t cpumask); bool is_affinity_mask_valid(const struct cpumask *cpumask);
#define is_affinity_mask_valid is_affinity_mask_valid #define is_affinity_mask_valid is_affinity_mask_valid
......
...@@ -124,7 +124,7 @@ extern void arch_fix_phys_package_id(int num, u32 slot); ...@@ -124,7 +124,7 @@ extern void arch_fix_phys_package_id(int num, u32 slot);
#define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \ #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
cpu_all_mask : \ cpu_all_mask : \
cpumask_from_node(pcibus_to_node(bus))) cpumask_of_node(pcibus_to_node(bus)))
#include <asm-generic/topology.h> #include <asm-generic/topology.h>
......
...@@ -102,17 +102,14 @@ static char irq_redir [NR_IRQS]; // = { [0 ... NR_IRQS-1] = 1 }; ...@@ -102,17 +102,14 @@ static char irq_redir [NR_IRQS]; // = { [0 ... NR_IRQS-1] = 1 };
void set_irq_affinity_info (unsigned int irq, int hwid, int redir) void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
{ {
cpumask_t mask = CPU_MASK_NONE;
cpu_set(cpu_logical_id(hwid), mask);
if (irq < NR_IRQS) { if (irq < NR_IRQS) {
irq_desc[irq].affinity = mask; cpumask_copy(&irq_desc[irq].affinity,
cpumask_of(cpu_logical_id(hwid)));
irq_redir[irq] = (char) (redir & 0xff); irq_redir[irq] = (char) (redir & 0xff);
} }
} }
bool is_affinity_mask_valid(cpumask_var_t cpumask) bool is_affinity_mask_valid(const struct cpumask *cpumask)
{ {
if (ia64_platform_is("sn2")) { if (ia64_platform_is("sn2")) {
/* Only allow one CPU to be specified in the smp_affinity mask */ /* 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,7 +125,7 @@ bool is_affinity_mask_valid(cpumask_var_t cpumask)
unsigned int vectors_in_migration[NR_IRQS]; unsigned int vectors_in_migration[NR_IRQS];
/* /*
* Since cpu_online_map is already updated, we just need to check for * Since cpu_online_mask is already updated, we just need to check for
* affinity that has zeros * affinity that has zeros
*/ */
static void migrate_irqs(void) static void migrate_irqs(void)
...@@ -158,7 +155,7 @@ static void migrate_irqs(void) ...@@ -158,7 +155,7 @@ static void migrate_irqs(void)
*/ */
vectors_in_migration[irq] = irq; vectors_in_migration[irq] = irq;
new_cpu = any_online_cpu(cpu_online_map); new_cpu = cpumask_any(cpu_online_mask);
/* /*
* Al three are essential, currently WARN_ON.. maybe panic? * Al three are essential, currently WARN_ON.. maybe panic?
...@@ -191,7 +188,7 @@ void fixup_irqs(void) ...@@ -191,7 +188,7 @@ void fixup_irqs(void)
* Find a new timesync master * Find a new timesync master
*/ */
if (smp_processor_id() == time_keeper_id) { if (smp_processor_id() == time_keeper_id) {
time_keeper_id = first_cpu(cpu_online_map); time_keeper_id = cpumask_first(cpu_online_mask);
printk ("CPU %d is now promoted to time-keeper master\n", time_keeper_id); printk ("CPU %d is now promoted to time-keeper master\n", time_keeper_id);
} }
......
#ifndef __ASM_ES7000_APIC_H #ifndef __ASM_ES7000_APIC_H
#define __ASM_ES7000_APIC_H #define __ASM_ES7000_APIC_H
#include <linux/gfp.h>
#define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu) #define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu)
#define esr_disable (1) #define esr_disable (1)
......
...@@ -18,9 +18,26 @@ ...@@ -18,9 +18,26 @@
#include <asm/pda.h> #include <asm/pda.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#ifdef CONFIG_X86_64
extern cpumask_var_t cpu_callin_mask;
extern cpumask_var_t cpu_callout_mask;
extern cpumask_var_t cpu_initialized_mask;
extern cpumask_var_t cpu_sibling_setup_mask;
#else /* CONFIG_X86_32 */
extern cpumask_t cpu_callin_map;
extern cpumask_t cpu_callout_map; extern cpumask_t cpu_callout_map;
extern cpumask_t cpu_initialized; extern cpumask_t cpu_initialized;
extern cpumask_t cpu_callin_map; extern cpumask_t cpu_sibling_setup_map;
#define cpu_callin_mask ((struct cpumask *)&cpu_callin_map)
#define cpu_callout_mask ((struct cpumask *)&cpu_callout_map)
#define cpu_initialized_mask ((struct cpumask *)&cpu_initialized)
#define cpu_sibling_setup_mask ((struct cpumask *)&cpu_sibling_setup_map)
#endif /* CONFIG_X86_32 */
extern void (*mtrr_hook)(void); extern void (*mtrr_hook)(void);
extern void zap_low_mappings(void); extern void zap_low_mappings(void);
...@@ -29,7 +46,6 @@ extern int __cpuinit get_local_pda(int cpu); ...@@ -29,7 +46,6 @@ extern int __cpuinit get_local_pda(int cpu);
extern int smp_num_siblings; extern int smp_num_siblings;
extern unsigned int num_processors; extern unsigned int num_processors;
extern cpumask_t cpu_initialized;
DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
DECLARE_PER_CPU(cpumask_t, cpu_core_map); DECLARE_PER_CPU(cpumask_t, cpu_core_map);
...@@ -38,6 +54,16 @@ DECLARE_PER_CPU(u16, cpu_llc_id); ...@@ -38,6 +54,16 @@ DECLARE_PER_CPU(u16, cpu_llc_id);
DECLARE_PER_CPU(int, cpu_number); DECLARE_PER_CPU(int, cpu_number);
#endif #endif
static inline struct cpumask *cpu_sibling_mask(int cpu)
{
return &per_cpu(cpu_sibling_map, cpu);
}
static inline struct cpumask *cpu_core_mask(int cpu)
{
return &per_cpu(cpu_core_map, cpu);
}
DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid);
DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid);
...@@ -149,7 +175,7 @@ void smp_store_cpu_info(int id); ...@@ -149,7 +175,7 @@ void smp_store_cpu_info(int id);
/* We don't mark CPUs online until __cpu_up(), so we need another measure */ /* We don't mark CPUs online until __cpu_up(), so we need another measure */
static inline int num_booting_cpus(void) static inline int num_booting_cpus(void)
{ {
return cpus_weight(cpu_callout_map); return cpumask_weight(cpu_callout_mask);
} }
#else #else
static inline void prefill_possible_map(void) static inline void prefill_possible_map(void)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define __ASM_SUMMIT_APIC_H #define __ASM_SUMMIT_APIC_H
#include <asm/smp.h> #include <asm/smp.h>
#include <linux/gfp.h>
#define esr_disable (1) #define esr_disable (1)
#define NO_BALANCE_IRQ (0) #define NO_BALANCE_IRQ (0)
......
...@@ -67,35 +67,15 @@ static short mwait_supported[ACPI_PROCESSOR_MAX_POWER]; ...@@ -67,35 +67,15 @@ static short mwait_supported[ACPI_PROCESSOR_MAX_POWER];
#define NATIVE_CSTATE_BEYOND_HALT (2) #define NATIVE_CSTATE_BEYOND_HALT (2)
int acpi_processor_ffh_cstate_probe(unsigned int cpu, static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
struct acpi_processor_cx *cx, struct acpi_power_register *reg)
{ {
struct cstate_entry *percpu_entry; struct acpi_processor_cx *cx = _cx;
struct cpuinfo_x86 *c = &cpu_data(cpu); long retval;
cpumask_t saved_mask;
int retval;
unsigned int eax, ebx, ecx, edx; unsigned int eax, ebx, ecx, edx;
unsigned int edx_part; unsigned int edx_part;
unsigned int cstate_type; /* C-state type and not ACPI C-state type */ unsigned int cstate_type; /* C-state type and not ACPI C-state type */
unsigned int num_cstate_subtype; unsigned int num_cstate_subtype;
if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF )
return -1;
if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT)
return -1;
percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
percpu_entry->states[cx->index].eax = 0;
percpu_entry->states[cx->index].ecx = 0;
/* Make sure we are running on right CPU */
saved_mask = current->cpus_allowed;
retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
if (retval)
return -1;
cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
/* Check whether this particular cx_type (in CST) is supported or not */ /* 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,21 +96,45 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
retval = -1; retval = -1;
goto out; goto out;
} }
percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK;
/* Use the hint in CST */
percpu_entry->states[cx->index].eax = cx->address;
if (!mwait_supported[cstate_type]) { if (!mwait_supported[cstate_type]) {
mwait_supported[cstate_type] = 1; mwait_supported[cstate_type] = 1;
printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " printk(KERN_DEBUG
"state\n", cx->type); "Monitor-Mwait will be used to enter C-%d "
"state\n", cx->type);
} }
snprintf(cx->desc, ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", snprintf(cx->desc,
cx->address); ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
cx->address);
out: out:
set_cpus_allowed_ptr(current, &saved_mask); return retval;
}
int acpi_processor_ffh_cstate_probe(unsigned int cpu,
struct acpi_processor_cx *cx, struct acpi_power_register *reg)
{
struct cstate_entry *percpu_entry;
struct cpuinfo_x86 *c = &cpu_data(cpu);
long retval;
if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF)
return -1;
if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT)
return -1;
percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
percpu_entry->states[cx->index].eax = 0;
percpu_entry->states[cx->index].ecx = 0;
/* Make sure we are running on right CPU */
retval = work_on_cpu(cpu, acpi_processor_ffh_cstate_probe_cpu, cx);
if (retval == 0) {
/* Use the hint in CST */
percpu_entry->states[cx->index].eax = cx->address;
percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK;
}
return retval; return retval;
} }
EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe); EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);
......
...@@ -40,6 +40,26 @@ ...@@ -40,6 +40,26 @@
#include "cpu.h" #include "cpu.h"
#ifdef CONFIG_X86_64
/* all of these masks are initialized in setup_cpu_local_masks() */
cpumask_var_t cpu_callin_mask;
cpumask_var_t cpu_callout_mask;
cpumask_var_t cpu_initialized_mask;
/* representing cpus for which sibling maps can be computed */
cpumask_var_t cpu_sibling_setup_mask;
#else /* CONFIG_X86_32 */
cpumask_t cpu_callin_map;
cpumask_t cpu_callout_map;
cpumask_t cpu_initialized;
cpumask_t cpu_sibling_setup_map;
#endif /* CONFIG_X86_32 */
static struct cpu_dev *this_cpu __cpuinitdata; static struct cpu_dev *this_cpu __cpuinitdata;
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
...@@ -856,8 +876,6 @@ static __init int setup_disablecpuid(char *arg) ...@@ -856,8 +876,6 @@ static __init int setup_disablecpuid(char *arg)
} }
__setup("clearcpuid=", setup_disablecpuid); __setup("clearcpuid=", setup_disablecpuid);
cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
struct x8664_pda **_cpu_pda __read_mostly; struct x8664_pda **_cpu_pda __read_mostly;
EXPORT_SYMBOL(_cpu_pda); EXPORT_SYMBOL(_cpu_pda);
...@@ -976,7 +994,7 @@ void __cpuinit cpu_init(void) ...@@ -976,7 +994,7 @@ void __cpuinit cpu_init(void)
me = current; me = current;
if (cpu_test_and_set(cpu, cpu_initialized)) if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask))
panic("CPU#%d already initialized!\n", cpu); panic("CPU#%d already initialized!\n", cpu);
printk(KERN_INFO "Initializing CPU#%d\n", cpu); printk(KERN_INFO "Initializing CPU#%d\n", cpu);
...@@ -1085,7 +1103,7 @@ void __cpuinit cpu_init(void) ...@@ -1085,7 +1103,7 @@ void __cpuinit cpu_init(void)
struct tss_struct *t = &per_cpu(init_tss, cpu); struct tss_struct *t = &per_cpu(init_tss, cpu);
struct thread_struct *thread = &curr->thread; struct thread_struct *thread = &curr->thread;
if (cpu_test_and_set(cpu, cpu_initialized)) { if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);
for (;;) local_irq_enable(); for (;;) local_irq_enable();
} }
......
...@@ -145,13 +145,14 @@ typedef union { ...@@ -145,13 +145,14 @@ typedef union {
struct drv_cmd { struct drv_cmd {
unsigned int type; unsigned int type;
cpumask_t mask; cpumask_var_t mask;
drv_addr_union addr; drv_addr_union addr;
u32 val; u32 val;
}; };
static void do_drv_read(struct drv_cmd *cmd) static long do_drv_read(void *_cmd)
{ {
struct drv_cmd *cmd = _cmd;
u32 h; u32 h;
switch (cmd->type) { switch (cmd->type) {
...@@ -166,10 +167,12 @@ static void do_drv_read(struct drv_cmd *cmd) ...@@ -166,10 +167,12 @@ static void do_drv_read(struct drv_cmd *cmd)
default: default:
break; break;
} }
return 0;
} }
static void do_drv_write(struct drv_cmd *cmd) static long do_drv_write(void *_cmd)
{ {
struct drv_cmd *cmd = _cmd;
u32 lo, hi; u32 lo, hi;
switch (cmd->type) { switch (cmd->type) {
...@@ -186,48 +189,41 @@ static void do_drv_write(struct drv_cmd *cmd) ...@@ -186,48 +189,41 @@ static void do_drv_write(struct drv_cmd *cmd)
default: default:
break; break;
} }
return 0;
} }
static void drv_read(struct drv_cmd *cmd) static void drv_read(struct drv_cmd *cmd)
{ {
cpumask_t saved_mask = current->cpus_allowed;
cmd->val = 0; cmd->val = 0;
set_cpus_allowed_ptr(current, &cmd->mask); work_on_cpu(cpumask_any(cmd->mask), do_drv_read, cmd);
do_drv_read(cmd);
set_cpus_allowed_ptr(current, &saved_mask);
} }
static void drv_write(struct drv_cmd *cmd) static void drv_write(struct drv_cmd *cmd)
{ {
cpumask_t saved_mask = current->cpus_allowed;
unsigned int i; unsigned int i;
for_each_cpu_mask_nr(i, cmd->mask) { for_each_cpu(i, cmd->mask) {
set_cpus_allowed_ptr(current, &cpumask_of_cpu(i)); work_on_cpu(i, do_drv_write, cmd);
do_drv_write(cmd);
} }
set_cpus_allowed_ptr(current, &saved_mask);
return;
} }
static u32 get_cur_val(const cpumask_t *mask) static u32 get_cur_val(const struct cpumask *mask)
{ {
struct acpi_processor_performance *perf; struct acpi_processor_performance *perf;
struct drv_cmd cmd; struct drv_cmd cmd;
if (unlikely(cpus_empty(*mask))) if (unlikely(cpumask_empty(mask)))
return 0; return 0;
switch (per_cpu(drv_data, first_cpu(*mask))->cpu_feature) { switch (per_cpu(drv_data, cpumask_first(mask))->cpu_feature) {
case SYSTEM_INTEL_MSR_CAPABLE: case SYSTEM_INTEL_MSR_CAPABLE:
cmd.type = SYSTEM_INTEL_MSR_CAPABLE; cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
cmd.addr.msr.reg = MSR_IA32_PERF_STATUS; cmd.addr.msr.reg = MSR_IA32_PERF_STATUS;
break; break;
case SYSTEM_IO_CAPABLE: case SYSTEM_IO_CAPABLE:
cmd.type = SYSTEM_IO_CAPABLE; cmd.type = SYSTEM_IO_CAPABLE;
perf = per_cpu(drv_data, first_cpu(*mask))->acpi_data; perf = per_cpu(drv_data, cpumask_first(mask))->acpi_data;
cmd.addr.io.port = perf->control_register.address; cmd.addr.io.port = perf->control_register.address;
cmd.addr.io.bit_width = perf->control_register.bit_width; cmd.addr.io.bit_width = perf->control_register.bit_width;
break; break;
...@@ -235,15 +231,44 @@ static u32 get_cur_val(const cpumask_t *mask) ...@@ -235,15 +231,44 @@ static u32 get_cur_val(const cpumask_t *mask)
return 0; return 0;
} }
cmd.mask = *mask; if (unlikely(!alloc_cpumask_var(&cmd.mask, GFP_KERNEL)))
return 0;
cpumask_copy(cmd.mask, mask);
drv_read(&cmd); drv_read(&cmd);
free_cpumask_var(cmd.mask);
dprintk("get_cur_val = %u\n", cmd.val); dprintk("get_cur_val = %u\n", cmd.val);
return cmd.val; return cmd.val;
} }
struct perf_cur {
union {
struct {
u32 lo;
u32 hi;
} split;
u64 whole;
} aperf_cur, mperf_cur;
};
static long read_measured_perf_ctrs(void *_cur)
{
struct perf_cur *cur = _cur;
rdmsr(MSR_IA32_APERF, cur->aperf_cur.split.lo, cur->aperf_cur.split.hi);
rdmsr(MSR_IA32_MPERF, cur->mperf_cur.split.lo, cur->mperf_cur.split.hi);
wrmsr(MSR_IA32_APERF, 0, 0);
wrmsr(MSR_IA32_MPERF, 0, 0);
return 0;
}
/* /*
* Return the measured active (C0) frequency on this CPU since last call * Return the measured active (C0) frequency on this CPU since last call
* to this function. * to this function.
...@@ -260,31 +285,12 @@ static u32 get_cur_val(const cpumask_t *mask) ...@@ -260,31 +285,12 @@ static u32 get_cur_val(const cpumask_t *mask)
static unsigned int get_measured_perf(struct cpufreq_policy *policy, static unsigned int get_measured_perf(struct cpufreq_policy *policy,
unsigned int cpu) unsigned int cpu)
{ {
union { struct perf_cur cur;
struct {
u32 lo;
u32 hi;
} split;
u64 whole;
} aperf_cur, mperf_cur;
cpumask_t saved_mask;
unsigned int perf_percent; unsigned int perf_percent;
unsigned int retval; unsigned int retval;
saved_mask = current->cpus_allowed; if (!work_on_cpu(cpu, read_measured_perf_ctrs, &cur))
set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
if (get_cpu() != cpu) {
/* We were not able to run on requested processor */
put_cpu();
return 0; return 0;
}
rdmsr(MSR_IA32_APERF, aperf_cur.split.lo, aperf_cur.split.hi);
rdmsr(MSR_IA32_MPERF, mperf_cur.split.lo, mperf_cur.split.hi);
wrmsr(MSR_IA32_APERF, 0,0);
wrmsr(MSR_IA32_MPERF, 0,0);
#ifdef __i386__ #ifdef __i386__
/* /*
...@@ -292,37 +298,39 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy, ...@@ -292,37 +298,39 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy,
* Get an approximate value. Return failure in case we cannot get * Get an approximate value. Return failure in case we cannot get
* an approximate value. * an approximate value.
*/ */
if (unlikely(aperf_cur.split.hi || mperf_cur.split.hi)) { if (unlikely(cur.aperf_cur.split.hi || cur.mperf_cur.split.hi)) {
int shift_count; int shift_count;
u32 h; u32 h;
h = max_t(u32, aperf_cur.split.hi, mperf_cur.split.hi); h = max_t(u32, cur.aperf_cur.split.hi, cur.mperf_cur.split.hi);
shift_count = fls(h); shift_count = fls(h);
aperf_cur.whole >>= shift_count; cur.aperf_cur.whole >>= shift_count;
mperf_cur.whole >>= shift_count; cur.mperf_cur.whole >>= shift_count;
} }
if (((unsigned long)(-1) / 100) < aperf_cur.split.lo) { if (((unsigned long)(-1) / 100) < cur.aperf_cur.split.lo) {
int shift_count = 7; int shift_count = 7;
aperf_cur.split.lo >>= shift_count; cur.aperf_cur.split.lo >>= shift_count;
mperf_cur.split.lo >>= shift_count; cur.mperf_cur.split.lo >>= shift_count;
} }
if (aperf_cur.split.lo && mperf_cur.split.lo) if (cur.aperf_cur.split.lo && cur.mperf_cur.split.lo)
perf_percent = (aperf_cur.split.lo * 100) / mperf_cur.split.lo; perf_percent = (cur.aperf_cur.split.lo * 100) /
cur.mperf_cur.split.lo;
else else
perf_percent = 0; perf_percent = 0;
#else #else
if (unlikely(((unsigned long)(-1) / 100) < aperf_cur.whole)) { if (unlikely(((unsigned long)(-1) / 100) < cur.aperf_cur.whole)) {
int shift_count = 7; int shift_count = 7;
aperf_cur.whole >>= shift_count; cur.aperf_cur.whole >>= shift_count;
mperf_cur.whole >>= shift_count; cur.mperf_cur.whole >>= shift_count;
} }
if (aperf_cur.whole && mperf_cur.whole) if (cur.aperf_cur.whole && cur.mperf_cur.whole)
perf_percent = (aperf_cur.whole * 100) / mperf_cur.whole; perf_percent = (cur.aperf_cur.whole * 100) /
cur.mperf_cur.whole;
else else
perf_percent = 0; perf_percent = 0;
...@@ -330,10 +338,6 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy, ...@@ -330,10 +338,6 @@ static unsigned int get_measured_perf(struct cpufreq_policy *policy,
retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100; retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100;
put_cpu();
set_cpus_allowed_ptr(current, &saved_mask);
dprintk("cpu %d: performance percent %d\n", cpu, perf_percent);
return retval; return retval;
} }
...@@ -351,7 +355,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu) ...@@ -351,7 +355,7 @@ static unsigned int get_cur_freq_on_cpu(unsigned int cpu)
} }
cached_freq = data->freq_table[data->acpi_data->state].frequency; cached_freq = data->freq_table[data->acpi_data->state].frequency;
freq = extract_freq(get_cur_val(&cpumask_of_cpu(cpu)), data); freq = extract_freq(get_cur_val(cpumask_of(cpu)), data);
if (freq != cached_freq) { if (freq != cached_freq) {
/* /*
* The dreaded BIOS frequency change behind our back. * The dreaded BIOS frequency change behind our back.
...@@ -386,7 +390,6 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -386,7 +390,6 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu); struct acpi_cpufreq_data *data = per_cpu(drv_data, policy->cpu);
struct acpi_processor_performance *perf; struct acpi_processor_performance *perf;
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
cpumask_t online_policy_cpus;
struct drv_cmd cmd; struct drv_cmd cmd;
unsigned int next_state = 0; /* Index into freq_table */ unsigned int next_state = 0; /* Index into freq_table */
unsigned int next_perf_state = 0; /* Index into perf table */ unsigned int next_perf_state = 0; /* Index into perf table */
...@@ -401,20 +404,18 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -401,20 +404,18 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
return -ENODEV; return -ENODEV;
} }
if (unlikely(!alloc_cpumask_var(&cmd.mask, GFP_KERNEL)))
return -ENOMEM;
perf = data->acpi_data; perf = data->acpi_data;
result = cpufreq_frequency_table_target(policy, result = cpufreq_frequency_table_target(policy,
data->freq_table, data->freq_table,
target_freq, target_freq,
relation, &next_state); relation, &next_state);
if (unlikely(result)) if (unlikely(result)) {
return -ENODEV; result = -ENODEV;
goto out;
#ifdef CONFIG_HOTPLUG_CPU }
/* cpufreq holds the hotplug lock, so we are safe from here on */
cpus_and(online_policy_cpus, cpu_online_map, policy->cpus);
#else
online_policy_cpus = policy->cpus;
#endif
next_perf_state = data->freq_table[next_state].index; next_perf_state = data->freq_table[next_state].index;
if (perf->state == next_perf_state) { if (perf->state == next_perf_state) {
...@@ -425,7 +426,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -425,7 +426,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
} else { } else {
dprintk("Already at target state (P%d)\n", dprintk("Already at target state (P%d)\n",
next_perf_state); next_perf_state);
return 0; goto out;
} }
} }
...@@ -444,19 +445,19 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -444,19 +445,19 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
cmd.val = (u32) perf->states[next_perf_state].control; cmd.val = (u32) perf->states[next_perf_state].control;
break; break;
default: default:
return -ENODEV; result = -ENODEV;
goto out;
} }
cpus_clear(cmd.mask); /* cpufreq holds the hotplug lock, so we are safe from here on */
if (policy->shared_type != CPUFREQ_SHARED_TYPE_ANY) if (policy->shared_type != CPUFREQ_SHARED_TYPE_ANY)
cmd.mask = online_policy_cpus; cpumask_and(cmd.mask, cpu_online_mask, policy->cpus);
else else
cpu_set(policy->cpu, cmd.mask); cpumask_copy(cmd.mask, cpumask_of(policy->cpu));
freqs.old = perf->states[perf->state].core_frequency * 1000; freqs.old = perf->states[perf->state].core_frequency * 1000;
freqs.new = data->freq_table[next_state].frequency; freqs.new = data->freq_table[next_state].frequency;
for_each_cpu_mask_nr(i, cmd.mask) { for_each_cpu(i, cmd.mask) {
freqs.cpu = i; freqs.cpu = i;
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
} }
...@@ -464,19 +465,22 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -464,19 +465,22 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
drv_write(&cmd); drv_write(&cmd);
if (acpi_pstate_strict) { if (acpi_pstate_strict) {
if (!check_freqs(&cmd.mask, freqs.new, data)) { if (!check_freqs(cmd.mask, freqs.new, data)) {
dprintk("acpi_cpufreq_target failed (%d)\n", dprintk("acpi_cpufreq_target failed (%d)\n",
policy->cpu); policy->cpu);
return -EAGAIN; result = -EAGAIN;
goto out;
} }
} }
for_each_cpu_mask_nr(i, cmd.mask) { for_each_cpu(i, cmd.mask) {
freqs.cpu = i; freqs.cpu = i;
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
} }
perf->state = next_perf_state; perf->state = next_perf_state;
out:
free_cpumask_var(cmd.mask);
return result; return result;
} }
...@@ -626,15 +630,15 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -626,15 +630,15 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
*/ */
if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL || if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL ||
policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
cpumask_copy(&policy->cpus, perf->shared_cpu_map); cpumask_copy(policy->cpus, perf->shared_cpu_map);
} }
cpumask_copy(&policy->related_cpus, perf->shared_cpu_map); cpumask_copy(policy->related_cpus, perf->shared_cpu_map);
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
dmi_check_system(sw_any_bug_dmi_table); dmi_check_system(sw_any_bug_dmi_table);
if (bios_with_sw_any_bug && cpus_weight(policy->cpus) == 1) { if (bios_with_sw_any_bug && cpumask_weight(policy->cpus) == 1) {
policy->shared_type = CPUFREQ_SHARED_TYPE_ALL; policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
policy->cpus = per_cpu(cpu_core_map, cpu); cpumask_copy(policy->cpus, cpu_core_mask(cpu));
} }
#endif #endif
......
...@@ -122,7 +122,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, ...@@ -122,7 +122,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
return 0; return 0;
/* notifiers */ /* notifiers */
for_each_cpu_mask_nr(i, policy->cpus) { for_each_cpu(i, policy->cpus) {
freqs.cpu = i; freqs.cpu = i;
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
} }
...@@ -130,11 +130,11 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, ...@@ -130,11 +130,11 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
/* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software /* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software
* Developer's Manual, Volume 3 * Developer's Manual, Volume 3
*/ */
for_each_cpu_mask_nr(i, policy->cpus) for_each_cpu(i, policy->cpus)
cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); cpufreq_p4_setdc(i, p4clockmod_table[newstate].index);
/* notifiers */ /* notifiers */
for_each_cpu_mask_nr(i, policy->cpus) { for_each_cpu(i, policy->cpus) {
freqs.cpu = i; freqs.cpu = i;
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
} }
...@@ -203,7 +203,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy) ...@@ -203,7 +203,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
unsigned int i; unsigned int i;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
policy->cpus = per_cpu(cpu_sibling_map, policy->cpu); cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu));
#endif #endif
/* Errata workaround */ /* Errata workaround */
......
...@@ -1199,10 +1199,10 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol) ...@@ -1199,10 +1199,10 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
set_cpus_allowed_ptr(current, &oldmask); set_cpus_allowed_ptr(current, &oldmask);
if (cpu_family == CPU_HW_PSTATE) if (cpu_family == CPU_HW_PSTATE)
pol->cpus = cpumask_of_cpu(pol->cpu); cpumask_copy(pol->cpus, cpumask_of(pol->cpu));
else else
pol->cpus = per_cpu(cpu_core_map, pol->cpu); cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu));
data->available_cores = &(pol->cpus); data->available_cores = pol->cpus;
/* Take a crude guess here. /* Take a crude guess here.
* That guess was in microseconds, so multiply with 1000 */ * That guess was in microseconds, so multiply with 1000 */
......
...@@ -53,7 +53,7 @@ struct powernow_k8_data { ...@@ -53,7 +53,7 @@ struct powernow_k8_data {
/* we need to keep track of associated cores, but let cpufreq /* we need to keep track of associated cores, but let cpufreq
* handle hotplug events - so just point at cpufreq pol->cpus * handle hotplug events - so just point at cpufreq pol->cpus
* structure */ * structure */
cpumask_t *available_cores; struct cpumask *available_cores;
}; };
......
...@@ -458,11 +458,6 @@ static int centrino_verify (struct cpufreq_policy *policy) ...@@ -458,11 +458,6 @@ static int centrino_verify (struct cpufreq_policy *policy)
* *
* Sets a new CPUFreq policy. * Sets a new CPUFreq policy.
*/ */
struct allmasks {
cpumask_t saved_mask;
cpumask_t covered_cpus;
};
static int centrino_target (struct cpufreq_policy *policy, static int centrino_target (struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int target_freq,
unsigned int relation) unsigned int relation)
...@@ -472,12 +467,15 @@ static int centrino_target (struct cpufreq_policy *policy, ...@@ -472,12 +467,15 @@ static int centrino_target (struct cpufreq_policy *policy,
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
int retval = 0; int retval = 0;
unsigned int j, k, first_cpu, tmp; unsigned int j, k, first_cpu, tmp;
CPUMASK_ALLOC(allmasks); cpumask_var_t saved_mask, covered_cpus;
CPUMASK_PTR(saved_mask, allmasks);
CPUMASK_PTR(covered_cpus, allmasks);
if (unlikely(allmasks == NULL)) if (unlikely(!alloc_cpumask_var(&saved_mask, GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
if (unlikely(!alloc_cpumask_var(&covered_cpus, GFP_KERNEL))) {
free_cpumask_var(saved_mask);
return -ENOMEM;
}
cpumask_copy(saved_mask, &current->cpus_allowed);
if (unlikely(per_cpu(centrino_model, cpu) == NULL)) { if (unlikely(per_cpu(centrino_model, cpu) == NULL)) {
retval = -ENODEV; retval = -ENODEV;
...@@ -493,11 +491,9 @@ static int centrino_target (struct cpufreq_policy *policy, ...@@ -493,11 +491,9 @@ static int centrino_target (struct cpufreq_policy *policy,
goto out; goto out;
} }
*saved_mask = current->cpus_allowed;
first_cpu = 1; first_cpu = 1;
cpus_clear(*covered_cpus); for_each_cpu(j, policy->cpus) {
for_each_cpu_mask_nr(j, policy->cpus) { const struct cpumask *mask;
const cpumask_t *mask;
/* cpufreq holds the hotplug lock, so we are safe here */ /* cpufreq holds the hotplug lock, so we are safe here */
if (!cpu_online(j)) if (!cpu_online(j))
...@@ -508,9 +504,9 @@ static int centrino_target (struct cpufreq_policy *policy, ...@@ -508,9 +504,9 @@ static int centrino_target (struct cpufreq_policy *policy,
* Make sure we are running on CPU that wants to change freq * Make sure we are running on CPU that wants to change freq
*/ */
if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
mask = &policy->cpus; mask = policy->cpus;
else else
mask = &cpumask_of_cpu(j); mask = cpumask_of(j);
set_cpus_allowed_ptr(current, mask); set_cpus_allowed_ptr(current, mask);
preempt_disable(); preempt_disable();
...@@ -542,7 +538,7 @@ static int centrino_target (struct cpufreq_policy *policy, ...@@ -542,7 +538,7 @@ static int centrino_target (struct cpufreq_policy *policy,
dprintk("target=%dkHz old=%d new=%d msr=%04x\n", dprintk("target=%dkHz old=%d new=%d msr=%04x\n",
target_freq, freqs.old, freqs.new, msr); target_freq, freqs.old, freqs.new, msr);
for_each_cpu_mask_nr(k, policy->cpus) { for_each_cpu(k, policy->cpus) {
if (!cpu_online(k)) if (!cpu_online(k))
continue; continue;
freqs.cpu = k; freqs.cpu = k;
...@@ -567,7 +563,7 @@ static int centrino_target (struct cpufreq_policy *policy, ...@@ -567,7 +563,7 @@ static int centrino_target (struct cpufreq_policy *policy,
preempt_enable(); preempt_enable();
} }
for_each_cpu_mask_nr(k, policy->cpus) { for_each_cpu(k, policy->cpus) {
if (!cpu_online(k)) if (!cpu_online(k))
continue; continue;
freqs.cpu = k; freqs.cpu = k;
...@@ -590,7 +586,7 @@ static int centrino_target (struct cpufreq_policy *policy, ...@@ -590,7 +586,7 @@ static int centrino_target (struct cpufreq_policy *policy,
tmp = freqs.new; tmp = freqs.new;
freqs.new = freqs.old; freqs.new = freqs.old;
freqs.old = tmp; freqs.old = tmp;
for_each_cpu_mask_nr(j, policy->cpus) { for_each_cpu(j, policy->cpus) {
if (!cpu_online(j)) if (!cpu_online(j))
continue; continue;
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
...@@ -605,7 +601,8 @@ static int centrino_target (struct cpufreq_policy *policy, ...@@ -605,7 +601,8 @@ static int centrino_target (struct cpufreq_policy *policy,
preempt_enable(); preempt_enable();
set_cpus_allowed_ptr(current, saved_mask); set_cpus_allowed_ptr(current, saved_mask);
out: out:
CPUMASK_FREE(allmasks); free_cpumask_var(saved_mask);
free_cpumask_var(covered_cpus);
return retval; return retval;
} }
......
...@@ -229,7 +229,7 @@ static unsigned int speedstep_detect_chipset (void) ...@@ -229,7 +229,7 @@ static unsigned int speedstep_detect_chipset (void)
return 0; return 0;
} }
static unsigned int _speedstep_get(const cpumask_t *cpus) static unsigned int _speedstep_get(const struct cpumask *cpus)
{ {
unsigned int speed; unsigned int speed;
cpumask_t cpus_allowed; cpumask_t cpus_allowed;
...@@ -244,7 +244,7 @@ static unsigned int _speedstep_get(const cpumask_t *cpus) ...@@ -244,7 +244,7 @@ static unsigned int _speedstep_get(const cpumask_t *cpus)
static unsigned int speedstep_get(unsigned int cpu) static unsigned int speedstep_get(unsigned int cpu)
{ {
return _speedstep_get(&cpumask_of_cpu(cpu)); return _speedstep_get(cpumask_of(cpu));
} }
/** /**
...@@ -267,7 +267,7 @@ static int speedstep_target (struct cpufreq_policy *policy, ...@@ -267,7 +267,7 @@ static int speedstep_target (struct cpufreq_policy *policy,
if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate)) if (cpufreq_frequency_table_target(policy, &speedstep_freqs[0], target_freq, relation, &newstate))
return -EINVAL; return -EINVAL;
freqs.old = _speedstep_get(&policy->cpus); freqs.old = _speedstep_get(policy->cpus);
freqs.new = speedstep_freqs[newstate].frequency; freqs.new = speedstep_freqs[newstate].frequency;
freqs.cpu = policy->cpu; freqs.cpu = policy->cpu;
...@@ -279,20 +279,20 @@ static int speedstep_target (struct cpufreq_policy *policy, ...@@ -279,20 +279,20 @@ static int speedstep_target (struct cpufreq_policy *policy,
cpus_allowed = current->cpus_allowed; cpus_allowed = current->cpus_allowed;
for_each_cpu_mask_nr(i, policy->cpus) { for_each_cpu(i, policy->cpus) {
freqs.cpu = i; freqs.cpu = i;
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
} }
/* switch to physical CPU where state is to be changed */ /* switch to physical CPU where state is to be changed */
set_cpus_allowed_ptr(current, &policy->cpus); set_cpus_allowed_ptr(current, policy->cpus);
speedstep_set_state(newstate); speedstep_set_state(newstate);
/* allow to be run on all CPUs */ /* allow to be run on all CPUs */
set_cpus_allowed_ptr(current, &cpus_allowed); set_cpus_allowed_ptr(current, &cpus_allowed);
for_each_cpu_mask_nr(i, policy->cpus) { for_each_cpu(i, policy->cpus) {
freqs.cpu = i; freqs.cpu = i;
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
} }
...@@ -322,11 +322,11 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -322,11 +322,11 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
/* only run on CPU to be set, or on its sibling */ /* only run on CPU to be set, or on its sibling */
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
policy->cpus = per_cpu(cpu_sibling_map, policy->cpu); cpumask_copy(policy->cpus, &per_cpu(cpu_sibling_map, policy->cpu));
#endif #endif
cpus_allowed = current->cpus_allowed; cpus_allowed = current->cpus_allowed;
set_cpus_allowed_ptr(current, &policy->cpus); set_cpus_allowed_ptr(current, policy->cpus);
/* detect low and high frequency and transition latency */ /* detect low and high frequency and transition latency */
result = speedstep_get_freqs(speedstep_processor, result = speedstep_get_freqs(speedstep_processor,
...@@ -339,7 +339,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -339,7 +339,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
return result; return result;
/* get current speed setting */ /* get current speed setting */
speed = _speedstep_get(&policy->cpus); speed = _speedstep_get(policy->cpus);
if (!speed) if (!speed)
return -EIO; return -EIO;
......
...@@ -131,7 +131,27 @@ static void __init setup_cpu_pda_map(void) ...@@ -131,7 +131,27 @@ static void __init setup_cpu_pda_map(void)
/* point to new pointer table */ /* point to new pointer table */
_cpu_pda = new_cpu_pda; _cpu_pda = new_cpu_pda;
} }
#endif
#endif /* CONFIG_SMP && CONFIG_X86_64 */
#ifdef CONFIG_X86_64
/* correctly size the local cpu masks */
static void setup_cpu_local_masks(void)
{
alloc_bootmem_cpumask_var(&cpu_initialized_mask);
alloc_bootmem_cpumask_var(&cpu_callin_mask);
alloc_bootmem_cpumask_var(&cpu_callout_mask);
alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask);
}
#else /* CONFIG_X86_32 */
static inline void setup_cpu_local_masks(void)
{
}
#endif /* CONFIG_X86_32 */
/* /*
* Great future plan: * Great future plan:
...@@ -187,6 +207,9 @@ void __init setup_per_cpu_areas(void) ...@@ -187,6 +207,9 @@ void __init setup_per_cpu_areas(void)
/* Setup node to cpumask map */ /* Setup node to cpumask map */
setup_node_to_cpumask_map(); setup_node_to_cpumask_map();
/* Setup cpu initialized, callin, callout masks */
setup_cpu_local_masks();
} }
#endif #endif
......
...@@ -128,16 +128,23 @@ void native_send_call_func_single_ipi(int cpu) ...@@ -128,16 +128,23 @@ void native_send_call_func_single_ipi(int cpu)
void native_send_call_func_ipi(const struct cpumask *mask) void native_send_call_func_ipi(const struct cpumask *mask)
{ {
cpumask_t allbutself; cpumask_var_t allbutself;
allbutself = cpu_online_map; if (!alloc_cpumask_var(&allbutself, GFP_ATOMIC)) {
cpu_clear(smp_processor_id(), allbutself); send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
return;
}
if (cpus_equal(*mask, allbutself) && cpumask_copy(allbutself, cpu_online_mask);
cpus_equal(cpu_online_map, cpu_callout_map)) cpumask_clear_cpu(smp_processor_id(), allbutself);
if (cpumask_equal(mask, allbutself) &&
cpumask_equal(cpu_online_mask, cpu_callout_mask))
send_IPI_allbutself(CALL_FUNCTION_VECTOR); send_IPI_allbutself(CALL_FUNCTION_VECTOR);
else else
send_IPI_mask(mask, CALL_FUNCTION_VECTOR); send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
free_cpumask_var(allbutself);
} }
/* /*
......
...@@ -102,9 +102,6 @@ EXPORT_SYMBOL(smp_num_siblings); ...@@ -102,9 +102,6 @@ EXPORT_SYMBOL(smp_num_siblings);
/* Last level cache ID of each logical CPU */ /* Last level cache ID of each logical CPU */
DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID; DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID;
cpumask_t cpu_callin_map;
cpumask_t cpu_callout_map;
/* representing HT siblings of each logical CPU */ /* representing HT siblings of each logical CPU */
DEFINE_PER_CPU(cpumask_t, cpu_sibling_map); DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);
EXPORT_PER_CPU_SYMBOL(cpu_sibling_map); EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
...@@ -120,9 +117,6 @@ EXPORT_PER_CPU_SYMBOL(cpu_info); ...@@ -120,9 +117,6 @@ EXPORT_PER_CPU_SYMBOL(cpu_info);
static atomic_t init_deasserted; static atomic_t init_deasserted;
/* representing cpus for which sibling maps can be computed */
static cpumask_t cpu_sibling_setup_map;
/* Set if we find a B stepping CPU */ /* Set if we find a B stepping CPU */
static int __cpuinitdata smp_b_stepping; static int __cpuinitdata smp_b_stepping;
...@@ -140,7 +134,7 @@ EXPORT_SYMBOL(cpu_to_node_map); ...@@ -140,7 +134,7 @@ EXPORT_SYMBOL(cpu_to_node_map);
static void map_cpu_to_node(int cpu, int node) static void map_cpu_to_node(int cpu, int node)
{ {
printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node); printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node);
cpu_set(cpu, node_to_cpumask_map[node]); cpumask_set_cpu(cpu, &node_to_cpumask_map[node]);
cpu_to_node_map[cpu] = node; cpu_to_node_map[cpu] = node;
} }
...@@ -151,7 +145,7 @@ static void unmap_cpu_to_node(int cpu) ...@@ -151,7 +145,7 @@ static void unmap_cpu_to_node(int cpu)
printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu); printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu);
for (node = 0; node < MAX_NUMNODES; node++) for (node = 0; node < MAX_NUMNODES; node++)
cpu_clear(cpu, node_to_cpumask_map[node]); cpumask_clear_cpu(cpu, &node_to_cpumask_map[node]);
cpu_to_node_map[cpu] = 0; cpu_to_node_map[cpu] = 0;
} }
#else /* !(CONFIG_NUMA && CONFIG_X86_32) */ #else /* !(CONFIG_NUMA && CONFIG_X86_32) */
...@@ -209,7 +203,7 @@ static void __cpuinit smp_callin(void) ...@@ -209,7 +203,7 @@ static void __cpuinit smp_callin(void)
*/ */
phys_id = read_apic_id(); phys_id = read_apic_id();
cpuid = smp_processor_id(); cpuid = smp_processor_id();
if (cpu_isset(cpuid, cpu_callin_map)) { if (cpumask_test_cpu(cpuid, cpu_callin_mask)) {
panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__, panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__,
phys_id, cpuid); phys_id, cpuid);
} }
...@@ -231,7 +225,7 @@ static void __cpuinit smp_callin(void) ...@@ -231,7 +225,7 @@ static void __cpuinit smp_callin(void)
/* /*
* Has the boot CPU finished it's STARTUP sequence? * Has the boot CPU finished it's STARTUP sequence?
*/ */
if (cpu_isset(cpuid, cpu_callout_map)) if (cpumask_test_cpu(cpuid, cpu_callout_mask))
break; break;
cpu_relax(); cpu_relax();
} }
...@@ -274,7 +268,7 @@ static void __cpuinit smp_callin(void) ...@@ -274,7 +268,7 @@ static void __cpuinit smp_callin(void)
/* /*
* Allow the master to continue. * Allow the master to continue.
*/ */
cpu_set(cpuid, cpu_callin_map); cpumask_set_cpu(cpuid, cpu_callin_mask);
} }
static int __cpuinitdata unsafe_smp; static int __cpuinitdata unsafe_smp;
...@@ -332,7 +326,7 @@ notrace static void __cpuinit start_secondary(void *unused) ...@@ -332,7 +326,7 @@ notrace static void __cpuinit start_secondary(void *unused)
ipi_call_lock(); ipi_call_lock();
lock_vector_lock(); lock_vector_lock();
__setup_vector_irq(smp_processor_id()); __setup_vector_irq(smp_processor_id());
cpu_set(smp_processor_id(), cpu_online_map); set_cpu_online(smp_processor_id(), true);
unlock_vector_lock(); unlock_vector_lock();
ipi_call_unlock(); ipi_call_unlock();
per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
...@@ -438,50 +432,52 @@ void __cpuinit set_cpu_sibling_map(int cpu) ...@@ -438,50 +432,52 @@ void __cpuinit set_cpu_sibling_map(int cpu)
int i; int i;
struct cpuinfo_x86 *c = &cpu_data(cpu); struct cpuinfo_x86 *c = &cpu_data(cpu);
cpu_set(cpu, cpu_sibling_setup_map); cpumask_set_cpu(cpu, cpu_sibling_setup_mask);
if (smp_num_siblings > 1) { if (smp_num_siblings > 1) {
for_each_cpu_mask_nr(i, cpu_sibling_setup_map) { for_each_cpu(i, cpu_sibling_setup_mask) {
if (c->phys_proc_id == cpu_data(i).phys_proc_id && struct cpuinfo_x86 *o = &cpu_data(i);
c->cpu_core_id == cpu_data(i).cpu_core_id) {
cpu_set(i, per_cpu(cpu_sibling_map, cpu)); if (c->phys_proc_id == o->phys_proc_id &&
cpu_set(cpu, per_cpu(cpu_sibling_map, i)); c->cpu_core_id == o->cpu_core_id) {
cpu_set(i, per_cpu(cpu_core_map, cpu)); cpumask_set_cpu(i, cpu_sibling_mask(cpu));
cpu_set(cpu, per_cpu(cpu_core_map, i)); cpumask_set_cpu(cpu, cpu_sibling_mask(i));
cpu_set(i, c->llc_shared_map); cpumask_set_cpu(i, cpu_core_mask(cpu));
cpu_set(cpu, cpu_data(i).llc_shared_map); cpumask_set_cpu(cpu, cpu_core_mask(i));
cpumask_set_cpu(i, &c->llc_shared_map);
cpumask_set_cpu(cpu, &o->llc_shared_map);
} }
} }
} else { } else {
cpu_set(cpu, per_cpu(cpu_sibling_map, cpu)); cpumask_set_cpu(cpu, cpu_sibling_mask(cpu));
} }
cpu_set(cpu, c->llc_shared_map); cpumask_set_cpu(cpu, &c->llc_shared_map);
if (current_cpu_data.x86_max_cores == 1) { if (current_cpu_data.x86_max_cores == 1) {
per_cpu(cpu_core_map, cpu) = per_cpu(cpu_sibling_map, cpu); cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu));
c->booted_cores = 1; c->booted_cores = 1;
return; return;
} }
for_each_cpu_mask_nr(i, cpu_sibling_setup_map) { for_each_cpu(i, cpu_sibling_setup_mask) {
if (per_cpu(cpu_llc_id, cpu) != BAD_APICID && if (per_cpu(cpu_llc_id, cpu) != BAD_APICID &&
per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) { per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) {
cpu_set(i, c->llc_shared_map); cpumask_set_cpu(i, &c->llc_shared_map);
cpu_set(cpu, cpu_data(i).llc_shared_map); cpumask_set_cpu(cpu, &cpu_data(i).llc_shared_map);
} }
if (c->phys_proc_id == cpu_data(i).phys_proc_id) { if (c->phys_proc_id == cpu_data(i).phys_proc_id) {
cpu_set(i, per_cpu(cpu_core_map, cpu)); cpumask_set_cpu(i, cpu_core_mask(cpu));
cpu_set(cpu, per_cpu(cpu_core_map, i)); cpumask_set_cpu(cpu, cpu_core_mask(i));
/* /*
* Does this new cpu bringup a new core? * Does this new cpu bringup a new core?
*/ */
if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1) { if (cpumask_weight(cpu_sibling_mask(cpu)) == 1) {
/* /*
* for each core in package, increment * for each core in package, increment
* the booted_cores for this new cpu * the booted_cores for this new cpu
*/ */
if (first_cpu(per_cpu(cpu_sibling_map, i)) == i) if (cpumask_first(cpu_sibling_mask(i)) == i)
c->booted_cores++; c->booted_cores++;
/* /*
* increment the core count for all * increment the core count for all
...@@ -504,7 +500,7 @@ const struct cpumask *cpu_coregroup_mask(int cpu) ...@@ -504,7 +500,7 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
* And for power savings, we return cpu_core_map * And for power savings, we return cpu_core_map
*/ */
if (sched_mc_power_savings || sched_smt_power_savings) if (sched_mc_power_savings || sched_smt_power_savings)
return &per_cpu(cpu_core_map, cpu); return cpu_core_mask(cpu);
else else
return &c->llc_shared_map; return &c->llc_shared_map;
} }
...@@ -523,7 +519,7 @@ static void impress_friends(void) ...@@ -523,7 +519,7 @@ static void impress_friends(void)
*/ */
pr_debug("Before bogomips.\n"); pr_debug("Before bogomips.\n");
for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
if (cpu_isset(cpu, cpu_callout_map)) if (cpumask_test_cpu(cpu, cpu_callout_mask))
bogosum += cpu_data(cpu).loops_per_jiffy; bogosum += cpu_data(cpu).loops_per_jiffy;
printk(KERN_INFO printk(KERN_INFO
"Total of %d processors activated (%lu.%02lu BogoMIPS).\n", "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
...@@ -904,19 +900,19 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu) ...@@ -904,19 +900,19 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
* allow APs to start initializing. * allow APs to start initializing.
*/ */
pr_debug("Before Callout %d.\n", cpu); pr_debug("Before Callout %d.\n", cpu);
cpu_set(cpu, cpu_callout_map); cpumask_set_cpu(cpu, cpu_callout_mask);
pr_debug("After Callout %d.\n", cpu); pr_debug("After Callout %d.\n", cpu);
/* /*
* Wait 5s total for a response * Wait 5s total for a response
*/ */
for (timeout = 0; timeout < 50000; timeout++) { for (timeout = 0; timeout < 50000; timeout++) {
if (cpu_isset(cpu, cpu_callin_map)) if (cpumask_test_cpu(cpu, cpu_callin_mask))
break; /* It has booted */ break; /* It has booted */
udelay(100); udelay(100);
} }
if (cpu_isset(cpu, cpu_callin_map)) { if (cpumask_test_cpu(cpu, cpu_callin_mask)) {
/* number CPUs logically, starting from 1 (BSP is 0) */ /* number CPUs logically, starting from 1 (BSP is 0) */
pr_debug("OK.\n"); pr_debug("OK.\n");
printk(KERN_INFO "CPU%d: ", cpu); printk(KERN_INFO "CPU%d: ", cpu);
...@@ -941,9 +937,14 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu) ...@@ -941,9 +937,14 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
if (boot_error) { if (boot_error) {
/* Try to put things back the way they were before ... */ /* Try to put things back the way they were before ... */
numa_remove_cpu(cpu); /* was set by numa_add_cpu */ numa_remove_cpu(cpu); /* was set by numa_add_cpu */
cpu_clear(cpu, cpu_callout_map); /* was set by do_boot_cpu() */
cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */ /* was set by do_boot_cpu() */
cpu_clear(cpu, cpu_present_map); cpumask_clear_cpu(cpu, cpu_callout_mask);
/* was set by cpu_init() */
cpumask_clear_cpu(cpu, cpu_initialized_mask);
set_cpu_present(cpu, false);
per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID; per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID;
} }
...@@ -977,7 +978,7 @@ int __cpuinit native_cpu_up(unsigned int cpu) ...@@ -977,7 +978,7 @@ int __cpuinit native_cpu_up(unsigned int cpu)
/* /*
* Already booted CPU? * Already booted CPU?
*/ */
if (cpu_isset(cpu, cpu_callin_map)) { if (cpumask_test_cpu(cpu, cpu_callin_mask)) {
pr_debug("do_boot_cpu %d Already started\n", cpu); pr_debug("do_boot_cpu %d Already started\n", cpu);
return -ENOSYS; return -ENOSYS;
} }
...@@ -1032,8 +1033,9 @@ int __cpuinit native_cpu_up(unsigned int cpu) ...@@ -1032,8 +1033,9 @@ int __cpuinit native_cpu_up(unsigned int cpu)
*/ */
static __init void disable_smp(void) static __init void disable_smp(void)
{ {
cpu_present_map = cpumask_of_cpu(0); /* use the read/write pointers to the present and possible maps */
cpu_possible_map = cpumask_of_cpu(0); cpumask_copy(&cpu_present_map, cpumask_of(0));
cpumask_copy(&cpu_possible_map, cpumask_of(0));
smpboot_clear_io_apic_irqs(); smpboot_clear_io_apic_irqs();
if (smp_found_config) if (smp_found_config)
...@@ -1041,8 +1043,8 @@ static __init void disable_smp(void) ...@@ -1041,8 +1043,8 @@ static __init void disable_smp(void)
else else
physid_set_mask_of_physid(0, &phys_cpu_present_map); physid_set_mask_of_physid(0, &phys_cpu_present_map);
map_cpu_to_logical_apicid(); map_cpu_to_logical_apicid();
cpu_set(0, per_cpu(cpu_sibling_map, 0)); cpumask_set_cpu(0, cpu_sibling_mask(0));
cpu_set(0, per_cpu(cpu_core_map, 0)); cpumask_set_cpu(0, cpu_core_mask(0));
} }
/* /*
...@@ -1064,14 +1066,14 @@ static int __init smp_sanity_check(unsigned max_cpus) ...@@ -1064,14 +1066,14 @@ static int __init smp_sanity_check(unsigned max_cpus)
nr = 0; nr = 0;
for_each_present_cpu(cpu) { for_each_present_cpu(cpu) {
if (nr >= 8) if (nr >= 8)
cpu_clear(cpu, cpu_present_map); set_cpu_present(cpu, false);
nr++; nr++;
} }
nr = 0; nr = 0;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
if (nr >= 8) if (nr >= 8)
cpu_clear(cpu, cpu_possible_map); set_cpu_possible(cpu, false);
nr++; nr++;
} }
...@@ -1167,7 +1169,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) ...@@ -1167,7 +1169,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
preempt_disable(); preempt_disable();
smp_cpu_index_default(); smp_cpu_index_default();
current_cpu_data = boot_cpu_data; current_cpu_data = boot_cpu_data;
cpu_callin_map = cpumask_of_cpu(0); cpumask_copy(cpu_callin_mask, cpumask_of(0));
mb(); mb();
/* /*
* Setup boot CPU information * Setup boot CPU information
...@@ -1242,8 +1244,8 @@ void __init native_smp_prepare_boot_cpu(void) ...@@ -1242,8 +1244,8 @@ void __init native_smp_prepare_boot_cpu(void)
init_gdt(me); init_gdt(me);
#endif #endif
switch_to_new_gdt(); switch_to_new_gdt();
/* already set me in cpu_online_map in boot_cpu_init() */ /* already set me in cpu_online_mask in boot_cpu_init() */
cpu_set(me, cpu_callout_map); cpumask_set_cpu(me, cpu_callout_mask);
per_cpu(cpu_state, me) = CPU_ONLINE; per_cpu(cpu_state, me) = CPU_ONLINE;
} }
...@@ -1311,7 +1313,7 @@ __init void prefill_possible_map(void) ...@@ -1311,7 +1313,7 @@ __init void prefill_possible_map(void)
possible, max_t(int, possible - num_processors, 0)); possible, max_t(int, possible - num_processors, 0));
for (i = 0; i < possible; i++) for (i = 0; i < possible; i++)
cpu_set(i, cpu_possible_map); set_cpu_possible(i, true);
nr_cpu_ids = possible; nr_cpu_ids = possible;
} }
...@@ -1323,31 +1325,31 @@ static void remove_siblinginfo(int cpu) ...@@ -1323,31 +1325,31 @@ static void remove_siblinginfo(int cpu)
int sibling; int sibling;
struct cpuinfo_x86 *c = &cpu_data(cpu); struct cpuinfo_x86 *c = &cpu_data(cpu);
for_each_cpu_mask_nr(sibling, per_cpu(cpu_core_map, cpu)) { for_each_cpu(sibling, cpu_core_mask(cpu)) {
cpu_clear(cpu, per_cpu(cpu_core_map, sibling)); cpumask_clear_cpu(cpu, cpu_core_mask(sibling));
/*/ /*/
* last thread sibling in this cpu core going down * last thread sibling in this cpu core going down
*/ */
if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1) if (cpumask_weight(cpu_sibling_mask(cpu)) == 1)
cpu_data(sibling).booted_cores--; cpu_data(sibling).booted_cores--;
} }
for_each_cpu_mask_nr(sibling, per_cpu(cpu_sibling_map, cpu)) for_each_cpu(sibling, cpu_sibling_mask(cpu))
cpu_clear(cpu, per_cpu(cpu_sibling_map, sibling)); cpumask_clear_cpu(cpu, cpu_sibling_mask(sibling));
cpus_clear(per_cpu(cpu_sibling_map, cpu)); cpumask_clear(cpu_sibling_mask(cpu));
cpus_clear(per_cpu(cpu_core_map, cpu)); cpumask_clear(cpu_core_mask(cpu));
c->phys_proc_id = 0; c->phys_proc_id = 0;
c->cpu_core_id = 0; c->cpu_core_id = 0;
cpu_clear(cpu, cpu_sibling_setup_map); cpumask_clear_cpu(cpu, cpu_sibling_setup_mask);
} }
static void __ref remove_cpu_from_maps(int cpu) static void __ref remove_cpu_from_maps(int cpu)
{ {
cpu_clear(cpu, cpu_online_map); set_cpu_online(cpu, false);
cpu_clear(cpu, cpu_callout_map); cpumask_clear_cpu(cpu, cpu_callout_mask);
cpu_clear(cpu, cpu_callin_map); cpumask_clear_cpu(cpu, cpu_callin_mask);
/* was set by cpu_init() */ /* was set by cpu_init() */
cpu_clear(cpu, cpu_initialized); cpumask_clear_cpu(cpu, cpu_initialized_mask);
numa_remove_cpu(cpu); numa_remove_cpu(cpu);
} }
......
...@@ -584,12 +584,12 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, ...@@ -584,12 +584,12 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
return i; return i;
} }
static ssize_t show_cpus(cpumask_t mask, char *buf) static ssize_t show_cpus(const struct cpumask *mask, char *buf)
{ {
ssize_t i = 0; ssize_t i = 0;
unsigned int cpu; unsigned int cpu;
for_each_cpu_mask_nr(cpu, mask) { for_each_cpu(cpu, mask) {
if (i) if (i)
i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " "); i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " ");
i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u", cpu); 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,7 +606,7 @@ static ssize_t show_cpus(cpumask_t mask, char *buf)
*/ */
static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
{ {
if (cpus_empty(policy->related_cpus)) if (cpumask_empty(policy->related_cpus))
return show_cpus(policy->cpus, buf); return show_cpus(policy->cpus, buf);
return show_cpus(policy->related_cpus, buf); return show_cpus(policy->related_cpus, buf);
} }
...@@ -806,9 +806,20 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) ...@@ -806,9 +806,20 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
ret = -ENOMEM; ret = -ENOMEM;
goto nomem_out; goto nomem_out;
} }
if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) {
kfree(policy);
ret = -ENOMEM;
goto nomem_out;
}
if (!alloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) {
free_cpumask_var(policy->cpus);
kfree(policy);
ret = -ENOMEM;
goto nomem_out;
}
policy->cpu = cpu; policy->cpu = cpu;
policy->cpus = cpumask_of_cpu(cpu); cpumask_copy(policy->cpus, cpumask_of(cpu));
/* Initially set CPU itself as the policy_cpu */ /* Initially set CPU itself as the policy_cpu */
per_cpu(policy_cpu, cpu) = cpu; per_cpu(policy_cpu, cpu) = cpu;
...@@ -843,7 +854,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) ...@@ -843,7 +854,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
} }
#endif #endif
for_each_cpu_mask_nr(j, policy->cpus) { for_each_cpu(j, policy->cpus) {
if (cpu == j) if (cpu == j)
continue; continue;
...@@ -861,7 +872,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) ...@@ -861,7 +872,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
goto err_out_driver_exit; goto err_out_driver_exit;
spin_lock_irqsave(&cpufreq_driver_lock, flags); spin_lock_irqsave(&cpufreq_driver_lock, flags);
managed_policy->cpus = policy->cpus; cpumask_copy(managed_policy->cpus, policy->cpus);
per_cpu(cpufreq_cpu_data, cpu) = managed_policy; per_cpu(cpufreq_cpu_data, cpu) = managed_policy;
spin_unlock_irqrestore(&cpufreq_driver_lock, flags); spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
...@@ -916,14 +927,14 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) ...@@ -916,14 +927,14 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
} }
spin_lock_irqsave(&cpufreq_driver_lock, flags); spin_lock_irqsave(&cpufreq_driver_lock, flags);
for_each_cpu_mask_nr(j, policy->cpus) { for_each_cpu(j, policy->cpus) {
per_cpu(cpufreq_cpu_data, j) = policy; per_cpu(cpufreq_cpu_data, j) = policy;
per_cpu(policy_cpu, j) = policy->cpu; per_cpu(policy_cpu, j) = policy->cpu;
} }
spin_unlock_irqrestore(&cpufreq_driver_lock, flags); spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
/* symlink affected CPUs */ /* symlink affected CPUs */
for_each_cpu_mask_nr(j, policy->cpus) { for_each_cpu(j, policy->cpus) {
if (j == cpu) if (j == cpu)
continue; continue;
if (!cpu_online(j)) if (!cpu_online(j))
...@@ -963,7 +974,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) ...@@ -963,7 +974,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
err_out_unregister: err_out_unregister:
spin_lock_irqsave(&cpufreq_driver_lock, flags); spin_lock_irqsave(&cpufreq_driver_lock, flags);
for_each_cpu_mask_nr(j, policy->cpus) for_each_cpu(j, policy->cpus)
per_cpu(cpufreq_cpu_data, j) = NULL; per_cpu(cpufreq_cpu_data, j) = NULL;
spin_unlock_irqrestore(&cpufreq_driver_lock, flags); spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
...@@ -1024,7 +1035,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) ...@@ -1024,7 +1035,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
*/ */
if (unlikely(cpu != data->cpu)) { if (unlikely(cpu != data->cpu)) {
dprintk("removing link\n"); dprintk("removing link\n");
cpu_clear(cpu, data->cpus); cpumask_clear_cpu(cpu, data->cpus);
spin_unlock_irqrestore(&cpufreq_driver_lock, flags); spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
sysfs_remove_link(&sys_dev->kobj, "cpufreq"); sysfs_remove_link(&sys_dev->kobj, "cpufreq");
cpufreq_cpu_put(data); cpufreq_cpu_put(data);
...@@ -1045,8 +1056,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) ...@@ -1045,8 +1056,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
* per_cpu(cpufreq_cpu_data) while holding the lock, and remove * per_cpu(cpufreq_cpu_data) while holding the lock, and remove
* the sysfs links afterwards. * the sysfs links afterwards.
*/ */
if (unlikely(cpus_weight(data->cpus) > 1)) { if (unlikely(cpumask_weight(data->cpus) > 1)) {
for_each_cpu_mask_nr(j, data->cpus) { for_each_cpu(j, data->cpus) {
if (j == cpu) if (j == cpu)
continue; continue;
per_cpu(cpufreq_cpu_data, j) = NULL; per_cpu(cpufreq_cpu_data, j) = NULL;
...@@ -1055,8 +1066,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) ...@@ -1055,8 +1066,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
spin_unlock_irqrestore(&cpufreq_driver_lock, flags); spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
if (unlikely(cpus_weight(data->cpus) > 1)) { if (unlikely(cpumask_weight(data->cpus) > 1)) {
for_each_cpu_mask_nr(j, data->cpus) { for_each_cpu(j, data->cpus) {
if (j == cpu) if (j == cpu)
continue; continue;
dprintk("removing link for cpu %u\n", j); dprintk("removing link for cpu %u\n", j);
...@@ -1090,7 +1101,10 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) ...@@ -1090,7 +1101,10 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
if (cpufreq_driver->exit) if (cpufreq_driver->exit)
cpufreq_driver->exit(data); cpufreq_driver->exit(data);
free_cpumask_var(data->related_cpus);
free_cpumask_var(data->cpus);
kfree(data); kfree(data);
per_cpu(cpufreq_cpu_data, cpu) = NULL;
cpufreq_debug_enable_ratelimit(); cpufreq_debug_enable_ratelimit();
return 0; return 0;
......
...@@ -498,7 +498,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -498,7 +498,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
return rc; return rc;
} }
for_each_cpu_mask_nr(j, policy->cpus) { for_each_cpu(j, policy->cpus) {
struct cpu_dbs_info_s *j_dbs_info; struct cpu_dbs_info_s *j_dbs_info;
j_dbs_info = &per_cpu(cpu_dbs_info, j); j_dbs_info = &per_cpu(cpu_dbs_info, j);
j_dbs_info->cur_policy = policy; j_dbs_info->cur_policy = policy;
......
...@@ -400,7 +400,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) ...@@ -400,7 +400,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
/* Get Absolute Load - in terms of freq */ /* Get Absolute Load - in terms of freq */
max_load_freq = 0; max_load_freq = 0;
for_each_cpu_mask_nr(j, policy->cpus) { for_each_cpu(j, policy->cpus) {
struct cpu_dbs_info_s *j_dbs_info; struct cpu_dbs_info_s *j_dbs_info;
cputime64_t cur_wall_time, cur_idle_time; cputime64_t cur_wall_time, cur_idle_time;
unsigned int idle_time, wall_time; unsigned int idle_time, wall_time;
...@@ -568,7 +568,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -568,7 +568,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
return rc; return rc;
} }
for_each_cpu_mask_nr(j, policy->cpus) { for_each_cpu(j, policy->cpus) {
struct cpu_dbs_info_s *j_dbs_info; struct cpu_dbs_info_s *j_dbs_info;
j_dbs_info = &per_cpu(cpu_dbs_info, j); j_dbs_info = &per_cpu(cpu_dbs_info, j);
j_dbs_info->cur_policy = policy; j_dbs_info->cur_policy = policy;
......
...@@ -71,11 +71,11 @@ static ssize_t broken_parity_status_store(struct device *dev, ...@@ -71,11 +71,11 @@ static ssize_t broken_parity_status_store(struct device *dev,
static ssize_t local_cpus_show(struct device *dev, static ssize_t local_cpus_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
cpumask_t mask; const struct cpumask *mask;
int len; int len;
mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); mask = cpumask_of_pcibus(to_pci_dev(dev)->bus);
len = cpumask_scnprintf(buf, PAGE_SIZE-2, &mask); len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
buf[len++] = '\n'; buf[len++] = '\n';
buf[len] = '\0'; buf[len] = '\0';
return len; return len;
...@@ -85,11 +85,11 @@ static ssize_t local_cpus_show(struct device *dev, ...@@ -85,11 +85,11 @@ static ssize_t local_cpus_show(struct device *dev,
static ssize_t local_cpulist_show(struct device *dev, static ssize_t local_cpulist_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
cpumask_t mask; const struct cpumask *mask;
int len; int len;
mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); mask = cpumask_of_pcibus(to_pci_dev(dev)->bus);
len = cpulist_scnprintf(buf, PAGE_SIZE-2, &mask); len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask);
buf[len++] = '\n'; buf[len++] = '\n';
buf[len] = '\0'; buf[len] = '\0';
return len; return len;
......
...@@ -51,12 +51,12 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev, ...@@ -51,12 +51,12 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
char *buf) char *buf)
{ {
int ret; int ret;
cpumask_t cpumask; const struct cpumask *cpumask;
cpumask = pcibus_to_cpumask(to_pci_bus(dev)); cpumask = cpumask_of_pcibus(to_pci_bus(dev));
ret = type? ret = type?
cpulist_scnprintf(buf, PAGE_SIZE-2, &cpumask) : cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask) :
cpumask_scnprintf(buf, PAGE_SIZE-2, &cpumask); cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask);
buf[ret++] = '\n'; buf[ret++] = '\n';
buf[ret] = '\0'; buf[ret] = '\0';
return ret; return ret;
......
...@@ -80,8 +80,8 @@ struct cpufreq_real_policy { ...@@ -80,8 +80,8 @@ struct cpufreq_real_policy {
}; };
struct cpufreq_policy { struct cpufreq_policy {
cpumask_t cpus; /* CPUs requiring sw coordination */ cpumask_var_t cpus; /* CPUs requiring sw coordination */
cpumask_t related_cpus; /* CPUs with any coordination */ cpumask_var_t related_cpus; /* CPUs with any coordination */
unsigned int shared_type; /* ANY or ALL affected CPUs unsigned int shared_type; /* ANY or ALL affected CPUs
should set cpufreq */ should set cpufreq */
unsigned int cpu; /* cpu nr of registered CPU */ unsigned int cpu; /* cpu nr of registered CPU */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册