* [PATCH] sched/fair: Fix update_min_vruntime() to get proper min_vruntime
@ 2016-09-06 5:05 Byungchul Park
2016-09-06 8:48 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Byungchul Park @ 2016-09-06 5:05 UTC (permalink / raw)
To: peterz, mingo; +Cc: linux-kernel
I am sorry for making you confused. The patch I posted one year ago,
Commit 97a7142 'sched/fair: Make update_min_vruntime() more readable',
has a bug, which you picked up.
Please add this patch to fix it, or combine these two patches into
one, or revert commit 97a7142. Whatever you want. Sorry.
Thank you,
Byungchul
-----8<-----
>From 295895be8befbab040d6054bb8186c03daabcedd Mon Sep 17 00:00:00 2001
From: Byungchul Park <byungchul.park@lge.com>
Date: Tue, 6 Sep 2016 12:22:26 +0900
Subject: [PATCH] sched/fair: Fix update_min_vruntime() to get proper
min_vruntime
Commit 97a7142 'sched/fair: Make update_min_vruntime() more readable'
introduces a bug that cfs_rq gets a wrong min_vruntime if
!cfs_rq->rb_leftmost && cfs_rq->curr. This fixes it and makes it more
readable and simple.
Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
kernel/sched/fair.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a6820b3..0a5f666b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -462,21 +462,20 @@ static inline int entity_before(struct sched_entity *a,
static void update_min_vruntime(struct cfs_rq *cfs_rq)
{
- u64 vruntime = cfs_rq->min_vruntime;
-
- if (cfs_rq->rb_leftmost) {
- struct sched_entity *se = rb_entry(cfs_rq->rb_leftmost,
- struct sched_entity,
- run_node);
+ u64 vruntime = U64_MAX;
- vruntime = se->vruntime;
- }
+ if (cfs_rq->rb_leftmost)
+ vruntime = rb_entry(cfs_rq->rb_leftmost,
+ struct sched_entity,
+ run_node)->vruntime;
if (cfs_rq->curr)
vruntime = min_vruntime(vruntime, cfs_rq->curr->vruntime);
/* ensure we never gain time by being placed backwards. */
- cfs_rq->min_vruntime = max_vruntime(cfs_rq->min_vruntime, vruntime);
+ if (vruntime != U64_MAX)
+ cfs_rq->min_vruntime = max_vruntime(cfs_rq->min_vruntime, vruntime);
+
#ifndef CONFIG_64BIT
smp_wmb();
cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/fair: Fix update_min_vruntime() to get proper min_vruntime
2016-09-06 5:05 [PATCH] sched/fair: Fix update_min_vruntime() to get proper min_vruntime Byungchul Park
@ 2016-09-06 8:48 ` Peter Zijlstra
2016-09-09 2:46 ` Byungchul Park
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2016-09-06 8:48 UTC (permalink / raw)
To: Byungchul Park; +Cc: mingo, linux-kernel
On Tue, Sep 06, 2016 at 02:05:17PM +0900, Byungchul Park wrote:
> From 295895be8befbab040d6054bb8186c03daabcedd Mon Sep 17 00:00:00 2001
> From: Byungchul Park <byungchul.park@lge.com>
> Date: Tue, 6 Sep 2016 12:22:26 +0900
> Subject: [PATCH] sched/fair: Fix update_min_vruntime() to get proper
> min_vruntime
>
> Commit 97a7142 'sched/fair: Make update_min_vruntime() more readable'
> introduces a bug that cfs_rq gets a wrong min_vruntime if
> !cfs_rq->rb_leftmost && cfs_rq->curr. This fixes it and makes it more
> readable and simple.
Urgh, I actually stared at that patch for quite a time and somehow
convinced myself it was good. I actually considered that scenario I
think.
/me thinks more..
Argh, I'm an idiot, you're right. By using min_vruntime() on
cfs_rq->curr we take the leftmost and fail to advance min_vruntime in
that case.
I'll ask Ingo to take the patch out.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/fair: Fix update_min_vruntime() to get proper min_vruntime
2016-09-06 8:48 ` Peter Zijlstra
@ 2016-09-09 2:46 ` Byungchul Park
0 siblings, 0 replies; 3+ messages in thread
From: Byungchul Park @ 2016-09-09 2:46 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: mingo, linux-kernel
On Tue, Sep 06, 2016 at 10:48:39AM +0200, Peter Zijlstra wrote:
> On Tue, Sep 06, 2016 at 02:05:17PM +0900, Byungchul Park wrote:
> > From 295895be8befbab040d6054bb8186c03daabcedd Mon Sep 17 00:00:00 2001
> > From: Byungchul Park <byungchul.park@lge.com>
> > Date: Tue, 6 Sep 2016 12:22:26 +0900
> > Subject: [PATCH] sched/fair: Fix update_min_vruntime() to get proper
> > min_vruntime
> >
> > Commit 97a7142 'sched/fair: Make update_min_vruntime() more readable'
> > introduces a bug that cfs_rq gets a wrong min_vruntime if
> > !cfs_rq->rb_leftmost && cfs_rq->curr. This fixes it and makes it more
> > readable and simple.
>
> Urgh, I actually stared at that patch for quite a time and somehow
> convinced myself it was good. I actually considered that scenario I
> think.
>
> /me thinks more..
>
> Argh, I'm an idiot, you're right. By using min_vruntime() on
> cfs_rq->curr we take the leftmost and fail to advance min_vruntime in
> that case.
>
> I'll ask Ingo to take the patch out.
Ok. But I think the combined one is more readable.
Don't you think so. It's ok even if you don't.
Thank you,
Byungchul
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-09 2:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 5:05 [PATCH] sched/fair: Fix update_min_vruntime() to get proper min_vruntime Byungchul Park
2016-09-06 8:48 ` Peter Zijlstra
2016-09-09 2:46 ` Byungchul Park
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.