realtime-preempt: update inherited priorities on setscheduler
PATCH 1/1 realtime-preempt: update inherited priorities on setscheduler
The following patch (against realtime-preempt v0.7.39-02) makes setscheduler calls behave properly with respect to priority inheritance. If a task's priority is raised, it will be propagated to tasks on which it is blocked. If it is lowered, it will check whether there's a higher priority that could be inherited, and whether priorities that had been inherited from the changing task need to be changed.
It also prevents the scheduler from overwriting the RT priority (which may be inherited) with the base priority in places where recalculation of non-RT priority is done.
Adjusting the priority inheritance chain on setscheduler is important for dynamic priority schemes, where the proper functioning of the system may depend on setscheduler taking effect within a bounded amount of time.
For the same reason, it'd also be best to revoke an inheritance as soon as the lender aborts a down_interruptible(), but this patch does not address that issue.
include/linux/sched.h renamed from include/linux/sched.h.ORIG +4 -0
@@ -945,6 +945,10 @@extern void mutex_setprio (task_t *p,int prio);extern int mutex_getprio (task_t *p); +void mutex_recalc_pi (task_t *p,int force_first_iteration); +void mutex_lock_pi (unsigned long *flags); +void mutex_unlock_pi (unsigned long *flags); +void yield (void );/*
kernel/sched.c renamed from kernel/sched.c.ORIG +40 -1
70 lines not on this page · raw message
kernel/rt.c renamed from kernel/rt.c.ORIG +123 -56
238 lines not on this page · raw message
kernel/sched.c line 791
Quoted 6 lines · Scott Wood
kernel/sched.c renamed from kernel/sched.c.ORIG +5
-1- p->prio =effective_prio (p); +/* Don't overwrite an inherited RT priority with the static +RT priority. */ + +if (!rt_task (p)) + p->prio =effective_prio (p);
are you sure this is needed? The -RT code currently does this:
static int effective_prio(task_t *p)
{
if (rt_task(p))
return p->prio;
return __effective_prio(p);}
i.e. if it's an RT task then 'effective priority' is whatever it has right now. I.e. 'p->prio = effective_prio(p)' will have no effect for RT tasks. PI would not be working at all if we were overwriting the inherited priority.
Ingo
Quoted 12 lines · Ingo Molnar
kernel/sched.c line 791
Quoted 6 lines · Scott Wood
kernel/sched.c renamed from kernel/sched.c.ORIG +5
-1- p->prio =effective_prio (p); +/* Don't overwrite an inherited RT priority with the static +RT priority. */ + +if (!rt_task (p)) + p->prio =effective_prio (p);are you sure this is needed? The -RT code currently does this:
Quoted 6 lines
static int
effective_prio(task_t *p){ if (rt_task(p)) return p->prio; return __effective_prio(p);}
I must have read-then-misremembered it as recalculating the prio from rt_priority, or else been worried about some race that doesn't appear possible. The change isn't needed.
-Scott