]> www.infradead.org Git - users/dwmw2/linux.git/commit
x86/apic/x2apic: Fix parallel handling of cluster_mask
authorDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 21 Jan 2021 19:50:50 +0000 (19:50 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 28 Jan 2021 10:12:27 +0000 (10:12 +0000)
commit7b6250dbb2ac9c995157aab76b219b3f3b23ee27
tree4c67156fde06a6c36ecead9ee23285e3b489aeea
parent6ee1d745b7c9fd573fba142a2efdad76a9f1cb04
x86/apic/x2apic: Fix parallel handling of cluster_mask

For each CPU being brought up, the alloc_clustermask() function
allocates a new struct cluster_mask just in case it's needed. Then the
target CPU actually runs, and in init_x2apic_ldr() it either uses a
cluster_mask from a previous CPU in the same cluster, or consumes the
"spare" one and sets the global pointer to NULL.

That isn't going to parallelise stunningly well.

Ditch the global variable, let alloc_clustermask() install the struct
*directly* in the per_cpu data for the CPU being brought up. As an
optimisation, actually make it do so for *all* present CPUs in the same
cluster, which means only one iteration over for_each_present_cpu()
instead of doing so repeatedly, once for each CPU.

This was a harmless "bug" while CPU bringup wasn't actually happening in
parallel. It's about to become less harmless...

Fixes: 023a611748fd5 ("x86/apic/x2apic: Simplify cluster management")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
arch/x86/kernel/apic/x2apic_cluster.c