|
|
@ -9,6 +9,12 @@
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_TO_FILE
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include "debuglog.h"
|
|
|
|
#include "debuglog.h"
|
|
|
|
#include "module.h"
|
|
|
|
#include "module.h"
|
|
|
|
#include "panic.h"
|
|
|
|
#include "panic.h"
|
|
|
@ -81,7 +87,7 @@ runtime_allocate_available_cores()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Find the number of processors currently online */
|
|
|
|
/* Find the number of processors currently online */
|
|
|
|
runtime_total_online_processors = sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|
runtime_total_online_processors = sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|
printf("Detected %u cores\n", runtime_total_online_processors);
|
|
|
|
printf("\tCore Count: %u\n", runtime_total_online_processors);
|
|
|
|
uint32_t max_possible_workers = runtime_total_online_processors - 1;
|
|
|
|
uint32_t max_possible_workers = runtime_total_online_processors - 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (runtime_total_online_processors < 2) panic("Runtime requires at least two cores!");
|
|
|
|
if (runtime_total_online_processors < 2) panic("Runtime requires at least two cores!");
|
|
|
@ -98,8 +104,9 @@ runtime_allocate_available_cores()
|
|
|
|
runtime_worker_threads_count = max_possible_workers;
|
|
|
|
runtime_worker_threads_count = max_possible_workers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
printf("Running one listener core at ID %u and %u worker core(s) starting at ID %u\n", LISTENER_THREAD_CORE_ID,
|
|
|
|
printf("\tListener core ID: %u\n", LISTENER_THREAD_CORE_ID);
|
|
|
|
runtime_worker_threads_count, runtime_first_worker_processor);
|
|
|
|
printf("\tFirst Worker core ID: %u\n", runtime_first_worker_processor);
|
|
|
|
|
|
|
|
printf("\tWorker core count: %u\n", runtime_worker_threads_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -205,39 +212,155 @@ runtime_configure()
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
panic("Invalid scheduler policy: %s. Must be {EDF|FIFO}\n", scheduler_policy);
|
|
|
|
panic("Invalid scheduler policy: %s. Must be {EDF|FIFO}\n", scheduler_policy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("Scheduler Policy: %s\n", print_runtime_scheduler(runtime_scheduler));
|
|
|
|
printf("\tScheduler Policy: %s\n", print_runtime_scheduler(runtime_scheduler));
|
|
|
|
|
|
|
|
|
|
|
|
/* 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) {
|
|
|
|
printf("Logging Sandbox Performance to: %s\n", runtime_sandbox_perf_log_path);
|
|
|
|
printf("\tSandbox Performance Log: %s\n", runtime_sandbox_perf_log_path);
|
|
|
|
runtime_sandbox_perf_log = fopen(runtime_sandbox_perf_log_path, "w");
|
|
|
|
runtime_sandbox_perf_log = fopen(runtime_sandbox_perf_log_path, "w");
|
|
|
|
if (runtime_sandbox_perf_log == NULL) { perror("sandbox perf log"); }
|
|
|
|
if (runtime_sandbox_perf_log == NULL) { perror("sandbox perf log"); }
|
|
|
|
fprintf(runtime_sandbox_perf_log, "id,function,state,deadline,actual,queued,initializing,runnable,"
|
|
|
|
fprintf(runtime_sandbox_perf_log, "id,function,state,deadline,actual,queued,initializing,runnable,"
|
|
|
|
"running,blocked,returned,memory\n");
|
|
|
|
"running,blocked,returned,memory\n");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
printf("\tSandbox Performance Log: Disabled\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
log_compiletime_config()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Static Compiler Flags:\n");
|
|
|
|
|
|
|
|
#ifdef ADMISSIONS_CONTROL
|
|
|
|
|
|
|
|
printf("\tAdmissions Control: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tAdmissions Control: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
|
|
|
|
printf("\tAssertions and Debug Logs: Disabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tAssertions and Debug Logs: Enabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_TO_FILE
|
|
|
|
|
|
|
|
printf("\tLogging to: %s\n", RUNTIME_LOG_FILE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLogging to: STDOUT and STDERR\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(aarch64)
|
|
|
|
|
|
|
|
printf("\tArchitecture: %s\n", "aarch64");
|
|
|
|
|
|
|
|
#elif defined(x86_64)
|
|
|
|
|
|
|
|
printf("\tArchitecture: %s\n", "x86_64");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Static assertion of define
|
|
|
|
|
|
|
|
int ncores = NCORES;
|
|
|
|
|
|
|
|
printf("\tTotal Cores: %d\n", ncores);
|
|
|
|
|
|
|
|
int page_size = PAGE_SIZE;
|
|
|
|
|
|
|
|
printf("\tPage Size: %d\n", page_size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_HTTP_PARSER
|
|
|
|
|
|
|
|
printf("\tLog HTTP Parser: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog HTTP Parser: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_STATE_CHANGES
|
|
|
|
|
|
|
|
printf("\tLog State Changes: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog State Changes: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_LOCK_OVERHEAD
|
|
|
|
|
|
|
|
printf("\tLog Lock Overhead: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Lock Overhead: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_LISTENER_LOCK_OVERHEAD
|
|
|
|
|
|
|
|
printf("\tLog Listener Lock Overhead: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Listener Lock Overhead: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_CONTEXT_SWITCHES
|
|
|
|
|
|
|
|
printf("\tLog Context Switches: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Context Switches: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_ADMISSIONS_CONTROL
|
|
|
|
|
|
|
|
printf("\tLog Admissions Control: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Admissions Control: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_REQUEST_ALLOCATION
|
|
|
|
|
|
|
|
printf("\tLog Request Allocation: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Request Allocation: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_PREEMPTION
|
|
|
|
|
|
|
|
printf("\tLog Preemption: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Preemption: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_MODULE_LOADING
|
|
|
|
|
|
|
|
printf("\tLog Module Loading: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Module Loading: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_TOTAL_REQS_RESPS
|
|
|
|
|
|
|
|
printf("\tLog Total Reqs/Resps: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Total Reqs/Resps: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_SANDBOX_COUNT
|
|
|
|
|
|
|
|
printf("\tLog Sandbox Count: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Sandbox Count: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef LOG_LOCAL_RUNQUEUE
|
|
|
|
|
|
|
|
printf("\tLog Local Runqueue: Enabled\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
printf("\tLog Local Runqueue: Disabled\n");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
runtime_process_debug_log_behavior();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Starting the Sledge runtime\n");
|
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
if (argc != 2) {
|
|
|
|
runtime_usage(argv[0]);
|
|
|
|
runtime_usage(argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Starting the Sledge runtime\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log_compiletime_config();
|
|
|
|
|
|
|
|
runtime_process_debug_log_behavior();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Runtime Environment:\n");
|
|
|
|
|
|
|
|
|
|
|
|
memset(runtime_worker_threads, 0, sizeof(pthread_t) * WORKER_THREAD_CORE_COUNT);
|
|
|
|
memset(runtime_worker_threads, 0, sizeof(pthread_t) * WORKER_THREAD_CORE_COUNT);
|
|
|
|
|
|
|
|
|
|
|
|
runtime_processor_speed_MHz = runtime_get_processor_speed_MHz();
|
|
|
|
runtime_processor_speed_MHz = runtime_get_processor_speed_MHz();
|
|
|
|
if (unlikely(runtime_processor_speed_MHz == 0)) panic("Failed to detect processor speed\n");
|
|
|
|
if (unlikely(runtime_processor_speed_MHz == 0)) panic("Failed to detect processor speed\n");
|
|
|
|
|
|
|
|
|
|
|
|
runtime_relative_deadline_us_max = UINT64_MAX / runtime_processor_speed_MHz;
|
|
|
|
runtime_relative_deadline_us_max = UINT64_MAX / runtime_processor_speed_MHz;
|
|
|
|
|
|
|
|
// TODO: Just here for troubleshooting. Delete me later
|
|
|
|
|
|
|
|
printf("Runtime Relative Deadline Max: %lu\n", runtime_relative_deadline_us_max);
|
|
|
|
|
|
|
|
printf("UINT32_MAX: %u\n", UINT32_MAX);
|
|
|
|
software_interrupt_interval_duration_in_cycles = (uint64_t)SOFTWARE_INTERRUPT_INTERVAL_DURATION_IN_USEC
|
|
|
|
software_interrupt_interval_duration_in_cycles = (uint64_t)SOFTWARE_INTERRUPT_INTERVAL_DURATION_IN_USEC
|
|
|
|
* runtime_processor_speed_MHz;
|
|
|
|
* runtime_processor_speed_MHz;
|
|
|
|
printf("Detected processor speed of %u MHz\n", runtime_processor_speed_MHz);
|
|
|
|
printf("\tProcessor Speed: %u MHz\n", runtime_processor_speed_MHz);
|
|
|
|
|
|
|
|
|
|
|
|
runtime_set_resource_limits_to_max();
|
|
|
|
runtime_set_resource_limits_to_max();
|
|
|
|
runtime_allocate_available_cores();
|
|
|
|
runtime_allocate_available_cores();
|
|
|
|