Re: [PATCH 00/17] sched: EEVDF using latency-nice
From: Mike Galbraith
Date: Tue Apr 11 2023 - 06:16:27 EST
On Mon, 2023-04-10 at 16:23 +0800, Hillf Danton wrote:
>
> In order to only narrow down the poor performance reported, make a tradeoff
> between runtime and latency simply by restoring sysctl_sched_min_granularity
> at tick preempt, given the known order on the runqueue.
Tick preemption isn't the primary contributor to the scheduling delta,
it's wakeup preemption. If you look at the perf summaries of 5 minute
recordings on my little 8 rq box below, you'll see that the delta is
more than twice what a 250Hz tick could inflict. You could also just
turn off WAKEUP_PREEMPTION and watch the delta instantly peg negative.
Anyway...
Given we know preemption is markedly up, and as always a source of pain
(as well as gain), perhaps we can try to tamp it down a little without
inserting old constraints into the shiny new scheduler.
The dirt simple tweak below puts a dent in the sting by merely sticking
with whatever decision EEVDF last made until it itself invalidates that
decision. It still selects via the same math, just does so the tiniest
bit less frenetically.
---
kernel/sched/fair.c | 3 +++
kernel/sched/features.h | 6 ++++++
2 files changed, 9 insertions(+)
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -950,6 +950,9 @@ static struct sched_entity *pick_eevdf(s
if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr)))
curr = NULL;
+ if (sched_feat(GENTLE_EEVDF) && curr)
+ return curr;
+
while (node) {
struct sched_entity *se = __node_2_se(node);
--- a/kernel/sched/features.h
+++ b/kernel/sched/features.h
@@ -14,6 +14,12 @@ SCHED_FEAT(MINIMAL_VA, false)
SCHED_FEAT(VALIDATE_QUEUE, false)
/*
+ * Don't be quite so damn twitchy, once you select a champion let the
+ * poor bastard carry the baton until no longer eligible to do so.
+ */
+SCHED_FEAT(GENTLE_EEVDF, true)
+
+/*
* Prefer to schedule the task we woke last (assuming it failed
* wakeup-preemption), since its likely going to consume data we
* touched, increases cache locality.
perf.data.cfs
----------------------------------------------------------------------------------------------------------
Task | Runtime ms | Switches | Avg delay ms | Max delay ms | Sum delay ms |
----------------------------------------------------------------------------------------------------------
massive_intr:(8) |1665786.092 ms | 529819 | avg: 1.046 ms | max: 33.639 ms | sum:554226.960 ms |
dav1d-worker:(8) | 187982.593 ms | 448022 | avg: 0.881 ms | max: 35.806 ms | sum:394546.442 ms |
X:2503 | 102533.714 ms | 89729 | avg: 0.071 ms | max: 9.448 ms | sum: 6372.383 ms |
VizCompositorTh:5235 | 38717.241 ms | 76743 | avg: 0.632 ms | max: 24.308 ms | sum:48502.097 ms |
llvmpipe-0:(2) | 32520.412 ms | 42390 | avg: 1.041 ms | max: 19.804 ms | sum:44116.653 ms |
llvmpipe-1:(2) | 32374.548 ms | 35557 | avg: 1.247 ms | max: 17.439 ms | sum:44347.573 ms |
llvmpipe-2:(2) | 31579.168 ms | 34292 | avg: 1.312 ms | max: 16.775 ms | sum:45005.225 ms |
llvmpipe-3:(2) | 30478.664 ms | 33659 | avg: 1.375 ms | max: 16.863 ms | sum:46268.417 ms |
llvmpipe-7:(2) | 29778.002 ms | 30684 | avg: 1.543 ms | max: 17.384 ms | sum:47338.420 ms |
llvmpipe-4:(2) | 29741.774 ms | 32832 | avg: 1.433 ms | max: 18.571 ms | sum:47062.280 ms |
llvmpipe-5:(2) | 29462.794 ms | 32641 | avg: 1.455 ms | max: 19.802 ms | sum:47497.195 ms |
llvmpipe-6:(2) | 28367.114 ms | 32132 | avg: 1.514 ms | max: 16.562 ms | sum:48646.738 ms |
ThreadPoolForeg:(16) | 22238.667 ms | 66355 | avg: 0.353 ms | max: 46.477 ms | sum:23409.474 ms |
VideoFrameCompo:5243 | 17071.755 ms | 75223 | avg: 0.288 ms | max: 33.358 ms | sum:21650.918 ms |
chrome:(8) | 6478.351 ms | 47110 | avg: 0.486 ms | max: 28.018 ms | sum:22910.980 ms |
----------------------------------------------------------------------------------------------------------
TOTAL: |2317066.420 ms | 2221889 | | 46.477 ms | 1629736.515 ms |
----------------------------------------------------------------------------------------------------------
perf.data.eevdf
----------------------------------------------------------------------------------------------------------
Task | Runtime ms | Switches | Avg delay ms | Max delay ms | Sum delay ms |
----------------------------------------------------------------------------------------------------------
massive_intr:(8) |1673379.930 ms | 743590 | avg: 0.745 ms | max: 28.003 ms | sum:554041.093 ms |
dav1d-worker:(8) | 197647.514 ms | 1139053 | avg: 0.434 ms | max: 22.357 ms | sum:494377.980 ms |
X:2495 | 100741.946 ms | 114808 | avg: 0.191 ms | max: 8.583 ms | sum:21945.360 ms |
VizCompositorTh:6571 | 37705.863 ms | 74900 | avg: 0.479 ms | max: 16.464 ms | sum:35843.010 ms |
llvmpipe-6:(2) | 30757.126 ms | 38941 | avg: 1.448 ms | max: 18.529 ms | sum:56371.507 ms |
llvmpipe-3:(2) | 30658.127 ms | 40296 | avg: 1.405 ms | max: 24.791 ms | sum:56601.212 ms |
llvmpipe-4:(2) | 30456.388 ms | 40011 | avg: 1.419 ms | max: 23.840 ms | sum:56793.272 ms |
llvmpipe-2:(2) | 30395.971 ms | 40828 | avg: 1.394 ms | max: 19.195 ms | sum:56897.961 ms |
llvmpipe-5:(2) | 30346.432 ms | 39393 | avg: 1.445 ms | max: 21.747 ms | sum:56917.495 ms |
llvmpipe-1:(2) | 30275.694 ms | 41349 | avg: 1.378 ms | max: 20.765 ms | sum:56989.923 ms |
llvmpipe-7:(2) | 29768.515 ms | 37626 | avg: 1.532 ms | max: 20.649 ms | sum:57639.337 ms |
llvmpipe-0:(2) | 28931.905 ms | 42568 | avg: 1.378 ms | max: 20.942 ms | sum:58667.379 ms |
ThreadPoolForeg:(60) | 22598.216 ms | 131514 | avg: 0.342 ms | max: 36.105 ms | sum:44927.149 ms |
VideoFrameCompo:6587 | 16966.649 ms | 90751 | avg: 0.357 ms | max: 18.199 ms | sum:32379.045 ms |
chrome:(25) | 8862.695 ms | 75923 | avg: 0.308 ms | max: 30.821 ms | sum:23347.992 ms |
----------------------------------------------------------------------------------------------------------
TOTAL: |2331946.838 ms | 3471615 | | 36.105 ms | 1808071.407 ms |
----------------------------------------------------------------------------------------------------------
perf.data.eevdf+tweak
----------------------------------------------------------------------------------------------------------
Task | Runtime ms | Switches | Avg delay ms | Max delay ms | Sum delay ms |
----------------------------------------------------------------------------------------------------------
massive_intr:(8) |1687121.317 ms | 695518 | avg: 0.760 ms | max: 24.098 ms | sum:528302.626 ms |
dav1d-worker:(8) | 183514.008 ms | 922884 | avg: 0.489 ms | max: 32.093 ms | sum:451319.787 ms |
X:2489 | 99164.486 ms | 101585 | avg: 0.239 ms | max: 8.896 ms | sum:24295.253 ms |
VizCompositorTh:17881 | 37911.007 ms | 71122 | avg: 0.499 ms | max: 16.743 ms | sum:35460.994 ms |
llvmpipe-1:(2) | 29946.625 ms | 40320 | avg: 1.394 ms | max: 23.036 ms | sum:56222.367 ms |
llvmpipe-2:(2) | 29910.414 ms | 39677 | avg: 1.412 ms | max: 24.187 ms | sum:56011.791 ms |
llvmpipe-6:(2) | 29742.389 ms | 37822 | avg: 1.484 ms | max: 18.228 ms | sum:56109.947 ms |
llvmpipe-3:(2) | 29644.994 ms | 39155 | avg: 1.435 ms | max: 21.191 ms | sum:56202.636 ms |
llvmpipe-5:(2) | 29520.006 ms | 38037 | avg: 1.482 ms | max: 21.698 ms | sum:56373.679 ms |
llvmpipe-4:(2) | 29460.485 ms | 38562 | avg: 1.462 ms | max: 26.308 ms | sum:56389.022 ms |
llvmpipe-7:(2) | 29449.959 ms | 36308 | avg: 1.557 ms | max: 21.617 ms | sum:56547.129 ms |
llvmpipe-0:(2) | 29041.903 ms | 41207 | avg: 1.389 ms | max: 26.322 ms | sum:57239.666 ms |
ThreadPoolForeg:(16) | 22490.094 ms | 112591 | avg: 0.377 ms | max: 27.027 ms | sum:42414.618 ms |
VideoFrameCompo:17888 | 17385.895 ms | 86651 | avg: 0.367 ms | max: 19.350 ms | sum:31767.043 ms |
chrome:(8) | 6826.127 ms | 61487 | avg: 0.306 ms | max: 20.000 ms | sum:18835.879 ms |
----------------------------------------------------------------------------------------------------------
TOTAL: |2326181.115 ms | 3081183 | | 32.093 ms | 1737425.434 ms |
----------------------------------------------------------------------------------------------------------