Commit 8b94fe30 authored by Michael Quigley's avatar Michael Quigley
Browse files

Disabled preemption and local IRQs. Discovered another stack bug in the...

Disabled preemption and local IRQs. Discovered another stack bug in the Barrefish code where thc_done does not adequately clean up the used stacks resulting in memory leaks.
parent a5d61f05
......@@ -13,6 +13,7 @@
#include <thcinternal.h>
#include <awe_mapper.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/module.h>
#include "../test_helpers.h"
......@@ -23,35 +24,62 @@ MODULE_LICENSE("GPL");
static unsigned long ctx_switch_measurements[NUM_SWITCH_MEASUREMENTS];
static int setup_and_run_test(void)
static int test_fn(void* data)
{
unsigned long start_time, end_time, elapsed_time;
uint32_t msg_id;
thc_init();
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);
});
});
ctx_switch_measurements[i] = end_time - start_time;
}
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);
thc_done();
preempt_disable();
local_irq_disable();
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;
});
}
preempt_enable();
local_irq_enable();
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);
return 0;
}
static int setup_and_run_test(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);
return ret;
}
......@@ -59,7 +87,7 @@ static int __init ctx_switch_init(void)
{
int ret = 0;
LCD_MAIN({ ret = setup_and_run_test(); });
ret = setup_and_run_test();
return ret;
}
......
......@@ -40,13 +40,12 @@
\
} while (0);
static inline
struct task_struct *
test_fipc_spawn_thread_with_channel(struct fipc_ring_channel *channel,
int (*threadfn)(void *data),
int cpu_pin)
static inline
struct task_struct*
test_pin_to_core(void* thd_data, int (*threadfn)(void *data), int cpu_pin)
{
struct cpumask cpu_core;
struct cpumask cpu_core;
struct task_struct* thread = NULL;
if (cpu_pin > num_online_cpus()) {
......@@ -56,7 +55,7 @@ test_fipc_spawn_thread_with_channel(struct fipc_ring_channel *channel,
/*
* Create kernel thread
*/
thread = kthread_create(threadfn, channel, "AsyncIPC.%d", cpu_pin);
thread = kthread_create(threadfn, thd_data, "Async.%d", cpu_pin);
if (IS_ERR(thread)) {
pr_err("Error while creating kernel thread\n");
goto fail2;
......@@ -80,6 +79,15 @@ fail1:
return thread;
}
static inline
struct task_struct *
test_fipc_spawn_thread_with_channel(struct fipc_ring_channel *channel,
int (*threadfn)(void *data),
int cpu_pin)
{
return test_pin_to_core(channel, threadfn, cpu_pin);
}
static inline
void
test_fipc_release_thread(struct task_struct *thread)
......
Supports Markdown
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