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 += -DNCORES=${TOTAL_CORES}
CFLAGS += -DPAGE_SIZE=$(PAGE_SIZE) CFLAGS += -DPAGE_SIZE=$(PAGE_SIZE)
# Optionally Disable preemption
# CFLAGS += -DPREEMPT_DISABLE
# Sandboxes running on Sledge always use WebAssembly linear memory # Sandboxes running on Sledge always use WebAssembly linear memory
CFLAGS += -DUSE_MEM_VM CFLAGS += -DUSE_MEM_VM

@ -90,3 +90,4 @@ print_runtime_scheduler(enum RUNTIME_SCHEDULER variant)
}; };
extern enum RUNTIME_SCHEDULER runtime_scheduler; 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; enum RUNTIME_SCHEDULER runtime_scheduler = RUNTIME_SCHEDULER_FIFO;
int runtime_worker_core_count; int runtime_worker_core_count;
bool runtime_preemption_enabled = true;
/** /**
* Returns instructions on use of CLI if used incorrectly * Returns instructions on use of CLI if used incorrectly
* @param cmd - The command the user entered * @param cmd - The command the user entered
@ -213,6 +216,11 @@ runtime_configure()
} }
printf("\tScheduler Policy: %s\n", print_runtime_scheduler(runtime_scheduler)); 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 */ /* Runtime Perf Log */
char *runtime_sandbox_perf_log_path = getenv("SLEDGE_SANDBOX_PERF_LOG"); char *runtime_sandbox_perf_log_path = getenv("SLEDGE_SANDBOX_PERF_LOG");
if (runtime_sandbox_perf_log_path != NULL) { if (runtime_sandbox_perf_log_path != NULL) {

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

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

Loading…
Cancel
Save