Messages in this thread Patch in this message | | | From | qianjun.kernel@gmail ... | Subject | [PATCH 1/1] kernel/sched:use the enum code replace of the int variable | Date | Mon, 7 Sep 2020 21:05:02 +0800 |
| |
From: jun qian <qianjun.kernel@gmail.com>
It is hard to understand what the meaning of the value from the return value of wakeup_preempt_entity, so I fix it.
Signed-off-by: jun qian <qianjun.kernel@gmail.com> --- kernel/sched/fair.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 658aa7a..60bb184 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -86,6 +86,12 @@ const_debug unsigned int sysctl_sched_migration_cost = 500000UL; +enum preempt_curr_code { + NO_NEED_PREEMPT = -1, + MAY_NEED_PREEMPT = 0, + NEED_PREEMPT = 1, +}; + int sched_thermal_decay_shift; static int __init setup_sched_thermal_decay_shift(char *str) { @@ -4445,20 +4451,20 @@ static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se) second = curr; } - if (second && wakeup_preempt_entity(second, left) < 1) + if (second && wakeup_preempt_entity(second, left) != NEED_PREEMPT) se = second; } /* * Prefer last buddy, try to return the CPU to a preempted task. */ - if (cfs_rq->last && wakeup_preempt_entity(cfs_rq->last, left) < 1) + if (cfs_rq->last && wakeup_preempt_entity(cfs_rq->last, left) != NEED_PREEMPT) se = cfs_rq->last; /* * Someone really wants this to run. If it's not unfair, run it. */ - if (cfs_rq->next && wakeup_preempt_entity(cfs_rq->next, left) < 1) + if (cfs_rq->next && wakeup_preempt_entity(cfs_rq->next, left) != NEED_PREEMPT) se = cfs_rq->next; clear_buddies(cfs_rq, se); @@ -6822,9 +6828,9 @@ static unsigned long wakeup_gran(struct sched_entity *se) * g * |<--->|c * - * w(c, s1) = -1 - * w(c, s2) = 0 - * w(c, s3) = 1 + * w(c, s1) = NO_NEED_PREEMPT + * w(c, s2) = MAY_NEED_PREEMPT + * w(c, s3) = NEED_PREEMPT * */ static int @@ -6833,13 +6839,13 @@ static unsigned long wakeup_gran(struct sched_entity *se) s64 gran, vdiff = curr->vruntime - se->vruntime; if (vdiff <= 0) - return -1; + return NO_NEED_PREEMPT; gran = wakeup_gran(se); if (vdiff > gran) - return 1; + return NEED_PREEMPT; - return 0; + return MAY_NEED_PREEMPT; } static void set_last_buddy(struct sched_entity *se) @@ -6928,7 +6934,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_ find_matching_se(&se, &pse); update_curr(cfs_rq_of(se)); BUG_ON(!pse); - if (wakeup_preempt_entity(se, pse) == 1) { + if (wakeup_preempt_entity(se, pse) == NEED_PREEMPT) { /* * Bias pick_next to pick the sched entity that is * triggering this preemption. -- 1.8.3.1
| |