linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] sched/cfs: Fix pick_next_entity() implementation error
@ 2020-07-01 10:07 Zijun Hu
  2020-07-01 10:47 ` Vincent Guittot
  0 siblings, 1 reply; 3+ messages in thread
From: Zijun Hu @ 2020-07-01 10:07 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot
  Cc: dietmar.eggemann, rostedt, bsegall, mgorman, linux-kernel, zijuhu

sched_entity @se not static @left should be compared
to pick up @cfs_rq->next.

Signed-off-by: Zijun Hu <zijuhu@codeaurora.org>
---
 kernel/sched/fair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 658aa7a2ae6f..4790f2d851ad 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4452,13 +4452,13 @@ pick_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *curr)
 	/*
 	 * 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, se) < 1)
 		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, se) < 1)
 		se = cfs_rq->next;
 
 	clear_buddies(cfs_rq, se);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


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

* Re: [PATCH v1] sched/cfs: Fix pick_next_entity() implementation error
  2020-07-01 10:07 [PATCH v1] sched/cfs: Fix pick_next_entity() implementation error Zijun Hu
@ 2020-07-01 10:47 ` Vincent Guittot
  2020-07-01 11:43   ` Zijun Hu
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Guittot @ 2020-07-01 10:47 UTC (permalink / raw)
  To: Zijun Hu
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman, linux-kernel

On Wed, 1 Jul 2020 at 12:07, Zijun Hu <zijuhu@codeaurora.org> wrote:
>
> sched_entity @se not static @left should be compared
> to pick up @cfs_rq->next.

Could you elaborate why ?

left is the leftmost sched_entity and the one that should be used.

se != left means that left should be skipped after a yield and the
next se in the rbtree is not "far" from left although it has higher
vruntime

if we finally want to use last or next instead of se, we must ensure
that they are still not "far" from left otherwise you can promote a
sched entity that ends up having a really high vruntime

>
> Signed-off-by: Zijun Hu <zijuhu@codeaurora.org>
> ---
>  kernel/sched/fair.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 658aa7a2ae6f..4790f2d851ad 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4452,13 +4452,13 @@ pick_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *curr)
>         /*
>          * 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, se) < 1)
>                 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, se) < 1)
>                 se = cfs_rq->next;
>
>         clear_buddies(cfs_rq, se);
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
>

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

* Re: [PATCH v1] sched/cfs: Fix pick_next_entity() implementation error
  2020-07-01 10:47 ` Vincent Guittot
@ 2020-07-01 11:43   ` Zijun Hu
  0 siblings, 0 replies; 3+ messages in thread
From: Zijun Hu @ 2020-07-01 11:43 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman, linux-kernel

thanks for your explanation.
you are right. @lest should be used as reference point to compare.
Please ignore this patch.

On 7/1/2020 6:47 PM, Vincent Guittot wrote:
> On Wed, 1 Jul 2020 at 12:07, Zijun Hu <zijuhu@codeaurora.org> wrote:
>>
>> sched_entity @se not static @left should be compared
>> to pick up @cfs_rq->next.
> 
> Could you elaborate why ?
> 
> left is the leftmost sched_entity and the one that should be used.
> 
> se != left means that left should be skipped after a yield and the
> next se in the rbtree is not "far" from left although it has higher
> vruntime
> 
> if we finally want to use last or next instead of se, we must ensure
> that they are still not "far" from left otherwise you can promote a
> sched entity that ends up having a really high vruntime
> 
>>
>> Signed-off-by: Zijun Hu <zijuhu@codeaurora.org>
>> ---
>>  kernel/sched/fair.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 658aa7a2ae6f..4790f2d851ad 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -4452,13 +4452,13 @@ pick_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *curr)
>>         /*
>>          * 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, se) < 1)
>>                 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, se) < 1)
>>                 se = cfs_rq->next;
>>
>>         clear_buddies(cfs_rq, se);
>> --
>> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
>>

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

end of thread, other threads:[~2020-07-01 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 10:07 [PATCH v1] sched/cfs: Fix pick_next_entity() implementation error Zijun Hu
2020-07-01 10:47 ` Vincent Guittot
2020-07-01 11:43   ` Zijun Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).