Whamcloud - gitweb
- configurable stack size fo x86_64
[fs/lustre-release.git] / lustre / kernel_patches / patches / configurable-x86-stack-2.4.21-suse2.patch
1 Index: kernel-2.4.21/arch/i386/kernel/entry.S
2 ===================================================================
3 --- kernel-2.4.21.orig/arch/i386/kernel/entry.S 2003-06-13 07:51:29.000000000 -0700
4 +++ kernel-2.4.21/arch/i386/kernel/entry.S      2003-12-04 11:57:01.000000000 -0800
5 @@ -45,6 +45,7 @@
6  #include <linux/linkage.h>
7  #include <asm/segment.h>
8  #include <asm/smp.h>
9 +#include <asm/current.h>
10  
11  EBX            = 0x00
12  ECX            = 0x04
13 @@ -130,10 +131,6 @@
14         .long 3b,6b;    \
15  .previous
16  
17 -#define GET_CURRENT(reg) \
18 -       movl $-8192, reg; \
19 -       andl %esp, reg
20 -
21  ENTRY(lcall7)
22         pushfl                  # We get a different stack layout with call gates,
23         pushl %eax              # which has to be cleaned up later..
24 @@ -149,7 +146,7 @@
25         movl %ecx,CS(%esp)      #
26         movl %esp,%ebx
27         pushl %ebx
28 -       andl $-8192,%ebx        # GET_CURRENT
29 +       andl $-THREAD_SIZE,%ebx # GET_CURRENT
30         movl exec_domain(%ebx),%edx     # Get the execution domain
31         movl 4(%edx),%edx       # Get the lcall7 handler for the domain
32         pushl $0x7
33 @@ -173,7 +170,7 @@
34         movl %ecx,CS(%esp)      #
35         movl %esp,%ebx
36         pushl %ebx
37 -       andl $-8192,%ebx        # GET_CURRENT
38 +       andl $-THREAD_SIZE,%ebx # GET_CURRENT
39         movl exec_domain(%ebx),%edx     # Get the execution domain
40         movl 4(%edx),%edx       # Get the lcall7 handler for the domain
41         pushl $0x27
42 Index: kernel-2.4.21/arch/i386/kernel/smpboot.c
43 ===================================================================
44 --- kernel-2.4.21.orig/arch/i386/kernel/smpboot.c       2003-06-13 07:51:29.000000000 -0700
45 +++ kernel-2.4.21/arch/i386/kernel/smpboot.c    2003-12-04 11:57:01.000000000 -0800
46 @@ -819,7 +819,7 @@
47  
48         /* So we see what's up   */
49         printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
50 -       stack_start.esp = (void *) (1024 + PAGE_SIZE + (char *)idle);
51 +       stack_start.esp = (void *)idle->thread.esp;
52  
53         /*
54          * This grunge runs the startup process for
55 @@ -892,7 +892,7 @@
56                         Dprintk("CPU has booted.\n");
57                 } else {
58                         boot_error= 1;
59 -                       if (*((volatile unsigned char *)phys_to_virt(8192))
60 +                       if (*((volatile unsigned char *)phys_to_virt(THREAD_SIZE))
61                                         == 0xA5)
62                                 /* trampoline started but...? */
63                                 printk("Stuck ??\n");
64 @@ -915,7 +915,7 @@
65         }
66  
67         /* mark "stuck" area as not stuck */
68 -       *((volatile unsigned long *)phys_to_virt(8192)) = 0;
69 +       *((volatile unsigned long *)phys_to_virt(THREAD_SIZE)) = 0;
70  
71         if(clustered_apic_mode == CLUSTERED_APIC_NUMAQ) {
72                 printk("Restoring NMI vector\n");
73 Index: kernel-2.4.21/arch/i386/kernel/traps.c
74 ===================================================================
75 --- kernel-2.4.21.orig/arch/i386/kernel/traps.c 2002-11-28 15:53:09.000000000 -0800
76 +++ kernel-2.4.21/arch/i386/kernel/traps.c      2003-12-04 11:57:01.000000000 -0800
77 @@ -158,7 +158,7 @@
78         unsigned long esp = tsk->thread.esp;
79  
80         /* User space on another CPU? */
81 -       if ((esp ^ (unsigned long)tsk) & (PAGE_MASK<<1))
82 +       if ((esp ^ (unsigned long)tsk) & ~(THREAD_SIZE - 1))
83                 return;
84         show_trace((unsigned long *)esp);
85  }
86 Index: kernel-2.4.21/arch/i386/kernel/head.S
87 ===================================================================
88 --- kernel-2.4.21.orig/arch/i386/kernel/head.S  2003-06-13 07:51:29.000000000 -0700
89 +++ kernel-2.4.21/arch/i386/kernel/head.S       2003-12-04 11:57:01.000000000 -0800
90 @@ -15,6 +15,7 @@
91  #include <asm/page.h>
92  #include <asm/pgtable.h>
93  #include <asm/desc.h>
94 +#include <asm/current.h>
95  
96  #define OLD_CL_MAGIC_ADDR      0x90020
97  #define OLD_CL_MAGIC           0xA33F
98 @@ -320,7 +321,7 @@
99         ret
100  
101  ENTRY(stack_start)
102 -       .long SYMBOL_NAME(init_task_union)+8192
103 +       .long SYMBOL_NAME(init_task_union)+THREAD_SIZE
104         .long __KERNEL_DS
105  
106  /* This is the default interrupt "handler" :-) */
107 Index: kernel-2.4.21/arch/i386/kernel/irq.c
108 ===================================================================
109 --- kernel-2.4.21.orig/arch/i386/kernel/irq.c   2002-11-28 15:53:09.000000000 -0800
110 +++ kernel-2.4.21/arch/i386/kernel/irq.c        2003-12-04 11:57:01.000000000 -0800
111 @@ -581,7 +581,10 @@
112         long esp;
113  
114         /* Debugging check for stack overflow: is there less than 1KB free? */
115 -       __asm__ __volatile__("andl %%esp,%0" : "=r" (esp) : "0" (8191));
116 +       __asm__ __volatile__(
117 +               "andl %%esp,%0" 
118 +               : "=r" (esp) : "0" (THREAD_SIZE-1));
119 +
120         if (unlikely(esp < (sizeof(struct task_struct) + 1024))) {
121                 extern void show_stack(unsigned long *);
122  
123 Index: kernel-2.4.21/arch/i386/lib/getuser.S
124 ===================================================================
125 --- kernel-2.4.21.orig/arch/i386/lib/getuser.S  1998-01-12 13:42:52.000000000 -0800
126 +++ kernel-2.4.21/arch/i386/lib/getuser.S       2003-12-04 11:57:01.000000000 -0800
127 @@ -21,6 +21,10 @@
128   * as they get called from within inline assembly.
129   */
130  
131 +/* Duplicated from asm/processor.h */
132 +#include <asm/current.h>
133 +#include <linux/config.h>
134 +
135  addr_limit = 12
136  
137  .text
138 @@ -28,7 +32,7 @@
139  .globl __get_user_1
140  __get_user_1:
141         movl %esp,%edx
142 -       andl $0xffffe000,%edx
143 +       andl $~(THREAD_SIZE - 1),%edx
144         cmpl addr_limit(%edx),%eax
145         jae bad_get_user
146  1:     movzbl (%eax),%edx
147 @@ -41,7 +45,7 @@
148         addl $1,%eax
149         movl %esp,%edx
150         jc bad_get_user
151 -       andl $0xffffe000,%edx
152 +       andl $~(THREAD_SIZE - 1),%edx
153         cmpl addr_limit(%edx),%eax
154         jae bad_get_user
155  2:     movzwl -1(%eax),%edx
156 @@ -54,7 +58,7 @@
157         addl $3,%eax
158         movl %esp,%edx
159         jc bad_get_user
160 -       andl $0xffffe000,%edx
161 +       andl $~(THREAD_SIZE - 1),%edx
162         cmpl addr_limit(%edx),%eax
163         jae bad_get_user
164  3:     movl -3(%eax),%edx
165 Index: kernel-2.4.21/arch/i386/config.in
166 ===================================================================
167 --- kernel-2.4.21.orig/arch/i386/config.in      2003-06-13 07:51:29.000000000 -0700
168 +++ kernel-2.4.21/arch/i386/config.in   2003-12-04 11:57:01.000000000 -0800
169 @@ -256,6 +256,29 @@
170  if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then
171     define_bool CONFIG_HAVE_DEC_LOCK y
172  fi
173 +
174 +choice 'Bigger Stack Size Support' \
175 +     "off    CONFIG_NOBIGSTACK \
176 +      16KB   CONFIG_STACK_SIZE_16KB \
177 +      32KB   CONFIG_STACK_SIZE_32KB \
178 +      64KB   CONFIG_STACK_SIZE_64KB" off
179 +
180 +if [ "$CONFIG_NOBIGSTACK" = "y" ]; then
181 +   define_int CONFIG_STACK_SIZE_SHIFT 1
182 +else
183 +  if [ "$CONFIG_STACK_SIZE_16KB" = "y" ]; then
184 +     define_int CONFIG_STACK_SIZE_SHIFT 2
185 +  else
186 +    if [ "$CONFIG_STACK_SIZE_32KB" = "y" ]; then
187 +      define_int CONFIG_STACK_SIZE_SHIFT 3
188 +    else
189 +      if [ "$CONFIG_STACK_SIZE_64KB" = "y" ]; then
190 +        define_int CONFIG_STACK_SIZE_SHIFT 4
191 +      fi
192 +    fi
193 +  fi
194 +fi
195
196  endmenu
197  
198  mainmenu_option next_comment
199 Index: kernel-2.4.21/arch/i386/vmlinux.lds
200 ===================================================================
201 --- kernel-2.4.21.orig/arch/i386/vmlinux.lds.S  2002-02-25 11:37:53.000000000 -0800
202 +++ kernel-2.4.21/arch/i386/vmlinux.lds.S       2003-12-04 11:57:01.000000000 -0800
203 @@ -35,7 +35,8 @@
204  
205    _edata = .;                  /* End of data section */
206  
207 -  . = ALIGN(8192);             /* init_task */
208 +/* chose the biggest of the possible stack sizes here? */
209 +  . = ALIGN(65536);            /* init_task */
210    .data.init_task : { *(.data.init_task) }
211  
212    . = ALIGN(4096);             /* Init code and data */
213 Index: kernel-2.4.21/include/asm-i386/current.h
214 ===================================================================
215 --- kernel-2.4.21.orig/include/asm-i386/current.h       1998-08-14 16:35:22.000000000 -0700
216 +++ kernel-2.4.21/include/asm-i386/current.h    2003-12-04 11:57:01.000000000 -0800
217 @@ -1,15 +1,43 @@
218  #ifndef _I386_CURRENT_H
219  #define _I386_CURRENT_H
220 +#include <asm/page.h>
221 +
222 +/*
223 + * Configurable page sizes on i386, mainly for debugging purposes.
224 + * (c) Balbir Singh
225 + */
226 +
227 +#ifdef __ASSEMBLY__
228 +
229 +#define PAGE_SIZE      4096    /* as cannot handle 1UL << 12 */
230 +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE)
231 +
232 +#define GET_CURRENT(reg) \
233 +        movl $-THREAD_SIZE, reg; \
234 +        andl %esp, reg
235 +
236 +#else  /* __ASSEMBLY__ */
237 +
238 +#define THREAD_SIZE ((1 << CONFIG_STACK_SIZE_SHIFT) * PAGE_SIZE)
239 +#define alloc_task_struct() \
240 +  ((struct task_struct *) __get_free_pages(GFP_KERNEL,CONFIG_STACK_SIZE_SHIFT))
241 +
242 +#define free_task_struct(p) \
243 +  free_pages((unsigned long) (p), CONFIG_STACK_SIZE_SHIFT)
244 +
245 +#define INIT_TASK_SIZE THREAD_SIZE
246  
247  struct task_struct;
248  
249  static inline struct task_struct * get_current(void)
250  {
251         struct task_struct *current;
252 -       __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
253 +       __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~(THREAD_SIZE - 1)));
254         return current;
255   }
256   
257  #define current get_current()
258  
259 +#endif /* __ASSEMBLY__ */
260 +
261  #endif /* !(_I386_CURRENT_H) */
262 Index: kernel-2.4.21/include/asm-i386/hw_irq.h
263 ===================================================================
264 --- kernel-2.4.21.orig/include/asm-i386/hw_irq.h        2001-11-22 11:46:18.000000000 -0800
265 +++ kernel-2.4.21/include/asm-i386/hw_irq.h     2003-12-04 11:57:01.000000000 -0800
266 @@ -15,6 +15,7 @@
267  #include <linux/config.h>
268  #include <asm/atomic.h>
269  #include <asm/irq.h>
270 +#include <asm/current.h>
271  
272  /*
273   * IDT vectors usable for external interrupt sources start
274 @@ -113,10 +114,6 @@
275  #define IRQ_NAME2(nr) nr##_interrupt(void)
276  #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr)
277  
278 -#define GET_CURRENT \
279 -       "movl %esp, %ebx\n\t" \
280 -       "andl $-8192, %ebx\n\t"
281 -
282  /*
283   *     SMP has a few special interrupts for IPI messages
284   */
285 Index: kernel-2.4.21/include/asm-i386/processor.h
286 ===================================================================
287 --- kernel-2.4.21.orig/include/asm-i386/processor.h     2003-06-13 07:51:38.000000000 -0700
288 +++ kernel-2.4.21/include/asm-i386/processor.h  2003-12-04 11:57:01.000000000 -0800
289 @@ -14,6 +14,7 @@
290  #include <asm/types.h>
291  #include <asm/sigcontext.h>
292  #include <asm/cpufeature.h>
293 +#include <asm/current.h>
294  #include <linux/cache.h>
295  #include <linux/config.h>
296  #include <linux/threads.h>
297 @@ -453,9 +454,6 @@
298  #define KSTK_EIP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)))[1019])
299  #define KSTK_ESP(tsk)  (((unsigned long *)(4096+(unsigned long)(tsk)))[1022])
300  
301 -#define THREAD_SIZE (2*PAGE_SIZE)
302 -#define alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
303 -#define free_task_struct(p) free_pages((unsigned long) (p), 1)
304  #define get_task_struct(tsk)      atomic_inc(&virt_to_page(tsk)->count)
305  
306  #define init_task      (init_task_union.task)
307 Index: kernel-2.4.21/include/linux/sched.h
308 ===================================================================
309 --- kernel-2.4.21.orig/include/linux/sched.h    2003-06-13 15:26:52.000000000 -0700
310 +++ kernel-2.4.21/include/linux/sched.h 2003-12-04 12:00:14.000000000 -0800
311 @@ -2,6 +2,7 @@
312  #define _LINUX_SCHED_H
313  
314  #include <asm/param.h> /* for HZ */
315 +#include <asm/current.h>       /* maybe for INIT_TASK_SIZE */
316  
317  extern unsigned long event;
318