From: Peter Zijlstra <peterz@infradead.org>
To: "weiqi (C)" <weiqi4@huawei.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
Mike Galbraith <umgwanakikbuti@gmail.com>
Subject: Re: [RFC] sched/fair: Align vruntime to last_se when curr_se's timeslice run out
Date: Thu, 6 Dec 2018 10:36:40 +0100 [thread overview]
Message-ID: <20181206093640.GB13538@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <f4f56ab5-8f9e-9ee4-4db8-370bc4aa2556@huawei.com>
On Wed, Dec 05, 2018 at 08:41:39PM +0800, weiqi (C) wrote:
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index ee271bb..1f61b9c 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4020,7 +4020,23 @@ static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
> ideal_runtime = sched_slice(cfs_rq, curr);
> delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
> if (delta_exec > ideal_runtime) {
> + struct rb_node *next = NULL;
> + struct rb_node *right_most = NULL;
> + struct sched_entity *last;
> resched_curr(rq_of(cfs_rq));
> +
> + /* always set to max vruntime */
> + if (cfs_rq->nr_running > 1) {
> + next = &curr->run_node;
> + do {
> + right_most = next;
> + next = rb_next(next);
> + } while (next);
> +
> + last = rb_entry(right_most,
> + struct sched_entity, run_node);
This you can obviously do better by tracking max_vruntime along side
min_vruntime. But for testing this should work fine I suppose.
> + curr->vruntime = last->vruntime + 1; // maybe +1 is not needed
This however is completely broken... you've basically reduced a virtual
runtime scheduler to a simple RR one.
Yes, place_entity() is not ideal, for starters we should not insert
relative to min_vruntime but to the 0-lag point (weighted average
vruntime). And IIRC, we should not let negative lag tasks reduce the
runqueue weight.
But those things are computationally expensive to do, so we fudged it.
> + }
> +
> /*
> * The current task ran long enough, ensure it doesn't get
> * re-elected due to buddy favours.
prev parent reply other threads:[~2018-12-06 9:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-05 12:41 weiqi (C)
2018-12-06 9:36 ` Peter Zijlstra [this message]
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=20181206093640.GB13538@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=umgwanakikbuti@gmail.com \
--cc=weiqi4@huawei.com \
/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
all inboxes | Powered by JetHome®