mcexec/mm: user memory policy control for heap, stack, etc.

This commit is contained in:
Balazs Gerofi
2017-02-07 04:28:31 +09:00
parent afb7cb3a1e
commit 182202523e
7 changed files with 59 additions and 7 deletions

View File

@ -154,6 +154,9 @@ static char *altroot;
static const char rlimit_stack_envname[] = "MCKERNEL_RLIMIT_STACK";
static int ischild;
static int enable_vdso = 1;
static int mpol_no_heap = 0;
static int mpol_no_stack = 0;
static int mpol_no_bss = 0;
/* Partitioned execution (e.g., for MPI) */
static int nr_processes = 0;
@ -1279,7 +1282,24 @@ static struct option mcexec_options[] = {
.flag = &enable_vdso,
.val = 1,
},
{
.name = "mpol-no-heap",
.has_arg = no_argument,
.flag = &mpol_no_heap,
.val = 1,
},
{
.name = "mpol-no-stack",
.has_arg = no_argument,
.flag = &mpol_no_stack,
.val = 1,
},
{
.name = "mpol-no-bss",
.has_arg = no_argument,
.flag = &mpol_no_bss,
.val = 1,
},
/* end */
{ NULL, 0, NULL, 0, },
};
@ -1669,6 +1689,19 @@ int main(int argc, char **argv)
#endif
}
desc->mpol_flags = 0;
if (mpol_no_heap) {
desc->mpol_flags |= MPOL_NO_HEAP;
}
if (mpol_no_stack) {
desc->mpol_flags |= MPOL_NO_STACK;
}
if (mpol_no_bss) {
desc->mpol_flags |= MPOL_NO_BSS;
}
if (ioctl(fd, MCEXEC_UP_PREPARE_IMAGE, (unsigned long)desc) != 0) {
perror("prepare");
close(fd);