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

@@ -92,6 +92,10 @@ struct get_cpu_set_arg {
typedef unsigned long __cpu_set_unit;
#define PLD_CPU_SET_SIZE (PLD_CPU_SET_MAX_CPUS / (8 * sizeof(__cpu_set_unit)))
#define MPOL_NO_HEAP 0x01
#define MPOL_NO_STACK 0x02
#define MPOL_NO_BSS 0x04
struct program_load_desc {
int num_sections;
int status;
@@ -120,6 +124,7 @@ struct program_load_desc {
unsigned long envs_len;
struct rlimit rlimit[MCK_RLIM_MAX];
unsigned long interp_align;
unsigned long mpol_flags;
char shell_path[SHELL_PATH_MAX_LEN];
__cpu_set_unit cpu_set[PLD_CPU_SET_SIZE];
struct program_image_section sections[0];

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);