Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 71fff5e6 authored by Mike Travis's avatar Mike Travis Committed by Thomas Gleixner
Browse files

x86: convert cpu_to_apicid to be a per cpu variable



This patch converts the x86_cpu_to_apicid array to be a per cpu
variable. This saves sizeof(apicid) * NR unused cpus.  Access is mostly
from startup and CPU HOTPLUG functions.

MP_processor_info() is one of the functions that require access to the
x86_cpu_to_apicid array before the per_cpu data area is setup.  For this
case, a pointer to the __initdata array is initialized in setup_arch()
and removed in smp_prepare_cpus() after the per_cpu data area is
initialized.

A second change is included to change the initial array value of ARCH
i386 from 0xff to BAD_APICID to be consistent with ARCH x86_64.

Signed-off-by: default avatarMike Travis <travis@sgi.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent dbeb2be2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -555,7 +555,7 @@ EXPORT_SYMBOL(acpi_map_lsapic);

int acpi_unmap_lsapic(int cpu)
{
	x86_cpu_to_apicid[cpu] = -1;
	per_cpu(x86_cpu_to_apicid, cpu) = -1;
	cpu_clear(cpu, cpu_present_map);
	num_processors--;

+12 −3
Original line number Diff line number Diff line
@@ -24,10 +24,19 @@
#include <acpi/acpi_bus.h>
#endif

/* which logical CPU number maps to which CPU (physical APIC ID) */
u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly
/*
 * which logical CPU number maps to which CPU (physical APIC ID)
 *
 * The following static array is used during kernel startup
 * and the x86_cpu_to_apicid_ptr contains the address of the
 * array during this time.  Is it zeroed when the per_cpu
 * data area is removed.
 */
u8 x86_cpu_to_apicid_init[NR_CPUS] __initdata
					= { [0 ... NR_CPUS-1] = BAD_APICID };
EXPORT_SYMBOL(x86_cpu_to_apicid);
void *x86_cpu_to_apicid_ptr;
DEFINE_PER_CPU(u8, x86_cpu_to_apicid) = BAD_APICID;
EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);

struct genapic __read_mostly *genapic = &apic_flat;

+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ static unsigned int physflat_cpu_mask_to_apicid(cpumask_t cpumask)
	 */
	cpu = first_cpu(cpumask);
	if ((unsigned)cpu < NR_CPUS)
		return x86_cpu_to_apicid[cpu];
		return per_cpu(x86_cpu_to_apicid, cpu);
	else
		return BAD_APICID;
}
+13 −2
Original line number Diff line number Diff line
@@ -123,7 +123,18 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
		cpu = 0;
 	}
	bios_cpu_apicid[cpu] = m->mpc_apicid;
	/*
	 * We get called early in the the start_kernel initialization
	 * process when the per_cpu data area is not yet setup, so we
	 * use a static array that is removed after the per_cpu data
	 * area is created.
	 */
	if (x86_cpu_to_apicid_ptr) {
		u8 *x86_cpu_to_apicid = (u8 *)x86_cpu_to_apicid_ptr;
		x86_cpu_to_apicid[cpu] = m->mpc_apicid;
	} else {
		per_cpu(x86_cpu_to_apicid, cpu) = m->mpc_apicid;
	}

	cpu_set(cpu, cpu_possible_map);
	cpu_set(cpu, cpu_present_map);
+5 −0
Original line number Diff line number Diff line
@@ -271,6 +271,11 @@ void __init setup_arch(char **cmdline_p)

	dmi_scan_machine();

#ifdef CONFIG_SMP
	/* setup to use the static apicid table during kernel startup */
	x86_cpu_to_apicid_ptr = (void *)&x86_cpu_to_apicid_init;
#endif

#ifdef CONFIG_ACPI
	/*
	 * Initialize the ACPI boot-time table parser (gets the RSDP and SDT).
Loading