diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2018-11-05 06:21:55 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-11-12 00:17:52 -0500 |
commit | 1da1843f9f0334e2428308945d396ffecc2acfe1 (patch) | |
tree | 130afa62742c2b90671bd2e0e697b89d3aaeeda9 | |
parent | b5c0ce7bd1848892e2930f481828b6d7750231ed (diff) |
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: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Daniel 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.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/sched/core.c | 4 | ||||
-rw-r--r-- | kernel/sched/debug.c | 2 | ||||
-rw-r--r-- | kernel/sched/fair.c | 10 | ||||
-rw-r--r-- | kernel/sched/sched.h | 5 |
4 files changed, 13 insertions, 8 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 02a20ef196a6..5afb868f7339 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -697,7 +697,7 @@ static void set_load_weight(struct task_struct *p, bool update_load) | |||
697 | /* | 697 | /* |
698 | * SCHED_IDLE tasks get minimal weight: | 698 | * SCHED_IDLE tasks get minimal weight: |
699 | */ | 699 | */ |
700 | if (idle_policy(p->policy)) { | 700 | if (task_has_idle_policy(p)) { |
701 | load->weight = scale_load(WEIGHT_IDLEPRIO); | 701 | load->weight = scale_load(WEIGHT_IDLEPRIO); |
702 | load->inv_weight = WMULT_IDLEPRIO; | 702 | load->inv_weight = WMULT_IDLEPRIO; |
703 | p->se.runnable_weight = load->weight; | 703 | p->se.runnable_weight = load->weight; |
@@ -4199,7 +4199,7 @@ recheck: | |||
4199 | * Treat SCHED_IDLE as nice 20. Only allow a switch to | 4199 | * Treat SCHED_IDLE as nice 20. Only allow a switch to |
4200 | * SCHED_NORMAL if the RLIMIT_NICE would normally permit it. | 4200 | * SCHED_NORMAL if the RLIMIT_NICE would normally permit it. |
4201 | */ | 4201 | */ |
4202 | if (idle_policy(p->policy) && !idle_policy(policy)) { | 4202 | if (task_has_idle_policy(p) && !idle_policy(policy)) { |
4203 | if (!can_nice(p, task_nice(p))) | 4203 | if (!can_nice(p, task_nice(p))) |
4204 | return -EPERM; | 4204 | return -EPERM; |
4205 | } | 4205 | } |
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 6383aa6a60ca..02bd5f969b21 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c | |||
@@ -974,7 +974,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, | |||
974 | #endif | 974 | #endif |
975 | P(policy); | 975 | P(policy); |
976 | P(prio); | 976 | P(prio); |
977 | if (p->policy == SCHED_DEADLINE) { | 977 | if (task_has_dl_policy(p)) { |
978 | P(dl.runtime); | 978 | P(dl.runtime); |
979 | P(dl.deadline); | 979 | P(dl.deadline); |
980 | } | 980 | } |
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2cac9a469df4..d1f91e6efe51 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
@@ -6529,7 +6529,7 @@ wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se) | |||
6529 | 6529 | ||
6530 | static void set_last_buddy(struct sched_entity *se) | 6530 | static void set_last_buddy(struct sched_entity *se) |
6531 | { | 6531 | { |
6532 | if (entity_is_task(se) && unlikely(task_of(se)->policy == SCHED_IDLE)) | 6532 | if (entity_is_task(se) && unlikely(task_has_idle_policy(task_of(se)))) |
6533 | return; | 6533 | return; |
6534 | 6534 | ||
6535 | for_each_sched_entity(se) { | 6535 | for_each_sched_entity(se) { |
@@ -6541,7 +6541,7 @@ static void set_last_buddy(struct sched_entity *se) | |||
6541 | 6541 | ||
6542 | static void set_next_buddy(struct sched_entity *se) | 6542 | static void set_next_buddy(struct sched_entity *se) |
6543 | { | 6543 | { |
6544 | if (entity_is_task(se) && unlikely(task_of(se)->policy == SCHED_IDLE)) | 6544 | if (entity_is_task(se) && unlikely(task_has_idle_policy(task_of(se)))) |
6545 | return; | 6545 | return; |
6546 | 6546 | ||
6547 | for_each_sched_entity(se) { | 6547 | for_each_sched_entity(se) { |
@@ -6599,8 +6599,8 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ | |||
6599 | return; | 6599 | return; |
6600 | 6600 | ||
6601 | /* Idle tasks are by definition preempted by non-idle tasks. */ | 6601 | /* Idle tasks are by definition preempted by non-idle tasks. */ |
6602 | if (unlikely(curr->policy == SCHED_IDLE) && | 6602 | if (unlikely(task_has_idle_policy(curr)) && |
6603 | likely(p->policy != SCHED_IDLE)) | 6603 | likely(!task_has_idle_policy(p))) |
6604 | goto preempt; | 6604 | goto preempt; |
6605 | 6605 | ||
6606 | /* | 6606 | /* |
@@ -7021,7 +7021,7 @@ static int task_hot(struct task_struct *p, struct lb_env *env) | |||
7021 | if (p->sched_class != &fair_sched_class) | 7021 | if (p->sched_class != &fair_sched_class) |
7022 | return 0; | 7022 | return 0; |
7023 | 7023 | ||
7024 | if (unlikely(p->policy == SCHED_IDLE)) | 7024 | if (unlikely(task_has_idle_policy(p))) |
7025 | return 0; | 7025 | return 0; |
7026 | 7026 | ||
7027 | /* | 7027 | /* |
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 618577fc9aa8..b7a3147874e3 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h | |||
@@ -176,6 +176,11 @@ static inline bool valid_policy(int policy) | |||
176 | rt_policy(policy) || dl_policy(policy); | 176 | rt_policy(policy) || dl_policy(policy); |
177 | } | 177 | } |
178 | 178 | ||
179 | static inline int task_has_idle_policy(struct task_struct *p) | ||
180 | { | ||
181 | return idle_policy(p->policy); | ||
182 | } | ||
183 | |||
179 | static inline int task_has_rt_policy(struct task_struct *p) | 184 | static inline int task_has_rt_policy(struct task_struct *p) |
180 | { | 185 | { |
181 | return rt_policy(p->policy); | 186 | return rt_policy(p->policy); |