feat: make preemption toggle runtime config

main
Sean McBride 4 years ago
parent cfd97947b0
commit 3f18cf0cfc

@ -85,9 +85,6 @@ CFLAGS += -D${ARCH}
CFLAGS += -DNCORES=${TOTAL_CORES}
CFLAGS += -DPAGE_SIZE=$(PAGE_SIZE)
# Optionally Disable preemption
# CFLAGS += -DPREEMPT_DISABLE
# Sandboxes running on Sledge always use WebAssembly linear memory
CFLAGS += -DUSE_MEM_VM

@ -90,3 +90,4 @@ print_runtime_scheduler(enum RUNTIME_SCHEDULER variant)
};
extern enum RUNTIME_SCHEDULER runtime_scheduler;
extern bool runtime_preemption_enabled;

@ -40,6 +40,9 @@ FILE *runtime_sandbox_perf_log = NULL;
enum RUNTIME_SCHEDULER runtime_scheduler = RUNTIME_SCHEDULER_FIFO;
int runtime_worker_core_count;
bool runtime_preemption_enabled = true;
/**
* Returns instructions on use of CLI if used incorrectly
* @param cmd - The command the user entered
@ -213,6 +216,11 @@ runtime_configure()
}
printf("\tScheduler Policy: %s\n", print_runtime_scheduler(runtime_scheduler));
/* Runtime Preemption Toggle */
char *preempt_disable = getenv("SLEDGE_DISABLE_PREEMPTION");
if (preempt_disable != NULL && strcmp(preempt_disable, "false") != 0) runtime_preemption_enabled = false;
printf("\tPreemption: %s\n", runtime_preemption_enabled ? "Enabled" : "Disabled");
/* Runtime Perf Log */
char *runtime_sandbox_perf_log_path = getenv("SLEDGE_SANDBOX_PERF_LOG");
if (runtime_sandbox_perf_log_path != NULL) {

@ -165,9 +165,9 @@ software_interrupt_validate_worker()
static inline void
software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void *user_context_raw)
{
#ifdef PREEMPT_DISABLE
panic("Unexpectedly invoked signal handlers when PREEMPT_DISABLE set\n");
#else
if (unlikely(!runtime_preemption_enabled)) {
panic("Unexpectedly invoked signal handlers with preemption disabled\n");
}
software_interrupt_validate_worker();
@ -190,7 +190,6 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
}
}
}
#endif
}
/********************
@ -203,7 +202,8 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
void
software_interrupt_arm_timer(void)
{
#ifndef PREEMPT_DISABLE
if (!runtime_preemption_enabled) return;
struct itimerval interval_timer;
memset(&interval_timer, 0, sizeof(struct itimerval));
@ -215,7 +215,6 @@ software_interrupt_arm_timer(void)
perror("setitimer");
exit(1);
}
#endif
}
/**

@ -317,10 +317,11 @@ worker_thread_main(void *return_code)
/* Unmask signals */
#ifndef PREEMPT_DISABLE
software_interrupt_unmask_signal(SIGALRM);
software_interrupt_unmask_signal(SIGUSR1);
#endif
if (runtime_preemption_enabled) {
software_interrupt_unmask_signal(SIGALRM);
software_interrupt_unmask_signal(SIGUSR1);
}
signal(SIGPIPE, SIG_IGN);
/* Initialize epoll */

Loading…
Cancel
Save