# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 82f6786a0aa866ae6eecd1d4184c0df30b2c0543
# Parent f0a8a0a9a6f52dc78b5bd7a0a7e959ff15b78a8c
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@xxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8 linux-2.6-xen-sparse/arch/x86_64/Kconfig
--- a/linux-2.6-xen-sparse/arch/x86_64/Kconfig Mon Feb 20 14:51:50 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/Kconfig Mon Feb 20 15:15:10 2006
@@ -124,6 +124,11 @@
select SWIOTLB
help
This option will compile a kernel compatible with Xen hypervisor
+
+config X86_NO_TSS
+ bool
+ depends on X86_64_XEN
+ default y
#
# Define implied options from the CPU selection here
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8
linux-2.6-xen-sparse/arch/x86_64/kernel/asm-offsets.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/asm-offsets.c Mon Feb 20
14:51:50 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/asm-offsets.c Mon Feb 20
15:15:10 2006
@@ -66,7 +66,9 @@
DEFINE(pbe_address, offsetof(struct pbe, address));
DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address));
DEFINE(pbe_next, offsetof(struct pbe, next));
+#ifndef CONFIG_X86_NO_TSS
BLANK();
DEFINE(TSS_ist, offsetof(struct tss_struct, ist));
+#endif
return 0;
}
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8
linux-2.6-xen-sparse/arch/x86_64/kernel/init_task.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/init_task.c Mon Feb 20
14:51:50 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/init_task.c Mon Feb 20
15:15:10 2006
@@ -37,6 +37,8 @@
struct task_struct init_task = INIT_TASK(init_task);
EXPORT_SYMBOL(init_task);
+
+#ifndef CONFIG_X86_NO_TSS
/*
* per-CPU TSS segments. Threads are completely 'soft' on Linux,
* no more per-task TSS's. The TSS size is kept cacheline-aligned
@@ -45,5 +47,6 @@
* on exact cacheline boundaries, to eliminate cacheline ping-pong.
*/
DEFINE_PER_CPU(struct tss_struct, init_tss)
____cacheline_internodealigned_in_smp = INIT_TSS;
+#endif
#define ALIGN_TO_4K __attribute__((section(".data.init_task")))
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8
linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c Mon Feb 20
14:51:50 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c Mon Feb 20
15:15:10 2006
@@ -289,16 +289,28 @@
kprobe_flush_task(me);
if (me->thread.io_bitmap_ptr) {
+#ifndef CONFIG_X86_NO_TSS
struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
+#endif
+#ifdef CONFIG_XEN
+ static physdev_op_t iobmp_op = {
+ .cmd = PHYSDEVOP_SET_IOBITMAP
+ };
+#endif
kfree(t->io_bitmap_ptr);
t->io_bitmap_ptr = NULL;
/*
* Careful, clear this in the TSS too:
*/
+#ifndef CONFIG_X86_NO_TSS
memset(tss->io_bitmap, 0xff, t->io_bitmap_max);
+ put_cpu();
+#endif
+#ifdef CONFIG_XEN
+ HYPERVISOR_physdev_op(&iobmp_op);
+#endif
t->io_bitmap_max = 0;
- put_cpu();
}
}
@@ -463,7 +475,9 @@
struct thread_struct *prev = &prev_p->thread,
*next = &next_p->thread;
int cpu = smp_processor_id();
+#ifndef CONFIG_X86_NO_TSS
struct tss_struct *tss = &per_cpu(init_tss, cpu);
+#endif
physdev_op_t iopl_op, iobmp_op;
multicall_entry_t _mcl[8], *mcl = _mcl;
@@ -482,10 +496,9 @@
/*
* Reload esp0, LDT and the page table pointer:
*/
- tss->rsp0 = next->rsp0;
mcl->op = __HYPERVISOR_stack_switch;
mcl->args[0] = __KERNEL_DS;
- mcl->args[1] = tss->rsp0;
+ mcl->args[1] = next->rsp0;
mcl++;
/*
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8
linux-2.6-xen-sparse/arch/x86_64/kernel/setup64-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/setup64-xen.c Mon Feb 20
14:51:50 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/setup64-xen.c Mon Feb 20
15:15:10 2006
@@ -203,8 +203,10 @@
pda->irqstackptr += IRQSTACKSIZE-64;
}
+#ifndef CONFIG_X86_NO_TSS
char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ +
DEBUG_STKSZ]
__attribute__((section(".bss.page_aligned")));
+#endif
/* May not be marked __init: used by software suspend */
void syscall_init(void)
@@ -246,18 +248,23 @@
void __cpuinit cpu_init (void)
{
int cpu = stack_smp_processor_id();
+#ifndef CONFIG_X86_NO_TSS
struct tss_struct *t = &per_cpu(init_tss, cpu);
unsigned long v;
char *estacks = NULL;
+ unsigned i;
+#endif
struct task_struct *me;
- int i;
/* CPU 0 is initialised in head64.c */
if (cpu != 0) {
pda_init(cpu);
zap_low_mappings(cpu);
- } else
+ }
+#ifndef CONFIG_X86_NO_TSS
+ else
estacks = boot_exception_stacks;
+#endif
me = current;
@@ -294,6 +301,7 @@
check_efer();
+#ifndef CONFIG_X86_NO_TSS
/*
* set up and load the per-CPU TSS
*/
@@ -330,6 +338,7 @@
*/
for (i = 0; i <= IO_BITMAP_LONGS; i++)
t->io_bitmap[i] = ~0UL;
+#endif
atomic_inc(&init_mm.mm_count);
me->active_mm = &init_mm;
@@ -337,8 +346,10 @@
BUG();
enter_lazy_tlb(&init_mm, me);
+#ifndef CONFIG_X86_NO_TSS
+ set_tss_desc(cpu, t);
+#endif
#ifndef CONFIG_XEN
- set_tss_desc(cpu, t);
load_TR_desc();
#endif
load_LDT(&init_mm.context);
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8
linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c Mon Feb 20
14:51:50 2006
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/traps-xen.c Mon Feb 20
15:15:10 2006
@@ -134,6 +134,7 @@
static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
unsigned *usedp, const char **idp)
{
+#ifndef CONFIG_X86_NO_TSS
static char ids[][8] = {
[DEBUG_STACK - 1] = "#DB",
[NMI_STACK - 1] = "NMI",
@@ -185,6 +186,7 @@
}
#endif
}
+#endif
return NULL;
}
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8
linux-2.6-xen-sparse/drivers/xen/core/smpboot.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c Mon Feb 20 14:51:50 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/core/smpboot.c Mon Feb 20 15:15:10 2006
@@ -237,7 +237,6 @@
#ifdef __x86_64__
cpu_pda(cpu)->pcurrent = idle;
cpu_pda(cpu)->cpunumber = cpu;
- per_cpu(init_tss,cpu).rsp0 = idle->thread.rsp;
clear_ti_thread_flag(idle->thread_info, TIF_FORK);
#endif
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/desc.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/desc.h Mon Feb
20 14:51:50 2006
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/desc.h Mon Feb
20 15:15:10 2006
@@ -152,6 +152,7 @@
memcpy(ptr, &d, 16);
}
+#ifndef CONFIG_X86_NO_TSS
static inline void set_tss_desc(unsigned cpu, void *addr)
{
/*
@@ -165,6 +166,7 @@
(unsigned long)addr, DESC_TSS,
IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
}
+#endif
static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
{
diff -r f0a8a0a9a6f5 -r 82f6786a0aa8
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h Mon Feb
20 14:51:50 2006
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h Mon Feb
20 15:15:10 2006
@@ -196,7 +196,9 @@
#define IO_BITMAP_BITS 65536
#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
+#ifndef CONFIG_X86_NO_TSS
#define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
+#endif
#define INVALID_IO_BITMAP_OFFSET 0x8000
struct i387_fxsave_struct {
@@ -217,6 +219,7 @@
struct i387_fxsave_struct fxsave;
};
+#ifndef CONFIG_X86_NO_TSS
struct tss_struct {
u32 reserved1;
u64 rsp0;
@@ -240,8 +243,10 @@
unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
} __attribute__((packed)) ____cacheline_aligned;
+DECLARE_PER_CPU(struct tss_struct,init_tss);
+#endif
+
extern struct cpuinfo_x86 boot_cpu_data;
-DECLARE_PER_CPU(struct tss_struct,init_tss);
#ifdef CONFIG_X86_VSMP
#define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT)
@@ -283,9 +288,11 @@
.rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
}
+#ifndef CONFIG_X86_NO_TSS
#define INIT_TSS { \
.rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
}
+#endif
#define INIT_MMAP \
{ &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL,
NULL }
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|