x86 smp: modify send_IPI_mask interface to accept cpumask_t pointers
Impact: cleanup, change parameter passing * Change genapic interfaces to accept cpumask_t pointers where possible. * Modify external callers to use cpumask_t pointers in function calls. * Create new send_IPI_mask_allbutself which is the same as the send_IPI_mask functions but removes smp_processor_id() from list. This removes another common need for a temporary cpumask_t variable. * Functions that used a temp cpumask_t variable for: cpumask_t allbutme = cpu_online_map; cpu_clear(smp_processor_id(), allbutme); if (!cpus_empty(allbutme)) ... become: if (!cpus_equal(cpu_online_map, cpumask_of_cpu(cpu))) ... * Other minor code optimizations (like using cpus_clear instead of CPU_MASK_NONE, etc.) Applies to linux-2.6.tip/master. Signed-off-by: Mike Travis <travis@sgi.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
@@ -22,19 +22,18 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
|
||||
|
||||
/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */
|
||||
|
||||
static cpumask_t x2apic_target_cpus(void)
|
||||
static const cpumask_t *x2apic_target_cpus(void)
|
||||
{
|
||||
return cpumask_of_cpu(0);
|
||||
return &cpumask_of_cpu(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* for now each logical cpu is in its own vector allocation domain.
|
||||
*/
|
||||
static cpumask_t x2apic_vector_allocation_domain(int cpu)
|
||||
static void x2apic_vector_allocation_domain(int cpu, cpumask_t *retmask)
|
||||
{
|
||||
cpumask_t domain = CPU_MASK_NONE;
|
||||
cpu_set(cpu, domain);
|
||||
return domain;
|
||||
cpus_clear(*retmask);
|
||||
cpu_set(cpu, *retmask);
|
||||
}
|
||||
|
||||
static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
|
||||
@@ -56,32 +55,52 @@ static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
|
||||
* at once. We have 16 cpu's in a cluster. This will minimize IPI register
|
||||
* writes.
|
||||
*/
|
||||
static void x2apic_send_IPI_mask(cpumask_t mask, int vector)
|
||||
static void x2apic_send_IPI_mask(const cpumask_t *mask, int vector)
|
||||
{
|
||||
unsigned long flags;
|
||||
unsigned long query_cpu;
|
||||
|
||||
local_irq_save(flags);
|
||||
for_each_cpu_mask(query_cpu, mask) {
|
||||
__x2apic_send_IPI_dest(per_cpu(x86_cpu_to_logical_apicid, query_cpu),
|
||||
vector, APIC_DEST_LOGICAL);
|
||||
}
|
||||
for_each_cpu_mask_nr(query_cpu, *mask)
|
||||
__x2apic_send_IPI_dest(
|
||||
per_cpu(x86_cpu_to_logical_apicid, query_cpu),
|
||||
vector, APIC_DEST_LOGICAL);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_mask_allbutself(const cpumask_t *mask, int vector)
|
||||
{
|
||||
unsigned long flags;
|
||||
unsigned long query_cpu;
|
||||
unsigned long this_cpu = smp_processor_id();
|
||||
|
||||
local_irq_save(flags);
|
||||
for_each_cpu_mask_nr(query_cpu, *mask)
|
||||
if (query_cpu != this_cpu)
|
||||
__x2apic_send_IPI_dest(
|
||||
per_cpu(x86_cpu_to_logical_apicid, query_cpu),
|
||||
vector, APIC_DEST_LOGICAL);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_allbutself(int vector)
|
||||
{
|
||||
cpumask_t mask = cpu_online_map;
|
||||
unsigned long flags;
|
||||
unsigned long query_cpu;
|
||||
unsigned long this_cpu = smp_processor_id();
|
||||
|
||||
cpu_clear(smp_processor_id(), mask);
|
||||
|
||||
if (!cpus_empty(mask))
|
||||
x2apic_send_IPI_mask(mask, vector);
|
||||
local_irq_save(flags);
|
||||
for_each_online_cpu(query_cpu)
|
||||
if (query_cpu != this_cpu)
|
||||
__x2apic_send_IPI_dest(
|
||||
per_cpu(x86_cpu_to_logical_apicid, query_cpu),
|
||||
vector, APIC_DEST_LOGICAL);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static void x2apic_send_IPI_all(int vector)
|
||||
{
|
||||
x2apic_send_IPI_mask(cpu_online_map, vector);
|
||||
x2apic_send_IPI_mask(&cpu_online_map, vector);
|
||||
}
|
||||
|
||||
static int x2apic_apic_id_registered(void)
|
||||
@@ -89,7 +108,7 @@ static int x2apic_apic_id_registered(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
|
||||
static unsigned int x2apic_cpu_mask_to_apicid(const cpumask_t *cpumask)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
@@ -97,8 +116,8 @@ static unsigned int x2apic_cpu_mask_to_apicid(cpumask_t cpumask)
|
||||
* We're using fixed IRQ delivery, can only return one phys APIC ID.
|
||||
* May as well be the first.
|
||||
*/
|
||||
cpu = first_cpu(cpumask);
|
||||
if ((unsigned)cpu < NR_CPUS)
|
||||
cpu = first_cpu(*cpumask);
|
||||
if ((unsigned)cpu < nr_cpu_ids)
|
||||
return per_cpu(x86_cpu_to_logical_apicid, cpu);
|
||||
else
|
||||
return BAD_APICID;
|
||||
@@ -150,6 +169,7 @@ struct genapic apic_x2apic_cluster = {
|
||||
.send_IPI_all = x2apic_send_IPI_all,
|
||||
.send_IPI_allbutself = x2apic_send_IPI_allbutself,
|
||||
.send_IPI_mask = x2apic_send_IPI_mask,
|
||||
.send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
|
||||
.send_IPI_self = x2apic_send_IPI_self,
|
||||
.cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
|
||||
.phys_pkg_id = phys_pkg_id,
|
||||
|
Reference in New Issue
Block a user