Commit 1da1843f authored by Viresh Kumar's avatar Viresh Kumar Committed by Ingo Molnar

sched/core: Create task_has_idle_policy() helper

We already have task_has_rt_policy() and task_has_dl_policy() helpers,
create task_has_idle_policy() as well and update sched core to start
using it.

While at it, use task_has_dl_policy() at one more place.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Link: http://lkml.kernel.org/r/ce3915d5b490fc81af926a3b6bfb775e7188e005.1541416894.git.viresh.kumar@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent b5c0ce7b
...@@ -697,7 +697,7 @@ static void set_load_weight(struct task_struct *p, bool update_load) ...@@ -697,7 +697,7 @@ static void set_load_weight(struct task_struct *p, bool update_load)
/* /*
* SCHED_IDLE tasks get minimal weight: * SCHED_IDLE tasks get minimal weight:
*/ */
if (idle_policy(p->policy)) { if (task_has_idle_policy(p)) {
load->weight = scale_load(WEIGHT_IDLEPRIO); load->weight = scale_load(WEIGHT_IDLEPRIO);
load->inv_weight = WMULT_IDLEPRIO; load->inv_weight = WMULT_IDLEPRIO;
p->se.runnable_weight = load->weight; p->se.runnable_weight = load->weight;
...@@ -4199,7 +4199,7 @@ static int __sched_setscheduler(struct task_struct *p, ...@@ -4199,7 +4199,7 @@ static int __sched_setscheduler(struct task_struct *p,
* Treat SCHED_IDLE as nice 20. Only allow a switch to * Treat SCHED_IDLE as nice 20. Only allow a switch to
* SCHED_NORMAL if the RLIMIT_NICE would normally permit it. * SCHED_NORMAL if the RLIMIT_NICE would normally permit it.
*/ */
if (idle_policy(p->policy) && !idle_policy(policy)) { if (task_has_idle_policy(p) && !idle_policy(policy)) {
if (!can_nice(p, task_nice(p))) if (!can_nice(p, task_nice(p)))
return -EPERM; return -EPERM;
} }
......
...@@ -974,7 +974,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, ...@@ -974,7 +974,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
#endif #endif
P(policy); P(policy);
P(prio); P(prio);
if (p->policy == SCHED_DEADLINE) { if (task_has_dl_policy(p)) {
P(dl.runtime); P(dl.runtime);
P(dl.deadline); P(dl.deadline);
} }
......
...@@ -6529,7 +6529,7 @@ wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se) ...@@ -6529,7 +6529,7 @@ wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se)
static void set_last_buddy(struct sched_entity *se) static void set_last_buddy(struct sched_entity *se)
{ {
if (entity_is_task(se) && unlikely(task_of(se)->policy == SCHED_IDLE)) if (entity_is_task(se) && unlikely(task_has_idle_policy(task_of(se))))
return; return;
for_each_sched_entity(se) { for_each_sched_entity(se) {
...@@ -6541,7 +6541,7 @@ static void set_last_buddy(struct sched_entity *se) ...@@ -6541,7 +6541,7 @@ static void set_last_buddy(struct sched_entity *se)
static void set_next_buddy(struct sched_entity *se) static void set_next_buddy(struct sched_entity *se)
{ {
if (entity_is_task(se) && unlikely(task_of(se)->policy == SCHED_IDLE)) if (entity_is_task(se) && unlikely(task_has_idle_policy(task_of(se))))
return; return;
for_each_sched_entity(se) { for_each_sched_entity(se) {
...@@ -6599,8 +6599,8 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ ...@@ -6599,8 +6599,8 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
return; return;
/* Idle tasks are by definition preempted by non-idle tasks. */ /* Idle tasks are by definition preempted by non-idle tasks. */
if (unlikely(curr->policy == SCHED_IDLE) && if (unlikely(task_has_idle_policy(curr)) &&
likely(p->policy != SCHED_IDLE)) likely(!task_has_idle_policy(p)))
goto preempt; goto preempt;
/* /*
...@@ -7021,7 +7021,7 @@ static int task_hot(struct task_struct *p, struct lb_env *env) ...@@ -7021,7 +7021,7 @@ static int task_hot(struct task_struct *p, struct lb_env *env)
if (p->sched_class != &fair_sched_class) if (p->sched_class != &fair_sched_class)
return 0; return 0;
if (unlikely(p->policy == SCHED_IDLE)) if (unlikely(task_has_idle_policy(p)))
return 0; return 0;
/* /*
......
...@@ -176,6 +176,11 @@ static inline bool valid_policy(int policy) ...@@ -176,6 +176,11 @@ static inline bool valid_policy(int policy)
rt_policy(policy) || dl_policy(policy); rt_policy(policy) || dl_policy(policy);
} }
static inline int task_has_idle_policy(struct task_struct *p)
{
return idle_policy(p->policy);
}
static inline int task_has_rt_policy(struct task_struct *p) static inline int task_has_rt_policy(struct task_struct *p)
{ {
return rt_policy(p->policy); return rt_policy(p->policy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment