Skip to content

Commit

Permalink
Early Processing Methodology in More Benchmarks
Browse files Browse the repository at this point in the history
Add early processing methodology to more benchmarks

Signed-off-by: Courtney Darville <[email protected]>
  • Loading branch information
Courtney3141 authored and lsf37 committed Apr 18, 2023
1 parent a314b3c commit b7a570a
Show file tree
Hide file tree
Showing 18 changed files with 513 additions and 25 deletions.
95 changes: 95 additions & 0 deletions apps/fault/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,34 @@ static void measure_fault_handler_fn(int argc, char **argv)
fault_handler_done(ep, ip, done_ep, reply);
}

static void measure_fault_handler_fn_ep(int argc, char **argv)
{
seL4_CPtr ep, done_ep, reply;
volatile ccnt_t *start;
ccnt_t end, sum = 0, sum2 = 0, overhead;
fault_results_t *results;
DATACOLLECT_INIT();

parse_handler_args(argc, argv, &ep, &start, &results, &done_ep, &reply);

overhead = results->fault_ep_min_overhead;

seL4_Word ip = fault_handler_start(ep, done_ep, reply);
for (seL4_Word i = 0; i < N_RUNS; i++) {
ip += UD_INSTRUCTION_SIZE;
DO_REAL_REPLY_RECV_1(ep, ip, reply);

SEL4BENCH_READ_CCNT(end);
DATACOLLECT_GET_SUMS(i, N_IGNORED, *start, end, overhead, sum, sum2);
}

results->fault_ep_sum = sum;
results->fault_ep_sum2 = sum2;
results->fault_ep_num = N_RUNS - N_IGNORED;

fault_handler_done(ep, ip, done_ep, reply);
}

/* Pair for measuring fault handler -> faultee path */
static void measure_fault_reply_fn(int argc, char **argv)
{
Expand Down Expand Up @@ -153,6 +181,35 @@ static void measure_fault_reply_handler_fn(int argc, char **argv)
fault_handler_done(ep, ip, done_ep, reply);
}

/* measure_fault_reply_fn with early processing */
static void measure_fault_reply_fn_ep(int argc, char **argv)
{
assert(argc == N_FAULTER_ARGS);
volatile ccnt_t *start = (volatile ccnt_t *) atol(argv[0]);
fault_results_t *results = (fault_results_t *) atol(argv[1]);
seL4_CPtr done_ep = atol(argv[2]);
ccnt_t overhead, sum = 0, sum2 = 0;
DATACOLLECT_INIT();

overhead = results->fault_reply_ep_min_overhead;

/* handle 1 fault first to make sure start is set */
fault();
for (seL4_Word i = 0; i < N_RUNS; i++) {
fault();
ccnt_t end;
SEL4BENCH_READ_CCNT(end);
DATACOLLECT_GET_SUMS(i, N_IGNORED, *start, end, overhead, sum, sum2);
}
fault();

results->fault_reply_ep_sum = sum;
results->fault_reply_ep_sum2 = sum2;
results->fault_reply_ep_num = N_RUNS - N_IGNORED;

seL4_Send(done_ep, seL4_MessageInfo_new(0, 0, 0, 0));
}

/* round_trip fault handling pair */
static void measure_fault_roundtrip_fn(int argc, char **argv)
{
Expand All @@ -170,6 +227,32 @@ static void measure_fault_roundtrip_fn(int argc, char **argv)
seL4_Send(done_ep, seL4_MessageInfo_new(0, 0, 0, 0));
}

static void measure_fault_roundtrip_fn_ep(int argc, char **argv)
{
assert(argc == N_FAULTER_ARGS);
fault_results_t *results = (fault_results_t *) atol(argv[1]);
seL4_CPtr done_ep = atol(argv[2]);
ccnt_t sum = 0, sum2 = 0, overhead;
DATACOLLECT_INIT();

overhead = results->round_trip_ep_min_overhead;

for (seL4_Word i = 0; i < N_RUNS; i++) {
ccnt_t start, end;
SEL4BENCH_READ_CCNT(start);
fault();
SEL4BENCH_READ_CCNT(end);
DATACOLLECT_GET_SUMS(i, N_IGNORED, start, end, overhead, sum, sum2);
}
fault();

results->round_trip_ep_sum = sum;
results->round_trip_ep_sum2 = sum2;
results->round_trip_ep_num = N_RUNS - N_IGNORED;

seL4_Send(done_ep, seL4_MessageInfo_new(0, 0, 0, 0));
}

static void measure_fault_roundtrip_handler_fn(int argc, char **argv)
{
seL4_CPtr ep, done_ep, reply;
Expand Down Expand Up @@ -250,11 +333,23 @@ static void run_fault_benchmark(env_t *env, fault_results_t *results)
/* benchmark fault */
run_benchmark(measure_fault_fn, measure_fault_handler_fn, done_ep.cptr);

/* benchmark fault early processing */
results->fault_ep_min_overhead = getMinOverhead(results->reply_recv_overhead, N_RUNS);
run_benchmark(measure_fault_fn, measure_fault_handler_fn_ep, done_ep.cptr);

/* benchmark reply */
run_benchmark(measure_fault_reply_fn, measure_fault_reply_handler_fn, done_ep.cptr);

/* benchmark reply early processing */
results->fault_reply_ep_min_overhead = getMinOverhead(results->ccnt_overhead, N_RUNS);
run_benchmark(measure_fault_reply_fn_ep, measure_fault_reply_handler_fn, done_ep.cptr);

/* benchmark round_trip */
run_benchmark(measure_fault_roundtrip_fn, measure_fault_roundtrip_handler_fn, done_ep.cptr);

/* benchmark round_trip early processing */
results->round_trip_ep_min_overhead = getMinOverhead(results->reply_recv_overhead, N_RUNS);
run_benchmark(measure_fault_roundtrip_fn_ep, measure_fault_roundtrip_handler_fn, done_ep.cptr);
}

void measure_overhead(fault_results_t *results)
Expand Down
20 changes: 20 additions & 0 deletions apps/hardware/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ void measure_nullsyscall(ccnt_t *results)

}

void measure_nullsyscall_ep(hardware_results_t *results)
{
ccnt_t start, end, sum = 0, sum2 = 0, overhead;

overhead = results->overhead_min;
DATACOLLECT_INIT();

for (seL4_Word i = 0; i < N_RUNS; i++) {
SEL4BENCH_READ_CCNT(start);
DO_REAL_NULLSYSCALL();
SEL4BENCH_READ_CCNT(end);
DATACOLLECT_GET_SUMS(i, N_IGNORED, start, end, overhead, sum, sum2);
}

results->nullSyscall_ep_sum = sum;
results->nullSyscall_ep_sum2 = sum2;
results->nullSyscall_ep_num = N_RUNS - N_IGNORED;
}

static env_t *env;

void CONSTRUCTOR(MUSLCSYS_WITH_VSYSCALL_PRIORITY) init_env(void)
Expand All @@ -75,6 +94,7 @@ int main(int argc, char **argv)
/* measure overhead */
measure_nullsyscall_overhead(results->nullSyscall_overhead);
measure_nullsyscall(results->nullSyscall_results);
measure_nullsyscall_ep(results);

/* done -> results are stored in shared memory so we can now return */
benchmark_finished(EXIT_SUCCESS);
Expand Down
87 changes: 87 additions & 0 deletions apps/irquser/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,41 @@ void ticker_fn(ccnt_t *results, volatile ccnt_t *current_time)
seL4_Send(done_ep, seL4_MessageInfo_new(0, 0, 0, 0));
}

void ticker_fn_ep(int argc, char **argv)
{
if (argc != 5) {
abort();
}
ccnt_t overhead = (ccnt_t) atol(argv[0]);
ccnt_t *results_sum = (ccnt_t *) atol(argv[1]);
ccnt_t *results_sum2 = (ccnt_t *) atol(argv[2]);
ccnt_t *results_num = (ccnt_t *) atol(argv[3]);
volatile ccnt_t *current_time = (volatile ccnt_t *) atol(argv[4]);

seL4_Word start, end_low;
ccnt_t end, sum = 0, sum2 = 0;
seL4_Word badge;

DATACOLLECT_INIT();

for (seL4_Word i = 0; i < N_RUNS; i++) {
/* wait for irq */
seL4_Wait(timer_signal, &badge);
/* record result */
SEL4BENCH_READ_CCNT(end);
sel4platsupport_irq_handle(irq_ops, timer_ntfn_id, badge);
end_low = (seL4_Word) end;
start = (seL4_Word) * current_time;
DATACOLLECT_GET_SUMS(i, N_IGNORED, start, end_low, overhead, sum, sum2);
}

*results_sum = sum;
*results_sum2 = sum2;
*results_num = N_RUNS - N_IGNORED;

seL4_Send(done_ep, seL4_MessageInfo_new(0, 0, 0, 0));
}

static env_t *env;

void CONSTRUCTOR(MUSLCSYS_WITH_VSYSCALL_PRIORITY) init_env(void)
Expand Down Expand Up @@ -132,6 +167,9 @@ int main(int argc, char **argv)
results->overheads[i] = end - start;
}

/* find the minimum overhead for early processing run */
results->overhead_min = getMinOverhead(results->overheads, N_RUNS);

/* create a frame for the shared time variable so we can share it between processes */
ccnt_t *local_current_time = (ccnt_t *) vspace_new_pages(&env->vspace, seL4_AllRights, 1, seL4_PageBits);
if (local_current_time == NULL) {
Expand Down Expand Up @@ -165,6 +203,31 @@ int main(int argc, char **argv)
error = seL4_TCB_Suspend(ticker.tcb.cptr);
assert(error == seL4_NoError);

/* run the benchmark again with early processing */
char ticker_ep_strings[5][WORD_STRING_SIZE];
char *ticker_ep_argv[5];
sel4utils_create_word_args(ticker_ep_strings, ticker_ep_argv, 5, (seL4_Word) results->overhead_min,
&results->thread_results_ep_sum,
&results->thread_results_ep_sum2, &results->thread_results_ep_num, (seL4_Word) local_current_time);
error = sel4utils_start_thread(&ticker, (sel4utils_thread_entry_fn) ticker_fn_ep, (void *) 5, (void *) ticker_ep_argv,
true);
if (error) {
ZF_LOGF("Failed to start ticker");
}

error = sel4utils_start_thread(&spinner, (sel4utils_thread_entry_fn) spinner_fn, (void *) 1, (void *) spinner_argv,
true);
assert(!error);

benchmark_wait_children(endpoint.cptr, "child of irq-user", 1);

/* stop spinner thread */
error = seL4_TCB_Suspend(spinner.tcb.cptr);
assert(error == seL4_NoError);

error = seL4_TCB_Suspend(ticker.tcb.cptr);
assert(error == seL4_NoError);

/* now run the benchmark again, but run the spinner in another address space */

/* restart ticker */
Expand All @@ -190,6 +253,30 @@ int main(int argc, char **argv)

benchmark_wait_children(endpoint.cptr, "child of irq-user", 1);

/* stop threads */
error = seL4_TCB_Suspend(spinner_process.thread.tcb.cptr);
assert(error == seL4_NoError);

error = seL4_TCB_Suspend(ticker.tcb.cptr);
assert(error == seL4_NoError);

/* run the benchmark again but with early processing */
sel4utils_create_word_args(ticker_ep_strings, ticker_ep_argv, 5, (seL4_Word) results->overhead_min,
&results->process_results_ep_sum,
&results->process_results_ep_sum2, &results->process_results_ep_num, (seL4_Word) local_current_time);
error = sel4utils_start_thread(&ticker, (sel4utils_thread_entry_fn) ticker_fn_ep, (void *) 5, (void *) ticker_ep_argv,
true);
assert(!error);

/* start the spinner process */
sel4utils_create_word_args(strings, spinner_argv, 1, (seL4_Word) current_time_remote);
error = benchmark_spawn_process(&spinner_process, &env->slab_vka, &env->vspace, 1, spinner_argv, 1);
if (error) {
ZF_LOGF("Failed to start spinner process");
}

benchmark_wait_children(endpoint.cptr, "child of irq-user", 1);

/* done -> results are stored in shared memory so we can now return */
benchmark_finished(EXIT_SUCCESS);
return 0;
Expand Down
77 changes: 77 additions & 0 deletions apps/scheduler/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@ static void benchmark_yield(seL4_CPtr ep, ccnt_t *results, volatile ccnt_t *end)
benchmark_wait_children(ep, "yielder", 1);
}

static void benchmark_yield_ep(seL4_CPtr ep, ccnt_t overhead, ccnt_t *result_sum, ccnt_t *result_sum2,
ccnt_t *result_num, volatile ccnt_t *end)
{
ccnt_t start, sum = 0, sum2 = 0;
DATACOLLECT_INIT();
/* run the benchmark */
for (seL4_Word i = 0; i < N_RUNS; i++) {
SEL4BENCH_READ_CCNT(start);
seL4_Yield();
DATACOLLECT_GET_SUMS(i, N_IGNORED, start, *end, overhead, sum, sum2);
}

*result_sum = sum;
*result_sum2 = sum2;
*result_num = N_RUNS - N_IGNORED;

benchmark_wait_children(ep, "yielder", 1);
}

static void benchmark_yield_thread(env_t *env, seL4_CPtr ep, ccnt_t *results)
{
sel4utils_thread_t thread;
Expand All @@ -117,6 +136,22 @@ static void benchmark_yield_thread(env_t *env, seL4_CPtr ep, ccnt_t *results)
seL4_TCB_Suspend(thread.tcb.cptr);
}

static void benchmark_yield_thread_ep(env_t *env, seL4_CPtr ep, scheduler_results_t *results)
{
sel4utils_thread_t thread;
volatile ccnt_t end;
char args_strings[N_YIELD_ARGS][WORD_STRING_SIZE];
char *argv[N_YIELD_ARGS];

benchmark_configure_thread(env, ep, seL4_MaxPrio, "yielder", &thread);
sel4utils_create_word_args(args_strings, argv, N_YIELD_ARGS, ep, (seL4_Word) &end);
sel4utils_start_thread(&thread, (sel4utils_thread_entry_fn) yield_fn, (void *) N_YIELD_ARGS, (void *) argv, 1);

benchmark_yield_ep(ep, results->overhead_ccnt_min, &results->thread_yield_ep_sum, &results->thread_yield_ep_sum2,
&results->thread_yield_ep_num, &end);
seL4_TCB_Suspend(thread.tcb.cptr);
}

static void benchmark_yield_process(env_t *env, seL4_CPtr ep, ccnt_t *results)
{
sel4utils_process_t process;
Expand Down Expand Up @@ -153,6 +188,43 @@ static void benchmark_yield_process(env_t *env, seL4_CPtr ep, ccnt_t *results)
seL4_TCB_Suspend(process.thread.tcb.cptr);
}

static void benchmark_yield_process_ep(env_t *env, seL4_CPtr ep, scheduler_results_t *results)
{
sel4utils_process_t process;
void *start;
void *remote_start;
seL4_CPtr remote_ep;
char args_strings[N_YIELD_ARGS][WORD_STRING_SIZE];
char *argv[N_YIELD_ARGS];
UNUSED int error;
cspacepath_t path;

/* allocate a page to share for the start cycle count */
start = vspace_new_pages(&env->vspace, seL4_AllRights, 1, seL4_PageBits);
assert(start != NULL);

benchmark_shallow_clone_process(env, &process, seL4_MaxPrio, yield_fn, "yield process");

/* share memory for shared variable */
remote_start = vspace_share_mem(&env->vspace, &process.vspace, start, 1, seL4_PageBits,
seL4_AllRights, 1);
assert(remote_start != NULL);

/* copy ep cap */
vka_cspace_make_path(&env->slab_vka, ep, &path);
remote_ep = sel4utils_copy_path_to_process(&process, path);
assert(remote_ep != seL4_CapNull);

sel4utils_create_word_args(args_strings, argv, N_YIELD_ARGS, remote_ep, (seL4_Word) remote_start);

error = benchmark_spawn_process(&process, &env->slab_vka, &env->vspace, N_YIELD_ARGS, argv, 1);
assert(error == seL4_NoError);

benchmark_yield_ep(ep, results->overhead_ccnt_min, &results->process_yield_ep_sum, &results->process_yield_ep_sum2,
&results->process_yield_ep_num, (volatile ccnt_t *) start);
seL4_TCB_Suspend(process.thread.tcb.cptr);
}

static void benchmark_prio_threads(env_t *env, seL4_CPtr ep, seL4_CPtr produce, seL4_CPtr consume,
ccnt_t results[N_PRIOS][N_RUNS])
{
Expand Down Expand Up @@ -367,6 +439,9 @@ int main(int argc, char **argv)
measure_signal_overhead(produce.cptr, results->overhead_signal);
measure_yield_overhead(results->overhead_ccnt);

/* extract the minimum overhead for early processing benchmarks */
results->overhead_ccnt_min = getMinOverhead(results->overhead_ccnt, N_RUNS);

benchmark_prio_threads(env, done_ep.cptr, produce.cptr, consume.cptr,
results->thread_results);
benchmark_prio_processes(env, done_ep.cptr, produce.cptr, consume.cptr,
Expand All @@ -375,7 +450,9 @@ int main(int argc, char **argv)

/* thread yield benchmarks */
benchmark_yield_thread(env, done_ep.cptr, results->thread_yield);
benchmark_yield_thread_ep(env, done_ep.cptr, results);
benchmark_yield_process(env, done_ep.cptr, results->process_yield);
benchmark_yield_process_ep(env, done_ep.cptr, results);
benchmark_yield_average(results->average_yield);

/* done -> results are stored in shared memory so we can now return */
Expand Down
Loading

0 comments on commit b7a570a

Please sign in to comment.