mcexec: Add --stack-premap=<premap_size>[,<max>]

<premap_size> of stack is pre-mapped on creating a process.
And its max size of stack is set to <max>.
This replaces MCKERNEL_RLIMIT_STACK=<premap_size>,<max>.
This commit is contained in:
Masamichi Takagi
2017-09-26 16:49:40 +09:00
parent c43c1b640a
commit be4d84c0c1
5 changed files with 67 additions and 16 deletions

View File

@@ -497,6 +497,11 @@ static int process_msg_prepare_process(unsigned long rphys)
}
vm->region.map_end = vm->region.map_start;
memcpy(proc->rlimit, pn->rlimit, sizeof(struct rlimit) * MCK_RLIM_MAX);
dkprintf("%s: rlim_cur: %ld, rlim_max: %ld, stack_premap: %ld\n",
__FUNCTION__,
proc->rlimit[MCK_RLIMIT_STACK].rlim_cur,
proc->rlimit[MCK_RLIMIT_STACK].rlim_max,
pn->stack_premap);
if (prepare_process_ranges_args_envs(thread, pn, p, attr,
NULL, 0, NULL, 0) != 0) {

View File

@@ -197,6 +197,7 @@ struct program_load_desc {
unsigned long mpol_flags;
unsigned long mpol_threshold;
unsigned long heap_extension;
long stack_premap;
int nr_processes;
char shell_path[SHELL_PATH_MAX_LEN];
__cpu_set_unit cpu_set[PLD_CPU_SET_SIZE];

View File

@@ -2089,15 +2089,16 @@ int init_process_stack(struct thread *thread, struct program_load_desc *pn,
#ifdef POSTK_DEBUG_ARCH_DEP_80 /* user stack prepage size fix */
minsz = LARGE_PAGE_SIZE;
#else /* POSTK_DEBUG_ARCH_DEP_80 */
minsz = (proc->rlimit[MCK_RLIMIT_STACK].rlim_cur
minsz = (pn->stack_premap
+ LARGE_PAGE_SIZE - 1) & LARGE_PAGE_MASK;
#endif /* POSTK_DEBUG_ARCH_DEP_80 */
size = (proc->rlimit[MCK_RLIMIT_STACK].rlim_max
size = (proc->rlimit[MCK_RLIMIT_STACK].rlim_cur
+ LARGE_PAGE_SIZE - 1) & LARGE_PAGE_MASK;
dkprintf("%s: rlim_max: %lu, rlim_cur: %lu\n",
dkprintf("%s: stack_premap: %lu, rlim_cur: %lu, minsz: %lu, size: %lu\n",
__FUNCTION__,
proc->rlimit[MCK_RLIMIT_STACK].rlim_max,
proc->rlimit[MCK_RLIMIT_STACK].rlim_cur);
pn->stack_premap,
proc->rlimit[MCK_RLIMIT_STACK].rlim_cur,
minsz, size);
if (size > (USER_END / 2)) {
size = USER_END / 2;
}