From: qianjun.kernel@gmail.com
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, linux-kernel@vger.kernel.org
Cc: laoar.shao@gmail.com, jun qian <qianjun.kernel@gmail.com>
Subject: [PATCH 1/1] kernel/sched:use the enum code replace of the int variable
Date: Mon, 7 Sep 2020 21:05:02 +0800 [thread overview]
Message-ID: <20200907130502.44200-1-qianjun.kernel@gmail.com> (raw)
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
next reply other threads:[~2020-09-07 13:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 13:05 qianjun.kernel [this message]
2020-09-11 9:06 ` peterz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200907130502.44200-1-qianjun.kernel@gmail.com \
--to=qianjun.kernel@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome