diff options
author | Richard Henderson <rth@twiddle.net> | 2010-03-19 14:21:13 -0700 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2010-03-27 14:16:51 +0100 |
commit | 703e0e89c669a70bbd6bf33c5e75f910d8d8cca3 (patch) | |
tree | 53180583a5e0d4f84fafb2ddee1de2ddb640ba6b /linux-user/main.c | |
parent | 3ad493fc5ea38c005670adc5933058a28ccabdd4 (diff) |
linux-user: Use RLIMIT_STACK for default stack size.
The current default stack limit of 512kB is far too small; a fair
number of gcc testsuite failures (for all guests) are directly
attributable to this. Using the -s option in every invocation of
the emulator is annoying to say the least.
A reasonable compromise seems to be to honor the system rlimit.
At least on two Linux distributions, this is set to 8MB and 10MB
respectively. If the system does not limit the stack, then we're
no worse off than before.
At the same time, rename the variable from x86_stack_size and
change the ultimate fallback size from 512kB to 8MB.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r-- | linux-user/main.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/linux-user/main.c b/linux-user/main.c index 4614e3c9f9..e5ff8a908d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -24,6 +24,7 @@ #include <unistd.h> #include <sys/mman.h> #include <sys/syscall.h> +#include <sys/resource.h> #include "qemu.h" #include "qemu-common.h" @@ -51,7 +52,7 @@ const char *qemu_uname_release = CONFIG_UNAME_RELEASE; /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so we allocate a bigger stack. Need a better solution, for example by remapping the process stack directly at the right place */ -unsigned long x86_stack_size = 512 * 1024; +unsigned long guest_stack_size = 8 * 1024 * 1024UL; void gemu_log(const char *fmt, ...) { @@ -2560,7 +2561,7 @@ static void usage(void) , TARGET_ARCH, interp_prefix, - x86_stack_size, + guest_stack_size, DEBUG_LOGFILE); exit(1); } @@ -2639,6 +2640,16 @@ int main(int argc, char **argv, char **envp) (void) envlist_setenv(envlist, *wrk); } + /* Read the stack limit from the kernel. If it's "unlimited", + then we can do little else besides use the default. */ + { + struct rlimit lim; + if (getrlimit(RLIMIT_STACK, &lim) == 0 + && lim.rlim_cur != RLIM_INFINITY) { + guest_stack_size = lim.rlim_cur; + } + } + cpu_model = NULL; #if defined(cpudef_setup) cpudef_setup(); /* parse cpu definitions in target config file (TBD) */ @@ -2687,13 +2698,13 @@ int main(int argc, char **argv, char **envp) if (optind >= argc) break; r = argv[optind++]; - x86_stack_size = strtol(r, (char **)&r, 0); - if (x86_stack_size <= 0) + guest_stack_size = strtoul(r, (char **)&r, 0); + if (guest_stack_size == 0) usage(); if (*r == 'M') - x86_stack_size *= 1024 * 1024; + guest_stack_size *= 1024 * 1024; else if (*r == 'k' || *r == 'K') - x86_stack_size *= 1024; + guest_stack_size *= 1024; } else if (!strcmp(r, "L")) { interp_prefix = argv[optind++]; } else if (!strcmp(r, "p")) { |