record each thread worker's queuelength when an alarm signal come in

main
lyuxiaosu 3 years ago
parent d831af5615
commit f2853d2783

@ -4,6 +4,8 @@
#include "sandbox_types.h"
#define TEST_RECORDING_BUFFER_LEN 500000
/* Returns pointer back if successful, null otherwise */
typedef void (*local_runqueue_add_fn_t)(struct sandbox *);
typedef bool (*local_runqueue_is_empty_fn_t)(void);

@ -356,7 +356,7 @@ main(int argc, char **argv)
char *cpu_speed_MHz_raw = getenv("SLEDGE_CPU_SPEED");
if (cpu_speed_MHz_raw != NULL) {
long cpu_speed_MHz = atoi(cpu_speed_MHz_raw);
if (unlikely(cpu_speed_MHz < 0)) panic("SLEDGE_CPU_SPEED must be a positive integer, saw %ld\n", cpu_speed_MHz);
if (unlikely(cpu_speed_MHz <= 0)) panic("SLEDGE_CPU_SPEED must be a positive integer, saw %ld\n", cpu_speed_MHz);
runtime_processor_speed_MHz = (uint32_t)cpu_speed_MHz;
}
printf("\tCPU Speed: %u MHz\n", runtime_processor_speed_MHz);

@ -31,6 +31,9 @@ static uint64_t software_interrupt_interval_duration_in_cycles;
/******************
* Thread Globals *
*****************/
extern __thread uint32_t local_workload_count;
extern __thread int recording_buffer[];
extern __thread int worker_thread_idx;
__thread _Atomic static volatile sig_atomic_t software_interrupt_SIGALRM_kernel_count = 0;
__thread _Atomic static volatile sig_atomic_t software_interrupt_SIGALRM_thread_count = 0;
@ -168,6 +171,9 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
switch (signal_type) {
case SIGALRM: {
assert(TEST_RECORDING_BUFFER_LEN > software_interrupt_SIGALRM_kernel_count + software_interrupt_SIGALRM_thread_count);
/* record queuelength of the current worker thread */
recording_buffer[software_interrupt_SIGALRM_kernel_count + software_interrupt_SIGALRM_thread_count] = local_workload_count;
sigalrm_propagate_workers(signal_info);
if (current_sandbox == NULL || current_sandbox->ctxt.preemptable == false) {
/* Cannot preempt, so defer signal
@ -198,8 +204,15 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
goto done;
}
case SIGINT: {
/* Stop the alarm timer first */
software_interrupt_disarm_timer();
/* Only the thread that receives SIGINT from the kernel or user space will broadcast SIGINT to other worker threads */
sigint_propagate_workers_listener(signal_info);
mem_log("thread id %d test buffer:",worker_thread_idx);
for(int i = 0; i < software_interrupt_SIGALRM_kernel_count + software_interrupt_SIGALRM_thread_count; i++) {
mem_log("%d ", recording_buffer[i]);
}
mem_log("\n");
dump_log_to_file();
/* terminate itself */
pthread_exit(0);

@ -21,6 +21,10 @@
* Worker Thread State *
**************************/
extern uint32_t test_recording_buffer_len;
/* test recording buffer for saving queuelength */
__thread int recording_buffer[TEST_RECORDING_BUFFER_LEN] = {0};
/* context of the runtime thread before running sandboxes or to resume its "main". */
__thread struct arch_context worker_thread_base_context;

Loading…
Cancel
Save