From d987bdff0da6166a31ab1af47b225590915579d3 Mon Sep 17 00:00:00 2001 From: Shai Fultheim Date: Sun, 22 Aug 2004 22:42:10 -0700 Subject: [PATCH] [PATCH] percpu: init_tss Use the percpu infrastructure rather than open-coded array[NR_CPUS]. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/cpu/common.c | 2 +- arch/i386/kernel/init_task.c | 7 ++----- arch/i386/kernel/ioport.c | 2 +- arch/i386/kernel/process.c | 4 ++-- arch/i386/kernel/sysenter.c | 2 +- arch/i386/kernel/vm86.c | 4 ++-- arch/i386/power/cpu.c | 2 +- include/asm-i386/processor.h | 4 ++-- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c index 9f048bba69ebc..428800f11afc7 100644 --- a/arch/i386/kernel/cpu/common.c +++ b/arch/i386/kernel/cpu/common.c @@ -506,7 +506,7 @@ void __init early_cpu_init(void) void __init cpu_init (void) { int cpu = smp_processor_id(); - struct tss_struct * t = init_tss + cpu; + struct tss_struct * t = &per_cpu(init_tss, cpu); struct thread_struct *thread = ¤t->thread; if (test_and_set_bit(cpu, &cpu_initialized)) { diff --git a/arch/i386/kernel/init_task.c b/arch/i386/kernel/init_task.c index 5e1897649af8a..9caa8e8db80ca 100644 --- a/arch/i386/kernel/init_task.c +++ b/arch/i386/kernel/init_task.c @@ -40,10 +40,7 @@ EXPORT_SYMBOL(init_task); /* * per-CPU TSS segments. Threads are completely 'soft' on Linux, - * no more per-task TSS's. The TSS size is kept cacheline-aligned - * so they are allowed to end up in the .data.cacheline_aligned - * section. Since TSS's are completely CPU-local, we want them - * on exact cacheline boundaries, to eliminate cacheline ping-pong. + * no more per-task TSS's. */ -struct tss_struct init_tss[NR_CPUS] __cacheline_aligned = { [0 ... NR_CPUS-1] = INIT_TSS }; +DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_maxaligned_in_smp = INIT_TSS; diff --git a/arch/i386/kernel/ioport.c b/arch/i386/kernel/ioport.c index e4350d22b5f6e..001044c6f9d8c 100644 --- a/arch/i386/kernel/ioport.c +++ b/arch/i386/kernel/ioport.c @@ -87,7 +87,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) * because the ->io_bitmap_max value must match the bitmap * contents: */ - tss = init_tss + get_cpu(); + tss = &per_cpu(init_tss, get_cpu()); set_bitmap(t->io_bitmap_ptr, from, num, !turn_on); diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index bf3cdbfe27d11..0b3b83450b19d 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c @@ -299,7 +299,7 @@ void exit_thread(void) /* The process may have allocated an io port bitmap... nuke it. */ if (unlikely(NULL != t->io_bitmap_ptr)) { int cpu = get_cpu(); - struct tss_struct *tss = init_tss + cpu; + struct tss_struct *tss = &per_cpu(init_tss, cpu); kfree(t->io_bitmap_ptr); t->io_bitmap_ptr = NULL; @@ -517,7 +517,7 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas struct thread_struct *prev = &prev_p->thread, *next = &next_p->thread; int cpu = smp_processor_id(); - struct tss_struct *tss = init_tss + cpu; + struct tss_struct *tss = &per_cpu(init_tss, cpu); /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */ diff --git a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c index 0daa404f52ee9..7a35ee83f9283 100644 --- a/arch/i386/kernel/sysenter.c +++ b/arch/i386/kernel/sysenter.c @@ -24,7 +24,7 @@ extern asmlinkage void sysenter_entry(void); void enable_sep_cpu(void *info) { int cpu = get_cpu(); - struct tss_struct *tss = init_tss + cpu; + struct tss_struct *tss = &per_cpu(init_tss, cpu); tss->ss1 = __KERNEL_CS; tss->esp1 = sizeof(struct tss_struct) + (unsigned long) tss; diff --git a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c index 4484e47a77c57..483e9b2e47ed7 100644 --- a/arch/i386/kernel/vm86.c +++ b/arch/i386/kernel/vm86.c @@ -121,7 +121,7 @@ struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs) do_exit(SIGSEGV); } - tss = init_tss + get_cpu(); + tss = &per_cpu(init_tss, get_cpu()); current->thread.esp0 = current->thread.saved_esp0; current->thread.sysenter_cs = __KERNEL_CS; load_esp0(tss, ¤t->thread); @@ -303,7 +303,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk asm volatile("movl %%fs,%0":"=m" (tsk->thread.saved_fs)); asm volatile("movl %%gs,%0":"=m" (tsk->thread.saved_gs)); - tss = init_tss + get_cpu(); + tss = &per_cpu(init_tss, get_cpu()); tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0; if (cpu_has_sep) tsk->thread.sysenter_cs = 0; diff --git a/arch/i386/power/cpu.c b/arch/i386/power/cpu.c index 2a6234a07b4b0..53542e3a923a4 100644 --- a/arch/i386/power/cpu.c +++ b/arch/i386/power/cpu.c @@ -83,7 +83,7 @@ do_fpu_end(void) static void fix_processor_context(void) { int cpu = smp_processor_id(); - struct tss_struct * t = init_tss + cpu; + struct tss_struct * t = &per_cpu(init_tss, cpu); set_tss_desc(cpu,t); /* This just modifies memory; should not be necessary. But... This is necessary, because 386 hardware has concept of busy TSS or some similar stupidity. */ per_cpu(cpu_gdt_table, cpu)[GDT_ENTRY_TSS].b &= 0xfffffdff; diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h index 76ca7ea957a2b..b542bd9d5a2b7 100644 --- a/include/asm-i386/processor.h +++ b/include/asm-i386/processor.h @@ -19,6 +19,7 @@ #include #include #include +#include /* flag for disabling the tsc */ extern int tsc_disable; @@ -84,8 +85,8 @@ struct cpuinfo_x86 { extern struct cpuinfo_x86 boot_cpu_data; extern struct cpuinfo_x86 new_cpu_data; -extern struct tss_struct init_tss[NR_CPUS]; extern struct tss_struct doublefault_tss; +DECLARE_PER_CPU(struct tss_struct, init_tss); #ifdef CONFIG_SMP extern struct cpuinfo_x86 cpu_data[]; @@ -441,7 +442,6 @@ struct thread_struct { #define INIT_TSS { \ .esp0 = sizeof(init_stack) + (long)&init_stack, \ .ss0 = __KERNEL_DS, \ - .esp1 = sizeof(init_tss[0]) + (long)&init_tss[0], \ .ss1 = __KERNEL_CS, \ .ldt = GDT_ENTRY_LDT, \ .io_bitmap_base = offsetof(struct tss_struct,io_bitmap), \ -- 2.53.0