Commit c8f3329a authored by Tejun Heo's avatar Tejun Heo Committed by Ingo Molnar

x86: use static _cpu_pda array

_cpu_pda array first uses statically allocated storage in data.init
and then switches to allocated bootmem to conserve space.  However,
after folding pda area into percpu area, _cpu_pda array will be
removed completely.  Drop the reallocation part to simplify the code
for soon-to-follow changes.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f32ff538
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/threads.h>
#include <asm/page.h> #include <asm/page.h>
/* Per processor datastructure. %gs points to it while the kernel runs */ /* Per processor datastructure. %gs points to it while the kernel runs */
...@@ -39,7 +40,7 @@ struct x8664_pda { ...@@ -39,7 +40,7 @@ struct x8664_pda {
unsigned irq_spurious_count; unsigned irq_spurious_count;
} ____cacheline_aligned_in_smp; } ____cacheline_aligned_in_smp;
extern struct x8664_pda **_cpu_pda; extern struct x8664_pda *_cpu_pda[NR_CPUS];
extern void pda_init(int); extern void pda_init(int);
#define cpu_pda(i) (_cpu_pda[i]) #define cpu_pda(i) (_cpu_pda[i])
......
...@@ -879,7 +879,7 @@ static __init int setup_disablecpuid(char *arg) ...@@ -879,7 +879,7 @@ static __init int setup_disablecpuid(char *arg)
__setup("clearcpuid=", setup_disablecpuid); __setup("clearcpuid=", setup_disablecpuid);
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
struct x8664_pda **_cpu_pda __read_mostly; struct x8664_pda *_cpu_pda[NR_CPUS] __read_mostly;
EXPORT_SYMBOL(_cpu_pda); EXPORT_SYMBOL(_cpu_pda);
struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table }; struct desc_ptr idt_descr = { 256 * 16 - 1, (unsigned long) idt_table };
......
...@@ -29,20 +29,8 @@ ...@@ -29,20 +29,8 @@
/* boot cpu pda, referenced by head_64.S to initialize %gs for boot CPU */ /* boot cpu pda, referenced by head_64.S to initialize %gs for boot CPU */
struct x8664_pda _boot_cpu_pda; struct x8664_pda _boot_cpu_pda;
#ifdef CONFIG_SMP
/*
* We install an empty cpu_pda pointer table to indicate to early users
* (numa_set_node) that the cpu_pda pointer table for cpus other than
* the boot cpu is not yet setup.
*/
static struct x8664_pda *__cpu_pda[NR_CPUS] __initdata;
#else
static struct x8664_pda *__cpu_pda[NR_CPUS] __read_mostly;
#endif
void __init x86_64_init_pda(void) void __init x86_64_init_pda(void)
{ {
_cpu_pda = __cpu_pda;
cpu_pda(0) = &_boot_cpu_pda; cpu_pda(0) = &_boot_cpu_pda;
cpu_pda(0)->data_offset = cpu_pda(0)->data_offset =
(unsigned long)(__per_cpu_load - __per_cpu_start); (unsigned long)(__per_cpu_load - __per_cpu_start);
......
...@@ -114,7 +114,6 @@ static inline void setup_cpu_pda_map(void) { } ...@@ -114,7 +114,6 @@ static inline void setup_cpu_pda_map(void) { }
static void __init setup_cpu_pda_map(void) static void __init setup_cpu_pda_map(void)
{ {
char *pda; char *pda;
struct x8664_pda **new_cpu_pda;
unsigned long size; unsigned long size;
int cpu; int cpu;
...@@ -122,28 +121,21 @@ static void __init setup_cpu_pda_map(void) ...@@ -122,28 +121,21 @@ static void __init setup_cpu_pda_map(void)
/* allocate cpu_pda array and pointer table */ /* allocate cpu_pda array and pointer table */
{ {
unsigned long tsize = nr_cpu_ids * sizeof(void *);
unsigned long asize = size * (nr_cpu_ids - 1); unsigned long asize = size * (nr_cpu_ids - 1);
tsize = roundup(tsize, cache_line_size()); pda = alloc_bootmem(asize);
new_cpu_pda = alloc_bootmem(tsize + asize);
pda = (char *)new_cpu_pda + tsize;
} }
/* initialize pointer table to static pda's */ /* initialize pointer table to static pda's */
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
if (cpu == 0) { if (cpu == 0) {
/* leave boot cpu pda in place */ /* leave boot cpu pda in place */
new_cpu_pda[0] = cpu_pda(0);
continue; continue;
} }
new_cpu_pda[cpu] = (struct x8664_pda *)pda; cpu_pda(cpu) = (struct x8664_pda *)pda;
new_cpu_pda[cpu]->in_bootmem = 1; cpu_pda(cpu)->in_bootmem = 1;
pda += size; pda += size;
} }
/* point to new pointer table */
_cpu_pda = new_cpu_pda;
} }
#endif /* CONFIG_SMP && CONFIG_X86_64 */ #endif /* CONFIG_SMP && CONFIG_X86_64 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment