Commit 0850a116 authored by Michael Quigley's avatar Michael Quigley
Browse files

Add micro benchmark for AWE creatiojn and destruction using YieldTo.

parent ca8b8fa7
Pipeline #1527 skipped
......@@ -23,14 +23,91 @@ MODULE_LICENSE("GPL");
static const int CPU_NUM = -1;
static unsigned long id_1, id_2;
static int id_1, id_2;
/*dummy_ret_val prevents the call to foo() from being optimized out.*/
static volatile int dummy_ret_val = 0;
static int thread_fn(void* data)
{
int ret;
preempt_disable();
local_irq_disable();
LCD_MAIN({ret = ((int (*)(void)) data)();});
preempt_enable();
local_irq_enable();
return ret;
}
static int run_test_fn_thread(int (*fn)(void), int cpu_num)
{
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");
}
return 0;
fail:
test_fipc_release_thread(thread);
return ret;
}
static int run_test_fn_nothread(int (*fn)(void))
{
int ret;
ret = thread_fn(fn);
if( ret )
{
printk(KERN_ERR "Error running test.\n");
goto fail1;
}
return 0;
fail1:
return ret;
}
/*run_test_fn
Runs provided function 'fn' with the appropriate setup
(irq and preemption disabled during execution)
if core_num is -1, then the provided function is run
on the current core, otherwise, it is run
in a kthread on core 'core_num'.*/
static int run_test_fn(int (*fn)(void), int core_num)
{
return (core_num == -1) ?
run_test_fn_nothread(fn)
: run_test_fn_thread(fn, core_num);
}
__attribute__((used)) noinline static int foo_yieldto(void)
{
THCYieldToIdAndSave(id_2, id_1);
THCYieldAndSave(id_1);
return 0;
}
......@@ -90,11 +167,10 @@ static int test_create_and_tear_down(void)
t1 = test_fipc_start_stopwatch();
DO_FINISH({
THCYieldAndSave(id_2);
for( i = 0; i < NUM_ITERS; i++ )
{
ASYNC(foo_yieldto(););
THCYieldToIdAndSave(id_1, id_2);
THCYieldToId(id_1);
}
});
t2 = test_fipc_stop_stopwatch();
......@@ -116,7 +192,7 @@ static int test_fn(void)
printk(KERN_ERR "Starting tests. Using %d iterations per test.\n\n",
NUM_ITERS);
ret = test_fipc_run_test_fn(test_create_and_tear_down, CPU_NUM);
ret = run_test_fn(test_create_and_tear_down, CPU_NUM);
if( ret )
{
......
......@@ -26,7 +26,83 @@ static unsigned long thd_measurements_arr[NUM_SWITCH_MEASUREMENTS];
static const int CPU_NUM = -1;
static int thread_fn(void* data)
{
int ret;
preempt_disable();
local_irq_disable();
LCD_MAIN({ret = ((int (*)(void)) data)();});
preempt_enable();
local_irq_enable();
return ret;
}
static int run_test_fn_thread(int (*fn)(void), int cpu_num)
{
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");
}
return 0;
fail:
test_fipc_release_thread(thread);
return ret;
}
static int run_test_fn_nothread(int (*fn)(void))
{
int ret;
ret = thread_fn(fn);
if( ret )
{
printk(KERN_ERR "Error running test.\n");
goto fail1;
}
return 0;
fail1:
return ret;
}
/*run_test_fn
Runs provided function 'fn' with the appropriate setup
(irq and preemption disabled during execution)
if core_num is -1, then the provided function is run
on the current core, otherwise, it is run
in a kthread on core 'core_num'.*/
static int run_test_fn(int (*fn)(void), int core_num)
{
return (core_num == -1) ?
run_test_fn_nothread(fn)
: run_test_fn_thread(fn, core_num);
}
/*Note: Stack overflow can occur with the lazy configuration because there are so many nested functions.*/
static int avg_thread_creation_test(void)
{
unsigned long t1, t2;
......@@ -339,13 +415,13 @@ static int test_fn(void)
NUM_SWITCH_MEASUREMENTS);
printk(KERN_ERR "\n\nTesting no dispatch yields\n");
ret = test_fipc_run_test_fn(test_ctx_switch_and_thd_creation_no_dispatch,
ret = run_test_fn(test_ctx_switch_and_thd_creation_no_dispatch,
CPU_NUM);
printk(KERN_ERR "\n\nTesting with dispatch yields\n");
ret |= test_fipc_run_test_fn(test_ctx_switch_and_thd_creation,
ret |= run_test_fn(test_ctx_switch_and_thd_creation,
CPU_NUM);
printk(KERN_ERR "\n\nTesting average thread creation time\n");
ret |= test_fipc_run_test_fn(avg_thread_creation_test,
ret |= run_test_fn(avg_thread_creation_test,
CPU_NUM);
......
......@@ -38,80 +38,3 @@ void test_fipc_dump_time(unsigned long *time, unsigned long num_transactions)
printk(KERN_ERR "%lu & %lu & %llu & %lu \n", min, max, counter/num_transactions, time[num_transactions/2]);
}
static int test_fipc_thread_fn(void* data)
{
int ret;
preempt_disable();
local_irq_disable();
LCD_MAIN({ret = ((int (*)(void)) data)();});
preempt_enable();
local_irq_enable();
return ret;
}
static int test_fipc_run_test_fn_thread(int (*fn)(void), int cpu_num)
{
int ret;
struct task_struct* thread;
thread = test_pin_to_core(fn, test_fipc_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");
}
return 0;
fail:
test_fipc_release_thread(thread);
return ret;
}
static int test_fipc_run_test_fn_nothread(int (*fn)(void))
{
int ret;
ret = test_fipc_thread_fn(fn);
if( ret )
{
printk(KERN_ERR "Error running test.\n");
goto fail1;
}
return 0;
fail1:
return ret;
}
/*run_test_fn
Runs provided function 'fn' with the appropriate setup
(irq and preemption disabled during execution)
if core_num is -1, then the provided function is run
on the current core, otherwise, it is run
in a kthread on core 'core_num'.*/
int test_fipc_run_test_fn(int (*fn)(void), int core_num)
{
return (core_num == -1) ?
test_fipc_run_test_fn_nothread(fn)
: test_fipc_run_test_fn_thread(fn, core_num);
}
......@@ -41,8 +41,6 @@
\
} while (0);
int test_fipc_run_test_fn(int (*fn)(void), int core_num);
static inline
struct task_struct*
test_pin_to_core(void* thd_data, int (*threadfn)(void *data), int cpu_pin)
......
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