The patch titled uml: stack usage reduction has been added to the -mm tree. Its filename is uml-stack-usage-reduction.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: uml: stack usage reduction From: Jeff Dike <jdike@xxxxxxxxxxx> The KSTK_* macros used an inordinate amount of stack. In order to overcome an impedance mismatch between their interface, which just returns a single register value, and the interface of get_thread_regs, which took a full pt_regs, the implementation created an on-stack pt_regs, filled it in, and returned one field. do_task_stat calls KSTK_* twice, resulting in two local pt_regs, blowing out the stack. This patch changes the interface (and name) of get_thread_regs to just return a single register from a jmp_buf. The include of archsetjmp.h" in registers.h to get the definition of jmp_buf exposed a bogus include of <setjmp.h> in start_up.c. <setjmp.h> shouldn't be used anywhere any more since UML uses the klibc setjmp/longjmp. Signed-off-by: Jeff Dike <jdike@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- arch/um/include/registers.h | 3 ++- arch/um/os-Linux/start_up.c | 1 - arch/um/os-Linux/sys-i386/registers.c | 15 +++++++++------ arch/um/os-Linux/sys-x86_64/registers.c | 15 +++++++++------ include/asm-um/processor-generic.h | 4 +--- 5 files changed, 21 insertions(+), 17 deletions(-) diff -puN arch/um/include/registers.h~uml-stack-usage-reduction arch/um/include/registers.h --- a/arch/um/include/registers.h~uml-stack-usage-reduction +++ a/arch/um/include/registers.h @@ -7,6 +7,7 @@ #define __REGISTERS_H #include "sysdep/ptrace.h" +#include "sysdep/archsetjmp.h" extern void init_thread_registers(union uml_pt_regs *to); extern int save_fp_registers(int pid, unsigned long *fp_regs); @@ -15,6 +16,6 @@ extern void save_registers(int pid, unio extern void restore_registers(int pid, union uml_pt_regs *regs); extern void init_registers(int pid); extern void get_safe_registers(unsigned long * regs, unsigned long * fp_regs); -extern void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer); +extern unsigned long get_thread_reg(int reg, jmp_buf *buf); #endif diff -puN arch/um/os-Linux/start_up.c~uml-stack-usage-reduction arch/um/os-Linux/start_up.c --- a/arch/um/os-Linux/start_up.c~uml-stack-usage-reduction +++ a/arch/um/os-Linux/start_up.c @@ -14,7 +14,6 @@ #include <sched.h> #include <fcntl.h> #include <errno.h> -#include <setjmp.h> #include <sys/time.h> #include <sys/wait.h> #include <sys/mman.h> diff -puN arch/um/os-Linux/sys-i386/registers.c~uml-stack-usage-reduction arch/um/os-Linux/sys-i386/registers.c --- a/arch/um/os-Linux/sys-i386/registers.c~uml-stack-usage-reduction +++ a/arch/um/os-Linux/sys-i386/registers.c @@ -130,11 +130,14 @@ void get_safe_registers(unsigned long *r HOST_FP_SIZE * sizeof(unsigned long)); } -void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer) +unsigned long get_thread_reg(int reg, jmp_buf *buf) { - struct __jmp_buf *jmpbuf = buffer; - - UPT_SET(uml_regs, EIP, jmpbuf->__eip); - UPT_SET(uml_regs, UESP, jmpbuf->__esp); - UPT_SET(uml_regs, EBP, jmpbuf->__ebp); + switch(reg){ + case EIP: return buf[0]->__eip; + case UESP: return buf[0]->__esp; + case EBP: return buf[0]->__ebp; + default: + printk("get_thread_regs - unknown register %d\n", reg); + return 0; + } } diff -puN arch/um/os-Linux/sys-x86_64/registers.c~uml-stack-usage-reduction arch/um/os-Linux/sys-x86_64/registers.c --- a/arch/um/os-Linux/sys-x86_64/registers.c~uml-stack-usage-reduction +++ a/arch/um/os-Linux/sys-x86_64/registers.c @@ -78,11 +78,14 @@ void get_safe_registers(unsigned long *r HOST_FP_SIZE * sizeof(unsigned long)); } -void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer) +unsigned long get_thread_reg(int reg, jmp_buf *buf) { - struct __jmp_buf *jmpbuf = buffer; - - UPT_SET(uml_regs, RIP, jmpbuf->__rip); - UPT_SET(uml_regs, RSP, jmpbuf->__rsp); - UPT_SET(uml_regs, RBP, jmpbuf->__rbp); + switch(reg){ + case RIP: return buf[0]->__rip; + case RSP: return buf[0]->__rsp; + case RBP: return buf[0]->__rbp; + default: + printk("get_thread_regs - unknown register %d\n", reg); + return 0; + } } diff -puN include/asm-um/processor-generic.h~uml-stack-usage-reduction include/asm-um/processor-generic.h --- a/include/asm-um/processor-generic.h~uml-stack-usage-reduction +++ a/include/asm-um/processor-generic.h @@ -138,9 +138,7 @@ extern struct cpuinfo_um cpu_data[]; #ifdef CONFIG_MODE_SKAS #define KSTK_REG(tsk, reg) \ - ({ union uml_pt_regs regs; \ - get_thread_regs(®s, tsk->thread.mode.skas.switch_buf); \ - UPT_REG(®s, reg); }) + get_thread_reg(reg, tsk->thread.mode.skas.switch_buf) #else #define KSTK_REG(tsk, reg) (0xbadbabe) #endif _ Patches currently in -mm which might be from jdike@xxxxxxxxxxx are fix-x86_64-mm-i386-semaphore-to-asm-uml-fix.patch reduce-max_nr_zones-make-zone_highmem-optional-fix-fix-fix.patch split-i386-and-x86_64-ptraceh.patch uml-use-ptrace-abih-instead-of-ptraceh.patch uml-use-klibc-setjmp-longjmp.patch uml-use-array_size-more-assiduously.patch uml-fix-stack-alignment.patch uml-whitespace-fixes.patch uml-fix-handling-of-failed-execs-of-helpers.patch uml-improve-sigbus-diagnostics.patch uml-sigio-cleanups.patch uml-move-signal-handlers-to-arch-code.patch uml-move-signal-handlers-to-arch-code-fix.patch uml-timer-cleanups.patch uml-remove-unused-variable.patch uml-clean-our-set_ether_mac.patch uml-stack-usage-reduction.patch uml-use-mcmodel=kernel-for-x86_64.patch uml-fix-proc-vs-interrupt-context-spinlock-deadlock.patch uml-remove-pte_mkexec.patch namespaces-utsname-switch-to-using-uts-namespaces-uml-fix.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html