ia64/xen-unstable

changeset 8929:82f6786a0aa8

Eliminate tss - tss is meaningless in a paravirtualized kernel
and consumes 25% of the per-cpu area.
Add CONFIG_X86_NO_TSS to exclude all code which references tss.

Based on a patch by Jan Beulich <JBeulich@novell.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Feb 20 15:15:10 2006 +0000 (2006-02-20)
parents f0a8a0a9a6f5
children 946a45f07351
files linux-2.6-xen-sparse/arch/x86_64/Kconfig linux-2.6-xen-sparse/arch/x86_64/kernel/asm-offsets.c linux-2.6-xen-sparse/arch/x86_64/kernel/init_task.c linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/setup64-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c linux-2.6-xen-sparse/drivers/xen/core/smpboot.c linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/desc.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/x86_64/Kconfig	Mon Feb 20 14:51:50 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/Kconfig	Mon Feb 20 15:15:10 2006 +0000
     1.3 @@ -125,6 +125,11 @@ config X86_64_XEN
     1.4  	help
     1.5  	  This option will compile a kernel compatible with Xen hypervisor
     1.6  
     1.7 +config X86_NO_TSS
     1.8 +	bool
     1.9 +	depends on X86_64_XEN
    1.10 +	default y
    1.11 +
    1.12  #
    1.13  # Define implied options from the CPU selection here
    1.14  #
     2.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/asm-offsets.c	Mon Feb 20 14:51:50 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/asm-offsets.c	Mon Feb 20 15:15:10 2006 +0000
     2.3 @@ -66,7 +66,9 @@ int main(void)
     2.4  	DEFINE(pbe_address, offsetof(struct pbe, address));
     2.5  	DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
     2.6  	DEFINE(pbe_next, offsetof(struct pbe, next));
     2.7 +#ifndef CONFIG_X86_NO_TSS
     2.8  	BLANK();
     2.9  	DEFINE(TSS_ist, offsetof(struct tss_struct, ist));
    2.10 +#endif
    2.11  	return 0;
    2.12  }
     3.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/init_task.c	Mon Feb 20 14:51:50 2006 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/init_task.c	Mon Feb 20 15:15:10 2006 +0000
     3.3 @@ -37,6 +37,8 @@ union thread_union init_thread_union
     3.4  struct task_struct init_task = INIT_TASK(init_task);
     3.5  
     3.6  EXPORT_SYMBOL(init_task);
     3.7 +
     3.8 +#ifndef CONFIG_X86_NO_TSS
     3.9  /*
    3.10   * per-CPU TSS segments. Threads are completely 'soft' on Linux,
    3.11   * no more per-task TSS's. The TSS size is kept cacheline-aligned
    3.12 @@ -45,5 +47,6 @@ EXPORT_SYMBOL(init_task);
    3.13   * on exact cacheline boundaries, to eliminate cacheline ping-pong.
    3.14   */ 
    3.15  DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_internodealigned_in_smp = INIT_TSS;
    3.16 +#endif
    3.17  
    3.18  #define ALIGN_TO_4K __attribute__((section(".data.init_task")))
     4.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Mon Feb 20 14:51:50 2006 +0000
     4.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Mon Feb 20 15:15:10 2006 +0000
     4.3 @@ -289,16 +289,28 @@ void exit_thread(void)
     4.4  	kprobe_flush_task(me);
     4.5  
     4.6  	if (me->thread.io_bitmap_ptr) { 
     4.7 +#ifndef CONFIG_X86_NO_TSS
     4.8  		struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
     4.9 +#endif
    4.10 +#ifdef CONFIG_XEN
    4.11 +		static physdev_op_t iobmp_op = {
    4.12 +			.cmd = PHYSDEVOP_SET_IOBITMAP
    4.13 +		};
    4.14 +#endif
    4.15  
    4.16  		kfree(t->io_bitmap_ptr);
    4.17  		t->io_bitmap_ptr = NULL;
    4.18  		/*
    4.19  		 * Careful, clear this in the TSS too:
    4.20  		 */
    4.21 +#ifndef CONFIG_X86_NO_TSS
    4.22  		memset(tss->io_bitmap, 0xff, t->io_bitmap_max);
    4.23 +		put_cpu();
    4.24 +#endif
    4.25 +#ifdef CONFIG_XEN
    4.26 +		HYPERVISOR_physdev_op(&iobmp_op);
    4.27 +#endif
    4.28  		t->io_bitmap_max = 0;
    4.29 -		put_cpu();
    4.30  	}
    4.31  }
    4.32  
    4.33 @@ -463,7 +475,9 @@ static inline void __save_init_fpu( stru
    4.34  	struct thread_struct *prev = &prev_p->thread,
    4.35  				 *next = &next_p->thread;
    4.36  	int cpu = smp_processor_id();  
    4.37 +#ifndef CONFIG_X86_NO_TSS
    4.38  	struct tss_struct *tss = &per_cpu(init_tss, cpu);
    4.39 +#endif
    4.40  	physdev_op_t iopl_op, iobmp_op;
    4.41  	multicall_entry_t _mcl[8], *mcl = _mcl;
    4.42  
    4.43 @@ -482,10 +496,9 @@ static inline void __save_init_fpu( stru
    4.44  	/*
    4.45  	 * Reload esp0, LDT and the page table pointer:
    4.46  	 */
    4.47 -	tss->rsp0 = next->rsp0;
    4.48  	mcl->op      = __HYPERVISOR_stack_switch;
    4.49  	mcl->args[0] = __KERNEL_DS;
    4.50 -	mcl->args[1] = tss->rsp0;
    4.51 +	mcl->args[1] = next->rsp0;
    4.52  	mcl++;
    4.53  
    4.54  	/*
     5.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/setup64-xen.c	Mon Feb 20 14:51:50 2006 +0000
     5.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/setup64-xen.c	Mon Feb 20 15:15:10 2006 +0000
     5.3 @@ -203,8 +203,10 @@ void pda_init(int cpu)
     5.4  	pda->irqstackptr += IRQSTACKSIZE-64;
     5.5  } 
     5.6  
     5.7 +#ifndef CONFIG_X86_NO_TSS
     5.8  char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]
     5.9  __attribute__((section(".bss.page_aligned")));
    5.10 +#endif
    5.11  
    5.12  /* May not be marked __init: used by software suspend */
    5.13  void syscall_init(void)
    5.14 @@ -246,18 +248,23 @@ void __cpuinit check_efer(void)
    5.15  void __cpuinit cpu_init (void)
    5.16  {
    5.17  	int cpu = stack_smp_processor_id();
    5.18 +#ifndef CONFIG_X86_NO_TSS
    5.19  	struct tss_struct *t = &per_cpu(init_tss, cpu);
    5.20  	unsigned long v; 
    5.21  	char *estacks = NULL; 
    5.22 +	unsigned i;
    5.23 +#endif
    5.24  	struct task_struct *me;
    5.25 -	int i;
    5.26  
    5.27  	/* CPU 0 is initialised in head64.c */
    5.28  	if (cpu != 0) {
    5.29  		pda_init(cpu);
    5.30  		zap_low_mappings(cpu);
    5.31 -	} else 
    5.32 +	}
    5.33 +#ifndef CONFIG_X86_NO_TSS
    5.34 +	else
    5.35  		estacks = boot_exception_stacks; 
    5.36 +#endif
    5.37  
    5.38  	me = current;
    5.39  
    5.40 @@ -294,6 +301,7 @@ void __cpuinit cpu_init (void)
    5.41  
    5.42  	check_efer();
    5.43  
    5.44 +#ifndef CONFIG_X86_NO_TSS
    5.45  	/*
    5.46  	 * set up and load the per-CPU TSS
    5.47  	 */
    5.48 @@ -330,6 +338,7 @@ void __cpuinit cpu_init (void)
    5.49  	 */
    5.50  	for (i = 0; i <= IO_BITMAP_LONGS; i++)
    5.51  		t->io_bitmap[i] = ~0UL;
    5.52 +#endif
    5.53  
    5.54  	atomic_inc(&init_mm.mm_count);
    5.55  	me->active_mm = &init_mm;
    5.56 @@ -337,8 +346,10 @@ void __cpuinit cpu_init (void)
    5.57  		BUG();
    5.58  	enter_lazy_tlb(&init_mm, me);
    5.59  
    5.60 +#ifndef CONFIG_X86_NO_TSS
    5.61 +	set_tss_desc(cpu, t);
    5.62 +#endif
    5.63  #ifndef CONFIG_XEN
    5.64 -	set_tss_desc(cpu, t);
    5.65  	load_TR_desc();
    5.66  #endif
    5.67  	load_LDT(&init_mm.context);
     6.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c	Mon Feb 20 14:51:50 2006 +0000
     6.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c	Mon Feb 20 15:15:10 2006 +0000
     6.3 @@ -134,6 +134,7 @@ int printk_address(unsigned long address
     6.4  static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
     6.5  					unsigned *usedp, const char **idp)
     6.6  {
     6.7 +#ifndef CONFIG_X86_NO_TSS
     6.8  	static char ids[][8] = {
     6.9  		[DEBUG_STACK - 1] = "#DB",
    6.10  		[NMI_STACK - 1] = "NMI",
    6.11 @@ -185,6 +186,7 @@ static unsigned long *in_exception_stack
    6.12  		}
    6.13  #endif
    6.14  	}
    6.15 +#endif
    6.16  	return NULL;
    6.17  }
    6.18  
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Mon Feb 20 14:51:50 2006 +0000
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c	Mon Feb 20 15:15:10 2006 +0000
     7.3 @@ -237,7 +237,6 @@ void __init smp_prepare_cpus(unsigned in
     7.4  #ifdef __x86_64__
     7.5  		cpu_pda(cpu)->pcurrent = idle;
     7.6  		cpu_pda(cpu)->cpunumber = cpu;
     7.7 -		per_cpu(init_tss,cpu).rsp0 = idle->thread.rsp;
     7.8  		clear_ti_thread_flag(idle->thread_info, TIF_FORK);
     7.9  #endif
    7.10  
     8.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/desc.h	Mon Feb 20 14:51:50 2006 +0000
     8.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/desc.h	Mon Feb 20 15:15:10 2006 +0000
     8.3 @@ -152,6 +152,7 @@ static inline void set_tssldt_descriptor
     8.4  	memcpy(ptr, &d, 16); 
     8.5  }
     8.6  
     8.7 +#ifndef CONFIG_X86_NO_TSS
     8.8  static inline void set_tss_desc(unsigned cpu, void *addr)
     8.9  { 
    8.10  	/*
    8.11 @@ -165,6 +166,7 @@ static inline void set_tss_desc(unsigned
    8.12  		(unsigned long)addr, DESC_TSS,
    8.13  		IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
    8.14  } 
    8.15 +#endif
    8.16  
    8.17  static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
    8.18  { 
     9.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h	Mon Feb 20 14:51:50 2006 +0000
     9.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h	Mon Feb 20 15:15:10 2006 +0000
     9.3 @@ -196,7 +196,9 @@ static inline void clear_in_cr4 (unsigne
     9.4  #define IO_BITMAP_BITS  65536
     9.5  #define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
     9.6  #define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
     9.7 +#ifndef CONFIG_X86_NO_TSS
     9.8  #define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
     9.9 +#endif
    9.10  #define INVALID_IO_BITMAP_OFFSET 0x8000
    9.11  
    9.12  struct i387_fxsave_struct {
    9.13 @@ -217,6 +219,7 @@ union i387_union {
    9.14  	struct i387_fxsave_struct	fxsave;
    9.15  };
    9.16  
    9.17 +#ifndef CONFIG_X86_NO_TSS
    9.18  struct tss_struct {
    9.19  	u32 reserved1;
    9.20  	u64 rsp0;	
    9.21 @@ -240,8 +243,10 @@ struct tss_struct {
    9.22  	unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
    9.23  } __attribute__((packed)) ____cacheline_aligned;
    9.24  
    9.25 +DECLARE_PER_CPU(struct tss_struct,init_tss);
    9.26 +#endif
    9.27 +
    9.28  extern struct cpuinfo_x86 boot_cpu_data;
    9.29 -DECLARE_PER_CPU(struct tss_struct,init_tss);
    9.30  
    9.31  #ifdef CONFIG_X86_VSMP
    9.32  #define ARCH_MIN_TASKALIGN	(1 << INTERNODE_CACHE_SHIFT)
    9.33 @@ -283,9 +288,11 @@ struct thread_struct {
    9.34  	.rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
    9.35  }
    9.36  
    9.37 +#ifndef CONFIG_X86_NO_TSS
    9.38  #define INIT_TSS  { \
    9.39  	.rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
    9.40  }
    9.41 +#endif
    9.42  
    9.43  #define INIT_MMAP \
    9.44  { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }