From 53696c1fe6a6ada66f2a47c078d62aee40ad8ebe Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Thu, 17 Dec 2009 21:31:46 -0500 Subject: [ported from 2008.3] Add rt_domain_t support Still to be merged: - arm_release_timer() with no rq locking --- litmus/litmus.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'litmus/litmus.c') diff --git a/litmus/litmus.c b/litmus/litmus.c index 9254f1621af7..de751a14d77c 100644 --- a/litmus/litmus.c +++ b/litmus/litmus.c @@ -19,6 +19,8 @@ #include +#include + /* Number of RT tasks that exist in the system */ atomic_t rt_task_count = ATOMIC_INIT(0); static DEFINE_SPINLOCK(task_transition_lock); @@ -30,6 +32,7 @@ atomic_t __log_seq_no = ATOMIC_INIT(0); atomic_t release_master_cpu = ATOMIC_INIT(NO_CPU); static struct kmem_cache * heap_node_cache; +extern struct kmem_cache * release_heap_cache; struct heap_node* heap_node_alloc(int gfp_flags) { @@ -41,6 +44,9 @@ void heap_node_free(struct heap_node* hn) kmem_cache_free(heap_node_cache, hn); } +struct release_heap* release_heap_alloc(int gfp_flags); +void release_heap_free(struct release_heap* rh); + /* * sys_set_task_rt_param * @pid: Pid of the task which scheduling parameters must be changed @@ -299,15 +305,16 @@ long litmus_admit_task(struct task_struct* tsk) get_exec_cost(tsk) > get_rt_period(tsk)) { TRACE_TASK(tsk, "litmus admit: invalid task parameters " "(%lu, %lu)\n", - get_exec_cost(tsk), get_rt_period(tsk)); - return -EINVAL; + get_exec_cost(tsk), get_rt_period(tsk)); + retval = -EINVAL; + goto out; } - if (!cpu_online(get_partition(tsk))) - { + if (!cpu_online(get_partition(tsk))) { TRACE_TASK(tsk, "litmus admit: cpu %d is not online\n", get_partition(tsk)); - return -EINVAL; + retval = -EINVAL; + goto out; } INIT_LIST_HEAD(&tsk_rt(tsk)->list); @@ -316,17 +323,22 @@ long litmus_admit_task(struct task_struct* tsk) spin_lock_irqsave(&task_transition_lock, flags); /* allocate heap node for this task */ - tsk_rt(tsk)->heap_node = heap_node_alloc(GFP_ATOMIC); - if (!tsk_rt(tsk)->heap_node || - !tsk_rt(tsk)->rel_heap) { + tsk_rt(tsk)->heap_node = heap_node_alloc(GFP_ATOMIC); + tsk_rt(tsk)->rel_heap = release_heap_alloc(GFP_ATOMIC); + + if (!tsk_rt(tsk)->heap_node || !tsk_rt(tsk)->rel_heap) { printk(KERN_WARNING "litmus: no more heap node memory!?\n"); - retval = -ENOMEM; + heap_node_free(tsk_rt(tsk)->heap_node); - } else + release_heap_free(tsk_rt(tsk)->rel_heap); + + retval = -ENOMEM; + goto out_unlock; + } else { heap_node_init(&tsk_rt(tsk)->heap_node, tsk); + } - if (!retval) - retval = litmus->admit_task(tsk); + retval = litmus->admit_task(tsk); if (!retval) { sched_trace_task_name(tsk); @@ -334,8 +346,9 @@ long litmus_admit_task(struct task_struct* tsk) atomic_inc(&rt_task_count); } +out_unlock: spin_unlock_irqrestore(&task_transition_lock, flags); - +out: return retval; } @@ -343,9 +356,13 @@ void litmus_exit_task(struct task_struct* tsk) { if (is_realtime(tsk)) { sched_trace_task_completion(tsk, 1); + litmus->task_exit(tsk); + BUG_ON(heap_node_in_heap(tsk_rt(tsk)->heap_node)); heap_node_free(tsk_rt(tsk)->heap_node); + release_heap_free(tsk_rt(tsk)->rel_heap); + atomic_dec(&rt_task_count); reinit_litmus_state(tsk, 1); } @@ -632,6 +649,7 @@ static int __init _init_litmus(void) register_sched_plugin(&linux_sched_plugin); heap_node_cache = KMEM_CACHE(heap_node, SLAB_PANIC); + release_heap_cache = KMEM_CACHE(release_heap, SLAB_PANIC); #ifdef CONFIG_MAGIC_SYSRQ /* offer some debugging help */ @@ -650,6 +668,7 @@ static void _exit_litmus(void) { exit_litmus_proc(); kmem_cache_destroy(heap_node_cache); + kmem_cache_destroy(release_heap_cache); } module_init(_init_litmus); -- cgit v1.2.2