parisc: Make user stack size configurable
On parisc we need to initialize the memory layout for the user stack at process start time to a fixed size, which up until now was limited to the size as given by CONFIG_MAX_STACK_SIZE_MB at compile time. This hard limit was too small and showed problems when compiling ruby2.7, qmlcachegen and some Qt packages. This patch changes two things: a) It increases the default maximum stack size to 100MB. b) Users can modify the stack hard limit size with ulimit and then newly forked processes will use the given stack size which can even be bigger than the default 100MB. Reported-by: John David Anglin <dave.anglin@bell.net> Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
Родитель
c984baad3d
Коммит
22ee3ea588
|
@ -45,15 +45,12 @@
|
|||
#define STACK_TOP TASK_SIZE
|
||||
#define STACK_TOP_MAX DEFAULT_TASK_SIZE
|
||||
|
||||
/* Allow bigger stacks for 64-bit processes */
|
||||
#define STACK_SIZE_MAX (USER_WIDE_MODE \
|
||||
? (1 << 30) /* 1 GB */ \
|
||||
: (CONFIG_MAX_STACK_SIZE_MB*1024*1024))
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
unsigned long calc_max_stack_size(unsigned long stack_max);
|
||||
|
||||
/*
|
||||
* Data detected about CPUs at boot time which is the same for all CPU's.
|
||||
* HP boxes are SMP - ie identical processors.
|
||||
|
|
|
@ -53,6 +53,25 @@ static inline unsigned long COLOR_ALIGN(unsigned long addr,
|
|||
return base + off;
|
||||
}
|
||||
|
||||
|
||||
#define STACK_SIZE_DEFAULT (USER_WIDE_MODE \
|
||||
? (1 << 30) /* 1 GB */ \
|
||||
: (CONFIG_STACK_MAX_DEFAULT_SIZE_MB*1024*1024))
|
||||
|
||||
unsigned long calc_max_stack_size(unsigned long stack_max)
|
||||
{
|
||||
#ifdef CONFIG_COMPAT
|
||||
if (!USER_WIDE_MODE && (stack_max == COMPAT_RLIM_INFINITY))
|
||||
stack_max = STACK_SIZE_DEFAULT;
|
||||
else
|
||||
#endif
|
||||
if (stack_max == RLIM_INFINITY)
|
||||
stack_max = STACK_SIZE_DEFAULT;
|
||||
|
||||
return stack_max;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Top of mmap area (just below the process stack).
|
||||
*/
|
||||
|
@ -69,8 +88,8 @@ static unsigned long mmap_upper_limit(struct rlimit *rlim_stack)
|
|||
/* Limit stack size - see setup_arg_pages() in fs/exec.c */
|
||||
stack_base = rlim_stack ? rlim_stack->rlim_max
|
||||
: rlimit_max(RLIMIT_STACK);
|
||||
if (stack_base > STACK_SIZE_MAX)
|
||||
stack_base = STACK_SIZE_MAX;
|
||||
|
||||
stack_base = calc_max_stack_size(stack_base);
|
||||
|
||||
/* Add space for stack randomization. */
|
||||
if (current->flags & PF_RANDOMIZE)
|
||||
|
|
|
@ -756,8 +756,8 @@ int setup_arg_pages(struct linux_binprm *bprm,
|
|||
#ifdef CONFIG_STACK_GROWSUP
|
||||
/* Limit stack size */
|
||||
stack_base = bprm->rlim_stack.rlim_max;
|
||||
if (stack_base > STACK_SIZE_MAX)
|
||||
stack_base = STACK_SIZE_MAX;
|
||||
|
||||
stack_base = calc_max_stack_size(stack_base);
|
||||
|
||||
/* Add space for stack randomization. */
|
||||
stack_base += (STACK_RND_MASK << PAGE_SHIFT);
|
||||
|
|
12
mm/Kconfig
12
mm/Kconfig
|
@ -733,19 +733,17 @@ config ZSMALLOC_STAT
|
|||
config GENERIC_EARLY_IOREMAP
|
||||
bool
|
||||
|
||||
config MAX_STACK_SIZE_MB
|
||||
int "Maximum user stack size for 32-bit processes (MB)"
|
||||
default 80
|
||||
config STACK_MAX_DEFAULT_SIZE_MB
|
||||
int "Default maximum user stack size for 32-bit processes (MB)"
|
||||
default 100
|
||||
range 8 2048
|
||||
depends on STACK_GROWSUP && (!64BIT || COMPAT)
|
||||
help
|
||||
This is the maximum stack size in Megabytes in the VM layout of 32-bit
|
||||
user processes when the stack grows upwards (currently only on parisc
|
||||
arch). The stack will be located at the highest memory address minus
|
||||
the given value, unless the RLIMIT_STACK hard limit is changed to a
|
||||
smaller value in which case that is used.
|
||||
arch) when the RLIMIT_STACK hard limit is unlimited.
|
||||
|
||||
A sane initial value is 80 MB.
|
||||
A sane initial value is 100 MB.
|
||||
|
||||
config DEFERRED_STRUCT_PAGE_INIT
|
||||
bool "Defer initialisation of struct pages to kthreads"
|
||||
|
|
Загрузка…
Ссылка в новой задаче