Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 71698
b: refs/heads/master
c: 71fff5e
h: refs/heads/master
v: v3
  • Loading branch information
Mike Travis authored and Thomas Gleixner committed Oct 19, 2007
1 parent df9b1d4 commit a3e4155
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dbeb2be21d678c49a8d8bbf774903df15dd55474
refs/heads/master: 71fff5e6ca1b738ac4742580e4c0ff79d906f6c8
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/acpi/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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--;

Expand Down
15 changes: 12 additions & 3 deletions trunk/arch/x86/kernel/genapic_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/genapic_flat_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 13 additions & 2 deletions trunk/arch/x86/kernel/mpparse_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int __init mpf_checksum(unsigned char *mp, int len)
return sum & 0xFF;
}

static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
{
int cpu;
cpumask_t tmp_map;
Expand Down Expand Up @@ -123,7 +123,18 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
cpu = 0;
}
bios_cpu_apicid[cpu] = m->mpc_apicid;
x86_cpu_to_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);
Expand Down
5 changes: 5 additions & 0 deletions trunk/arch/x86/kernel/setup_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/smp_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ static int convert_apicid_to_cpu(int apic_id)
int i;

for (i = 0; i < NR_CPUS; i++) {
if (x86_cpu_to_apicid[i] == apic_id)
if (per_cpu(x86_cpu_to_apicid, i) == apic_id)
return i;
}
return -1;
Expand Down
22 changes: 15 additions & 7 deletions trunk/arch/x86/kernel/smpboot_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,17 @@ static cpumask_t smp_commenced_mask;
struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
EXPORT_SYMBOL(cpu_data);

u8 x86_cpu_to_apicid[NR_CPUS] __read_mostly =
{ [0 ... NR_CPUS-1] = 0xff };
EXPORT_SYMBOL(x86_cpu_to_apicid);
/*
* 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 };
void *x86_cpu_to_apicid_ptr;
DEFINE_PER_CPU(u8, x86_cpu_to_apicid) = BAD_APICID;
EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);

u8 apicid_2_node[MAX_APICID];

Expand Down Expand Up @@ -804,7 +812,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)

irq_ctx_init(cpu);

x86_cpu_to_apicid[cpu] = apicid;
per_cpu(x86_cpu_to_apicid, cpu) = apicid;
/*
* This grunge runs the startup process for
* the targeted processor.
Expand Down Expand Up @@ -866,7 +874,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */
cpucount--;
} else {
x86_cpu_to_apicid[cpu] = apicid;
per_cpu(x86_cpu_to_apicid, cpu) = apicid;
cpu_set(cpu, cpu_present_map);
}

Expand Down Expand Up @@ -915,7 +923,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
struct warm_boot_cpu_info info;
int apicid, ret;

apicid = x86_cpu_to_apicid[cpu];
apicid = per_cpu(x86_cpu_to_apicid, cpu);
if (apicid == BAD_APICID) {
ret = -ENODEV;
goto exit;
Expand Down Expand Up @@ -965,7 +973,7 @@ static void __init smp_boot_cpus(unsigned int max_cpus)

boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
boot_cpu_logical_apicid = logical_smp_processor_id();
x86_cpu_to_apicid[0] = boot_cpu_physical_apicid;
per_cpu(x86_cpu_to_apicid, 0) = boot_cpu_physical_apicid;

current_thread_info()->cpu = 0;

Expand Down
23 changes: 22 additions & 1 deletion trunk/arch/x86/kernel/smpboot_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
clear_node_cpumask(cpu); /* was set by numa_add_cpu */
cpu_clear(cpu, cpu_present_map);
cpu_clear(cpu, cpu_possible_map);
x86_cpu_to_apicid[cpu] = BAD_APICID;
per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID;
return -EIO;
}

Expand Down Expand Up @@ -840,6 +840,26 @@ static int __init smp_sanity_check(unsigned max_cpus)
return 0;
}

/*
* Copy apicid's found by MP_processor_info from initial array to the per cpu
* data area. The x86_cpu_to_apicid_init array is then expendable and the
* x86_cpu_to_apicid_ptr is zeroed indicating that the static array is no
* longer available.
*/
void __init smp_set_apicids(void)
{
int cpu;

for_each_cpu_mask(cpu, cpu_possible_map) {
if (per_cpu_offset(cpu))
per_cpu(x86_cpu_to_apicid, cpu) =
x86_cpu_to_apicid_init[cpu];
}

/* indicate the static array will be going away soon */
x86_cpu_to_apicid_ptr = NULL;
}

/*
* Prepare for SMP bootup. The MP table or ACPI has been read
* earlier. Just do some sanity checking here and enable APIC mode.
Expand All @@ -849,6 +869,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
nmi_watchdog_default();
current_cpu_data = boot_cpu_data;
current_thread_info()->cpu = 0; /* needed? */
smp_set_apicids();
set_cpu_sibling_map(0);

if (smp_sanity_check(max_cpus) < 0) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/mm/numa_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ void __init init_cpu_to_node(void)
{
int i;
for (i = 0; i < NR_CPUS; i++) {
u8 apicid = x86_cpu_to_apicid[i];
u8 apicid = x86_cpu_to_apicid_init[i];
if (apicid == BAD_APICID)
continue;
if (apicid_to_node[apicid] == NUMA_NO_NODE)
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/asm-x86/ipi.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static inline void send_IPI_mask_sequence(cpumask_t mask, int vector)
*/
local_irq_save(flags);
for_each_cpu_mask(query_cpu, mask) {
__send_IPI_dest_field(x86_cpu_to_apicid[query_cpu],
__send_IPI_dest_field(per_cpu(x86_cpu_to_apicid, query_cpu),
vector, APIC_DEST_PHYSICAL);
}
local_irq_restore(flags);
Expand Down
6 changes: 4 additions & 2 deletions trunk/include/asm-x86/smp_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ extern void lock_ipi_call_lock(void);
extern void unlock_ipi_call_lock(void);

#define MAX_APICID 256
extern u8 x86_cpu_to_apicid[];
extern u8 __initdata x86_cpu_to_apicid_init[];
extern void *x86_cpu_to_apicid_ptr;
DECLARE_PER_CPU(u8, x86_cpu_to_apicid);

#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)

extern void set_cpu_sibling_map(int cpu);

Expand Down
6 changes: 4 additions & 2 deletions trunk/include/asm-x86/smp_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ static inline int hard_smp_processor_id(void)
* Some lowlevel functions might want to know about
* the real APIC ID <-> CPU # mapping.
*/
extern u8 x86_cpu_to_apicid[NR_CPUS]; /* physical ID */
extern u8 __initdata x86_cpu_to_apicid_init[];
extern void *x86_cpu_to_apicid_ptr;
DECLARE_PER_CPU(u8, x86_cpu_to_apicid); /* physical ID */
extern u8 bios_cpu_apicid[];

static inline int cpu_present_to_apicid(int mps_cpu)
Expand Down Expand Up @@ -117,7 +119,7 @@ static __inline int logical_smp_processor_id(void)
}

#ifdef CONFIG_SMP
#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
#else
#define cpu_physical_id(cpu) boot_cpu_id
#endif /* !CONFIG_SMP */
Expand Down

0 comments on commit a3e4155

Please sign in to comment.