From a916d9b2feaeb5934e1f8ba30fde74193a60e8d1 Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Tue, 11 Sep 2012 15:25:29 -0400 Subject: Fix hang from bug in edf_common.c --- include/litmus/fdso.h | 22 +++++++++++----------- litmus/edf_common.c | 36 +++++++++++++++++++++++++++++++----- litmus/fdso.c | 10 ++++++---- litmus/preempt.c | 5 +++-- 4 files changed, 51 insertions(+), 22 deletions(-) diff --git a/include/litmus/fdso.h b/include/litmus/fdso.h index 35be59b970ee..1469c0fd0460 100644 --- a/include/litmus/fdso.h +++ b/include/litmus/fdso.h @@ -20,20 +20,20 @@ typedef enum { FMLP_SEM = 0, SRP_SEM = 1, - RSM_MUTEX = 2, - IKGLP_SEM = 3, - KFMLP_SEM = 4, + MPCP_SEM = 2, + MPCP_VS_SEM = 3, + DPCP_SEM = 4, - IKGLP_SIMPLE_GPU_AFF_OBS = 5, - IKGLP_GPU_AFF_OBS = 6, - KFMLP_SIMPLE_GPU_AFF_OBS = 7, - KFMLP_GPU_AFF_OBS = 8, + PCP_SEM = 5, - MPCP_SEM = 9, - MPCP_VS_SEM = 10, - DPCP_SEM = 11, + RSM_MUTEX = 6, + IKGLP_SEM = 7, + KFMLP_SEM = 8, - PCP_SEM = 12, + IKGLP_SIMPLE_GPU_AFF_OBS = 9, + IKGLP_GPU_AFF_OBS = 10, + KFMLP_SIMPLE_GPU_AFF_OBS = 11, + KFMLP_GPU_AFF_OBS = 12, MAX_OBJ_TYPE = 12 } obj_type_t; diff --git a/litmus/edf_common.c b/litmus/edf_common.c index a1cdc10ea6f1..39ce1816ee04 100644 --- a/litmus/edf_common.c +++ b/litmus/edf_common.c @@ -185,11 +185,37 @@ int edf_higher_prio(struct task_struct* first, struct task_struct* second) return 1; } #endif - /* If the PIDs are the same then the task with the - * inherited priority wins. - */ - if (!second_task->rt_param.inh_task) { - return 1; + /* Something could be wrong if you get this far. */ + if (unlikely(first->rt_param.inh_task == + second->rt_param.inh_task)) { + /* Both tasks have the same inherited priority. + * Likely in a bug-condition. + */ + if (likely(first->pid < second->pid)) { + return 1; + } + else if (first->pid == second->pid) { + WARN_ON(1); + } + } + else { + /* At least one task must inherit */ + BUG_ON(!first->rt_param.inh_task && + !second->rt_param.inh_task); + + /* The task with the inherited priority wins. */ + if (!second->rt_param.inh_task) { + TRACE_CUR("unusual comparison: " + "first = %s/%d first_task = %s/%d " + "second = %s/%d second_task = %s/%d\n", + first->comm, first->pid, + (first->rt_param.inh_task) ? first->rt_param.inh_task->comm : "(nil)", + (first->rt_param.inh_task) ? first->rt_param.inh_task->pid : 0, + second->comm, second->pid, + (second->rt_param.inh_task) ? second->rt_param.inh_task->comm : "(nil)", + (second->rt_param.inh_task) ? second->rt_param.inh_task->pid : 0); + return 1; + } } } } diff --git a/litmus/fdso.c b/litmus/fdso.c index bac6a35fa17d..2411d16ba486 100644 --- a/litmus/fdso.c +++ b/litmus/fdso.c @@ -27,6 +27,12 @@ extern struct fdso_ops generic_affinity_ops; static const struct fdso_ops* fdso_ops[] = { &generic_lock_ops, /* FMLP_SEM */ &generic_lock_ops, /* SRP_SEM */ + + &generic_lock_ops, /* MPCP_SEM */ + &generic_lock_ops, /* MPCP_VS_SEM */ + &generic_lock_ops, /* DPCP_SEM */ + &generic_lock_ops, /* PCP_SEM */ + &generic_lock_ops, /* RSM_MUTEX */ &generic_lock_ops, /* IKGLP_SEM */ &generic_lock_ops, /* KFMLP_SEM */ @@ -36,10 +42,6 @@ static const struct fdso_ops* fdso_ops[] = { &generic_affinity_ops, /* KFMLP_SIMPLE_GPU_AFF_OBS */ &generic_affinity_ops, /* KFMLP_GPU_AFF_OBS */ #endif - &generic_lock_ops, /* MPCP_SEM */ - &generic_lock_ops, /* MPCP_VS_SEM */ - &generic_lock_ops, /* DPCP_SEM */ - &generic_lock_ops, /* PCP_SEM */ }; static int fdso_create(void** obj_ref, obj_type_t type, void* __user config) diff --git a/litmus/preempt.c b/litmus/preempt.c index 28368d5bc046..a2cae3648e15 100644 --- a/litmus/preempt.c +++ b/litmus/preempt.c @@ -26,10 +26,11 @@ void sched_state_will_schedule(struct task_struct* tsk) set_sched_state(PICKED_WRONG_TASK); else set_sched_state(WILL_SCHEDULE); - } else + } else { /* Litmus tasks should never be subject to a remote * set_tsk_need_resched(). */ - BUG_ON(is_realtime(tsk)); + //BUG_ON(is_realtime(tsk)); + } #ifdef CONFIG_PREEMPT_STATE_TRACE TRACE_TASK(tsk, "set_tsk_need_resched() ret:%p\n", -- cgit v1.2.2