The helper is supposed to set the effective prio of a given task. It will be used by the following patch.
In fact, we do not invent anything in this patch, because there is rt_mutex_setprio, which already does the job. This patch only adds a new wrapper. Signed-off-by: Vladimir Davydov <[email protected]> --- include/linux/sched.h | 10 ++++++++++ kernel/rtmutex.c | 5 +++++ kernel/sched/core.c | 8 +++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 3bd2f50822b8..12dc066e0681 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2151,6 +2151,16 @@ extern int sched_setscheduler(struct task_struct *, int, const struct sched_param *); extern int sched_setscheduler_nocheck(struct task_struct *, int, const struct sched_param *); +extern void __sched_boost_task(struct task_struct *p, int prio); +static inline void sched_boost_task(struct task_struct *p, int prio) +{ + unsigned long flags; + + raw_spin_lock_irqsave(&p->pi_lock, flags); + if (p->prio != prio) + __sched_boost_task(p, prio); + raw_spin_unlock_irqrestore(&p->pi_lock, flags); +} extern struct task_struct *idle_task(int cpu); /** * is_idle_task - is the specified task an idle task? diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c index 1e09308bf2a1..7776b0f17f8a 100644 --- a/kernel/rtmutex.c +++ b/kernel/rtmutex.c @@ -106,6 +106,11 @@ int rt_mutex_getprio(struct task_struct *task) task->normal_prio); } +void rt_mutex_setprio(struct task_struct *p, int prio) +{ + __sched_boost_task(p, prio); +} + /* * Adjust the priority of a task, after its pi_waiters got modified. * diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 77d330cd2b79..85343cb3f269 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3978,10 +3978,8 @@ long __sched sleep_on_timeout(wait_queue_head_t *q, long timeout) } EXPORT_SYMBOL(sleep_on_timeout); -#ifdef CONFIG_RT_MUTEXES - /* - * rt_mutex_setprio - set the current priority of a task + * __sched_boot_task - set the current priority of a task * @p: task * @prio: prio value (kernel-internal form) * @@ -3990,7 +3988,7 @@ EXPORT_SYMBOL(sleep_on_timeout); * * Used by the rt_mutex code to implement priority inheritance logic. */ -void rt_mutex_setprio(struct task_struct *p, int prio) +void __sched_boost_task(struct task_struct *p, int prio) { int oldprio, on_rq, running; struct rq *rq; @@ -4044,7 +4042,7 @@ void rt_mutex_setprio(struct task_struct *p, int prio) out_unlock: __task_rq_unlock(rq); } -#endif + void set_user_nice(struct task_struct *p, long nice) { int old_prio, delta, on_rq; -- 2.1.4 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
