Currently, the priority of tasks is modified directly in the scheduling
functions. Encapsulate priority updates to enable instrumentation of
priority changes. This will enable analysis of real-time scheduling
delays per thread priority, which cannot be performed accurately if we
only trace the priority of the currently scheduled processes.
The call sites that modify the priority of a task are mostly system
calls: sched_setscheduler, sched_setattr, sched_process_fork and
set_user_nice. Priority can also be dynamically boosted through
priority inheritance of rt_mutex by rt_mutex_setprio.
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- int prio, static_prio, normal_prio;
+ int prio; /* Updated through sched_set_prio() */
+ int static_prio, normal_prio;
unsigned int rt_priority;
const struct sched_class *sched_class;
struct sched_entity se;
unsigned int rt_priority;
const struct sched_class *sched_class;
struct sched_entity se;
+static void sched_set_prio(struct task_struct *p, int prio)
+{
+ p->prio = prio;
+}
+
/*
* fork()/clone()-time setup:
*/
/*
* fork()/clone()-time setup:
*/
/*
* Make sure we do not leak PI boosting priority to the child.
*/
/*
* Make sure we do not leak PI boosting priority to the child.
*/
- p->prio = current->normal_prio;
+ sched_set_prio(p, current->normal_prio);
/*
* Revert to default priority/policy on fork if requested.
/*
* Revert to default priority/policy on fork if requested.
} else if (PRIO_TO_NICE(p->static_prio) < 0)
p->static_prio = NICE_TO_PRIO(0);
} else if (PRIO_TO_NICE(p->static_prio) < 0)
p->static_prio = NICE_TO_PRIO(0);
- p->prio = p->normal_prio = __normal_prio(p);
+ p->normal_prio = __normal_prio(p);
+ sched_set_prio(p, p->normal_prio);
p->sched_class = &fair_sched_class;
}
p->sched_class = &fair_sched_class;
}
+ sched_set_prio(p, prio);
if (running)
p->sched_class->set_curr_task(rq);
if (running)
p->sched_class->set_curr_task(rq);
p->static_prio = NICE_TO_PRIO(nice);
set_load_weight(p);
old_prio = p->prio;
p->static_prio = NICE_TO_PRIO(nice);
set_load_weight(p);
old_prio = p->prio;
- p->prio = effective_prio(p);
+ sched_set_prio(p, effective_prio(p));
delta = p->prio - old_prio;
if (queued) {
delta = p->prio - old_prio;
if (queued) {
* sched_setscheduler().
*/
if (keep_boost)
* sched_setscheduler().
*/
if (keep_boost)
- p->prio = rt_mutex_get_effective_prio(p, normal_prio(p));
+ sched_set_prio(p, rt_mutex_get_effective_prio(p,
+ normal_prio(p)));
- p->prio = normal_prio(p);
+ sched_set_prio(p, normal_prio(p));
if (dl_prio(p->prio))
p->sched_class = &dl_sched_class;
if (dl_prio(p->prio))
p->sched_class = &dl_sched_class;