diff --git a/executer/include/uprotocol.h b/executer/include/uprotocol.h index 5bd5ddc0..ea0ba357 100644 --- a/executer/include/uprotocol.h +++ b/executer/include/uprotocol.h @@ -110,6 +110,8 @@ typedef unsigned long __cpu_set_unit; #define MPOL_NO_BSS 0x04 #define MPOL_SHM_PREMAP 0x08 +#define MCEXEC_HFI1 0x01 + struct program_load_desc { int num_sections; int status; @@ -138,6 +140,7 @@ struct program_load_desc { unsigned long envs_len; struct rlimit rlimit[MCK_RLIM_MAX]; unsigned long interp_align; + unsigned long mcexec_flags; unsigned long mpol_flags; unsigned long mpol_threshold; unsigned long heap_extension; diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 7fe97940..775aaa3a 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -221,6 +221,7 @@ static int mpol_no_stack = 0; static int mpol_no_bss = 0; static int mpol_shm_premap = 0; static int no_bind_ikc_map = 0; +static int hfi1_enabled = 0; static unsigned long mpol_threshold = 0; static unsigned long heap_extension = (4*1024); static int profile = 0; @@ -1753,6 +1754,12 @@ static struct option mcexec_options[] = { .flag = &disable_sched_yield, .val = 1, }, + { + .name = "enable-hfi1", + .has_arg = no_argument, + .flag = &hfi1_enabled, + .val = 1, + }, { .name = "extend-heap-by", .has_arg = required_argument, @@ -2535,6 +2542,11 @@ int main(int argc, char **argv) } } + desc->mcexec_flags = 0; + if (hfi1_enabled) { + desc->mcexec_flags |= MCEXEC_HFI1; + } + if (ioctl(fd, MCEXEC_UP_PREPARE_IMAGE, (unsigned long)desc) != 0) { perror("prepare"); close(fd); diff --git a/kernel/host.c b/kernel/host.c index 77ff420e..fbfa3469 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -479,6 +479,7 @@ static int process_msg_prepare_process(unsigned long rphys) proc->sgid = pn->cred[6]; proc->fsgid = pn->cred[7]; proc->termsig = SIGCHLD; + proc->mcexec_flags = pn->mcexec_flags; proc->mpol_flags = pn->mpol_flags; proc->mpol_threshold = pn->mpol_threshold; proc->nr_processes = pn->nr_processes; diff --git a/kernel/include/process.h b/kernel/include/process.h index 39f6992a..5b8d4679 100644 --- a/kernel/include/process.h +++ b/kernel/include/process.h @@ -552,6 +552,7 @@ struct process { long maxrss; long maxrss_children; + unsigned long mcexec_flags; /* Memory policy flags and memory specific options */ unsigned long mpol_flags; size_t mpol_threshold; diff --git a/kernel/include/syscall.h b/kernel/include/syscall.h index eadf7e8d..6946f50e 100644 --- a/kernel/include/syscall.h +++ b/kernel/include/syscall.h @@ -166,6 +166,8 @@ typedef unsigned long __cpu_set_unit; #define MPOL_NO_BSS 0x04 #define MPOL_SHM_PREMAP 0x08 +#define MCEXEC_HFI1 0x01 + struct program_load_desc { int num_sections; int status; @@ -194,6 +196,7 @@ struct program_load_desc { unsigned long envs_len; struct rlimit rlimit[MCK_RLIM_MAX]; unsigned long interp_align; + unsigned long mcexec_flags; unsigned long mpol_flags; unsigned long mpol_threshold; unsigned long heap_extension; diff --git a/kernel/syscall.c b/kernel/syscall.c index b353d2b2..a615864f 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -481,7 +481,8 @@ long do_syscall(struct syscall_request *req, int cpu, int pid) #endif // PROFILE_ENABLE if (req->number == __NR_open && rc > 0) { - if (res.private_data && + if ((cpu_local_var(current)->proc->mcexec_flags & MCEXEC_HFI1) && + res.private_data && !strncmp((const char *)req->args[0], "/dev/hfi", 8)) { extern void hfi1_txreq_prealloc(void);