Commit e8ff16ed authored by Michael Quigley's avatar Michael Quigley
Browse files

Added tests for timing thread creation. Only tests lazy thread creation for...

Added tests for timing thread creation. Only tests lazy thread creation for now. Refactored older test code as well.
parent e932e9fd
......@@ -20,65 +20,136 @@
MODULE_LICENSE("GPL");
#define NUM_SWITCH_MEASUREMENTS 100000
#define CPU_NUM 1
static unsigned long ctx_switch_measurements[NUM_SWITCH_MEASUREMENTS];
static unsigned long measurements_arr[NUM_SWITCH_MEASUREMENTS];
static int test_fn(void* data)
static int test_ctx_switch(void)
{
unsigned long start_time, end_time;
uint32_t msg_id;
int i;
for( i = 0; i < NUM_SWITCH_MEASUREMENTS; i++ )
{
DO_FINISH_(ctx_switch,{
ASYNC({
msg_id = awe_mapper_create_id();
THCYieldAndSave(msg_id);
end_time = test_fipc_stop_stopwatch();
});
ASYNC({
start_time = test_fipc_start_stopwatch();
THCYieldToId(msg_id);
awe_mapper_remove_id(msg_id);
});
});
measurements_arr[i] = end_time - start_time;
}
return 0;
}
static int test_thread_creation(void)
{
unsigned long start_time, end_time;
int i;
for( i = 0; i < NUM_SWITCH_MEASUREMENTS; i++ )
{
DO_FINISH_(thread_creation,{
start_time = test_fipc_start_stopwatch();
ASYNC({
end_time = test_fipc_stop_stopwatch();
});
});
measurements_arr[i] = end_time - start_time;
}
return 0;
}
static int thread_fn(void* data)
{
int ret;
preempt_disable();
local_irq_disable();
thc_init();
LCD_MAIN({ret = ((int (*)(void)) data)();});
int i;
for( i = 0; i < NUM_SWITCH_MEASUREMENTS; i++ )
{
LCD_MAIN({
thc_init();
DO_FINISH_(ctx_switch,{
ASYNC({
msg_id = awe_mapper_create_id();
//THCYieldAndSave(msg_id);
THCYield();
end_time = test_fipc_stop_stopwatch();
});
ASYNC({
start_time = test_fipc_start_stopwatch();
//THCYieldToId(msg_id);
THCYield();
awe_mapper_remove_id(msg_id);
});
});
thc_done();
ctx_switch_measurements[i] = end_time - start_time;
});
}
thc_done();
preempt_enable();
local_irq_enable();
return ret;
}
printk(KERN_ERR "Timing results of performing %d switches between awe contexts:\n", NUM_SWITCH_MEASUREMENTS);
test_fipc_dump_time(ctx_switch_measurements, NUM_SWITCH_MEASUREMENTS);
static int run_test_fn(const char* result_str, int (*fn)(void))
{
int ret;
struct task_struct* thread;
thread = test_pin_to_core(fn, thread_fn, CPU_NUM);
if( !thread )
{
printk(KERN_ERR "Error setting up thread.\n");
goto fail;
}
wake_up_process(thread);
msleep(1000);
ret = test_fipc_wait_for_thread(thread);
if( ret )
{
printk(KERN_ERR "Error waiting for thread.\n");
}
printk(KERN_ERR "%s\n", result_str);
test_fipc_dump_time(measurements_arr, NUM_SWITCH_MEASUREMENTS);
printk(KERN_ERR "\n\n");
return 0;
fail:
test_fipc_release_thread(thread);
return ret;
}
static int setup_and_run_test(void)
static int test_fn(void)
{
struct task_struct* thread = test_pin_to_core(NULL, test_fn, 1);
int ret;
wake_up_process(thread);
msleep(1000);
ret = test_fipc_wait_for_thread(thread);
if (ret)
printk(KERN_ERR "Thread returned non-zero exit status %d\n", ret);
printk(KERN_ERR "Starting tests. Using %d samples per test.\n\n", NUM_SWITCH_MEASUREMENTS);
ret = run_test_fn("Timing results for test_ctx_switch:", test_ctx_switch);
if( ret )
{
printk(KERN_ERR "test_ctx_switch returned non-zero\n");
return ret;
}
ret = run_test_fn("Timing results for test_thread_creation:", test_thread_creation);
if( ret )
{
printk(KERN_ERR "test_thread_creation returned non-zero\n");
return ret;
}
printk(KERN_ERR "Tests complete.\n\n");
return ret;
}
......@@ -87,7 +158,7 @@ static int __init ctx_switch_init(void)
{
int ret = 0;
ret = setup_and_run_test();
ret = test_fn();
return ret;
}
......
......@@ -36,6 +36,5 @@ void test_fipc_dump_time(unsigned long *time, unsigned long num_transactions)
printk(KERN_ERR "MIN\tMAX\tAVG\tMEDIAN\n");
printk(KERN_ERR "%lu & %lu & %llu & %lu \n", min, max, counter/num_transactions, time[num_transactions/2]);
}
EXPORT_SYMBOL(test_fipc_dump_time);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment