All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] kernel/sched:use the enum code replace of the int variable
@ 2020-09-07 13:05 qianjun.kernel
  2020-09-11  9:06 ` peterz
  0 siblings, 1 reply; 2+ messages in thread
From: qianjun.kernel @ 2020-09-07 13:05 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, linux-kernel
  Cc: laoar.shao, jun qian

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] kernel/sched:use the enum code replace of the int variable
  2020-09-07 13:05 [PATCH 1/1] kernel/sched:use the enum code replace of the int variable qianjun.kernel
@ 2020-09-11  9:06 ` peterz
  0 siblings, 0 replies; 2+ messages in thread
From: peterz @ 2020-09-11  9:06 UTC (permalink / raw)
  To: qianjun.kernel
  Cc: mingo, juri.lelli, vincent.guittot, linux-kernel, laoar.shao

On Mon, Sep 07, 2020 at 09:05:02PM +0800, qianjun.kernel@gmail.com wrote:
> 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.

> @@ -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
>   *
>   */

Yeah, I don't think so. The function is a simple C style compare,
where negative is less, 0 is equal and positive is more than.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-11  9:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 13:05 [PATCH 1/1] kernel/sched:use the enum code replace of the int variable qianjun.kernel
2020-09-11  9:06 ` peterz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.