This introduces THREAD_ORDER (to accompany THREAD_SIZE, which now becomes a derivate of the former) in order to easily pass this to page allocation routines. Code consuming this (fixing the double fault handler to use per-CPU stacks) will soon follow. Signed-Off-By: Jan Beulich --- 2.6.14/arch/i386/kernel/asm-offsets.c 2005-10-28 02:02:08.000000000 +0200 +++ 2.6.14-i386-THREAD_ORDER/arch/i386/kernel/asm-offsets.c 2005-11-04 16:19:32.000000000 +0100 @@ -68,5 +68,6 @@ void foo(void) sizeof(struct tss_struct)); DEFINE(PAGE_SIZE_asm, PAGE_SIZE); + DEFINE(THREAD_SIZE_asm, THREAD_SIZE); DEFINE(VSYSCALL_BASE, __fix_to_virt(FIX_VSYSCALL)); } --- 2.6.14/arch/i386/kernel/entry.S 2005-10-28 02:02:08.000000000 +0200 +++ 2.6.14-i386-THREAD_ORDER/arch/i386/kernel/entry.S 2005-11-04 16:45:13.000000000 +0100 @@ -540,8 +540,8 @@ ENTRY(nmi) /* Do not access memory above the end of our stack page, * it might not exist. */ - andl $(THREAD_SIZE-1),%eax - cmpl $(THREAD_SIZE-20),%eax + andl $(THREAD_SIZE_asm-1),%eax + cmpl $(THREAD_SIZE_asm-20),%eax popl %eax jae nmi_stack_correct cmpl $sysenter_entry,12(%esp) --- 2.6.14/arch/i386/kernel/head.S 2005-10-28 02:02:08.000000000 +0200 +++ 2.6.14-i386-THREAD_ORDER/arch/i386/kernel/head.S 2005-11-04 16:47:02.000000000 +0100 @@ -429,7 +429,7 @@ ENTRY(empty_zero_page) .data ENTRY(stack_start) - .long init_thread_union+THREAD_SIZE + .long init_thread_union+THREAD_SIZE_asm .long __BOOT_DS ready: .byte 0 --- 2.6.14/arch/i386/kernel/vmlinux.lds.S 2005-10-28 02:02:08.000000000 +0200 +++ 2.6.14-i386-THREAD_ORDER/arch/i386/kernel/vmlinux.lds.S 2005-11-08 14:45:53.000000000 +0100 @@ -4,8 +4,9 @@ #define LOAD_OFFSET __PAGE_OFFSET +#include #include -#include +#include #include OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") @@ -63,7 +64,7 @@ SECTIONS .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { *(.data.read_mostly) } _edata = .; /* End of data section */ - . = ALIGN(THREAD_SIZE); /* init_task */ + . = ALIGN(THREAD_SIZE_asm); /* init_task */ .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { *(.data.init_task) } --- 2.6.14/include/asm-i386/thread_info.h 2005-10-28 02:02:08.000000000 +0200 +++ 2.6.14-i386-THREAD_ORDER/include/asm-i386/thread_info.h 2005-11-04 16:19:34.000000000 +0100 @@ -54,10 +54,11 @@ struct thread_info { #define PREEMPT_ACTIVE 0x10000000 #ifdef CONFIG_4KSTACKS -#define THREAD_SIZE (4096) +#define THREAD_ORDER 0 #else -#define THREAD_SIZE (8192) +#define THREAD_ORDER 1 #endif +#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) #define STACK_WARN (THREAD_SIZE/8) /* @@ -118,12 +119,12 @@ register unsigned long current_stack_poi /* how to get the thread information struct from ASM */ #define GET_THREAD_INFO(reg) \ - movl $-THREAD_SIZE, reg; \ + movl $-THREAD_SIZE_asm, reg; \ andl %esp, reg /* use this one if reg already contains %esp */ #define GET_THREAD_INFO_WITH_ESP(reg) \ - andl $-THREAD_SIZE, reg + andl $-THREAD_SIZE_asm, reg #endif