From: Hillf Danton <hdanton@sina.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mingo@kernel.org, vincent.guittot@linaro.org,
linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
bristot@redhat.com, corbet@lwn.net, qyousef@layalina.io,
chris.hyser@oracle.com, patrick.bellasi@matbug.net,
pjt@google.com, joshdon@google.com, timj@gnu.org,
kprateek.nayak@amd.com, yu.c.chen@intel.com,
youssefesmat@chromium.org, linux-mm@kvack.org,
joel@joelfernandes.org, efault@gmx.de
Subject: Re: [PATCH 15/17] [RFC] sched/eevdf: Sleeper bonus
Date: Thu, 30 Mar 2023 15:53:18 +0800 [thread overview]
Message-ID: <20230330075318.2892-1-hdanton@sina.com> (raw)
In-Reply-To: <20230328110354.641979416@infradead.org>
On 28 Mar 2023 11:26:37 +0200 Peter Zijlstra (Intel) <peterz@infradead.org>
> @@ -4878,22 +4878,55 @@ place_entity(struct cfs_rq *cfs_rq, stru
> if (WARN_ON_ONCE(!load))
> load = 1;
> lag = div_s64(lag, load);
> +
> + vruntime -= lag;
> + }
> +
> + /*
> + * Base the deadline on the 'normal' EEVDF placement policy in an
> + * attempt to not let the bonus crud below wreck things completely.
> + */
> + se->deadline = vruntime;
> +
> + /*
> + * The whole 'sleeper' bonus hack... :-/ This is strictly unfair.
> + *
> + * By giving a sleeping task a little boost, it becomes possible for a
> + * 50% task to compete equally with a 100% task. That is, strictly fair
> + * that setup would result in a 67% / 33% split. Sleeper bonus will
> + * change that to 50% / 50%.
> + *
> + * This thing hurts my brain, because tasks leaving with negative lag
> + * will move 'time' backward, so comparing against a historical
> + * se->vruntime is dodgy as heck.
> + */
> + if (sched_feat(PLACE_BONUS) &&
> + (flags & ENQUEUE_WAKEUP) && !(flags & ENQUEUE_MIGRATED)) {
> + /*
> + * If se->vruntime is ahead of vruntime, something dodgy
> + * happened and we cannot give bonus due to not having valid
> + * history.
> + */
> + if ((s64)(se->vruntime - vruntime) < 0) {
> + vruntime -= se->slice/2;
> + vruntime = max_vruntime(se->vruntime, vruntime);
> + }
> }
>
> - se->vruntime = vruntime - lag;
> + se->vruntime = vruntime;
>
> /*
> * When joining the competition; the exisiting tasks will be,
> * on average, halfway through their slice, as such start tasks
> * off with half a slice to ease into the competition.
> */
> - if (sched_feat(PLACE_DEADLINE_INITIAL) && initial)
> + if (sched_feat(PLACE_DEADLINE_INITIAL) && (flags & ENQUEUE_INITIAL))
> vslice /= 2;
>
> /*
> * EEVDF: vd_i = ve_i + r_i/w_i
> */
> - se->deadline = se->vruntime + vslice;
> + se->deadline += vslice;
> }
Because lag makes no sense for more-than-a-second sleepers, it is simpler to
make them able to preempt the current at the next tick, in line with what fork
can do at best.
next parent reply other threads:[~2023-03-30 7:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230328092622.062917921@infradead.org>
[not found] ` <20230328110354.641979416@infradead.org>
2023-03-30 7:53 ` Hillf Danton [this message]
[not found] ` <20230328110354.141543852@infradead.org>
2023-03-30 11:02 ` [PATCH 08/17] sched/fair: Implement an EEVDF like policy Hillf Danton
[not found] ` <20230328110354.562078801@infradead.org>
[not found] ` <CAKfTPtAkFBw5zt0+WK7dWBUE9OrbOOExG8ueUE6ogdCEQZhpXQ@mail.gmail.com>
2023-04-01 23:23 ` [PATCH 14/17] sched/eevdf: Better handle mixed slice length Hillf Danton
2023-04-02 2:40 ` Mike Galbraith
2023-04-02 6:28 ` Hillf Danton
[not found] ` <20230410031350.GA49280@maniforge>
2023-04-10 8:23 ` [PATCH 00/17] sched: EEVDF using latency-nice Hillf Danton
2023-04-11 10:15 ` Mike Galbraith
2023-04-11 13:33 ` Hillf Danton
2023-04-11 14:56 ` Mike Galbraith
[not found] ` <20230412025042.1413-1-hdanton@sina.com>
2023-04-12 4:05 ` Mike Galbraith
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=20230330075318.2892-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=chris.hyser@oracle.com \
--cc=corbet@lwn.net \
--cc=dietmar.eggemann@arm.com \
--cc=efault@gmx.de \
--cc=joel@joelfernandes.org \
--cc=joshdon@google.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=patrick.bellasi@matbug.net \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=qyousef@layalina.io \
--cc=rostedt@goodmis.org \
--cc=timj@gnu.org \
--cc=vincent.guittot@linaro.org \
--cc=youssefesmat@chromium.org \
--cc=yu.c.chen@intel.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