Skip to content

Commit

Permalink
x86/apic: Use non-atomic operations when possible
Browse files Browse the repository at this point in the history
Using __clear_bit() and __cpumask_clear_cpu() is more efficient than using
their atomic counterparts.

Use them when atomicity is not needed, such as when manipulating bitmasks
that are on the stack.

Signed-off-by: Nadav Amit <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
anadav authored and KAGA-KOKO committed Jun 23, 2019
1 parent 748b170 commit dde3626
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions arch/x86/kernel/apic/apic_flat_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)
int cpu = smp_processor_id();

if (cpu < BITS_PER_LONG)
clear_bit(cpu, &mask);
__clear_bit(cpu, &mask);

_flat_send_IPI_mask(mask, vector);
}
Expand All @@ -92,7 +92,7 @@ static void flat_send_IPI_allbutself(int vector)
unsigned long mask = cpumask_bits(cpu_online_mask)[0];

if (cpu < BITS_PER_LONG)
clear_bit(cpu, &mask);
__clear_bit(cpu, &mask);

_flat_send_IPI_mask(mask, vector);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/apic/x2apic_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ __x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
cpumask_copy(tmpmsk, mask);
/* If IPI should not be sent to self, clear current CPU */
if (apic_dest != APIC_DEST_ALLINC)
cpumask_clear_cpu(smp_processor_id(), tmpmsk);
__cpumask_clear_cpu(smp_processor_id(), tmpmsk);

/* Collapse cpus in a cluster so a single IPI per cluster is sent */
for_each_cpu(cpu, tmpmsk) {
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void native_send_call_func_ipi(const struct cpumask *mask)
}

cpumask_copy(allbutself, cpu_online_mask);
cpumask_clear_cpu(smp_processor_id(), allbutself);
__cpumask_clear_cpu(smp_processor_id(), allbutself);

if (cpumask_equal(mask, allbutself) &&
cpumask_equal(cpu_online_mask, cpu_callout_mask))
Expand Down

0 comments on commit dde3626

Please sign in to comment.