Skip to content

Commit 76cae9d

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/fair: Commit to lag based placement
Removes the FAIR_SLEEPERS code in favour of the new LAG based placement. Specifically, the whole FAIR_SLEEPER thing was a very crude approximation to make up for the lack of lag based placement, specifically the 'service owed' part. This is important for things like 'starve' and 'hackbench'. One side effect of FAIR_SLEEPER is that it caused 'small' unfairness, specifically, by always ignoring up-to 'thresh' sleeptime it would have a 50%/50% time distribution for a 50% sleeper vs a 100% runner, while strictly speaking this should (of course) result in a 33%/67% split (as CFS will also do if the sleep period exceeds 'thresh'). Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 147f3ef commit 76cae9d

File tree

2 files changed

+1
-66
lines changed

2 files changed

+1
-66
lines changed

kernel/sched/fair.c

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5068,29 +5068,6 @@ static void check_spread(struct cfs_rq *cfs_rq, struct sched_entity *se)
50685068
#endif
50695069
}
50705070

5071-
static inline bool entity_is_long_sleeper(struct sched_entity *se)
5072-
{
5073-
struct cfs_rq *cfs_rq;
5074-
u64 sleep_time;
5075-
5076-
if (se->exec_start == 0)
5077-
return false;
5078-
5079-
cfs_rq = cfs_rq_of(se);
5080-
5081-
sleep_time = rq_clock_task(rq_of(cfs_rq));
5082-
5083-
/* Happen while migrating because of clock task divergence */
5084-
if (sleep_time <= se->exec_start)
5085-
return false;
5086-
5087-
sleep_time -= se->exec_start;
5088-
if (sleep_time > ((1ULL << 63) / scale_load_down(NICE_0_LOAD)))
5089-
return true;
5090-
5091-
return false;
5092-
}
5093-
50945071
static void
50955072
place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
50965073
{
@@ -5172,43 +5149,9 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
51725149
if (WARN_ON_ONCE(!load))
51735150
load = 1;
51745151
lag = div_s64(lag, load);
5175-
5176-
vruntime -= lag;
5177-
}
5178-
5179-
if (sched_feat(FAIR_SLEEPERS)) {
5180-
5181-
/* sleeps up to a single latency don't count. */
5182-
if (!initial) {
5183-
unsigned long thresh;
5184-
5185-
if (se_is_idle(se))
5186-
thresh = sysctl_sched_min_granularity;
5187-
else
5188-
thresh = sysctl_sched_latency;
5189-
5190-
/*
5191-
* Halve their sleep time's effect, to allow
5192-
* for a gentler effect of sleepers:
5193-
*/
5194-
if (sched_feat(GENTLE_FAIR_SLEEPERS))
5195-
thresh >>= 1;
5196-
5197-
vruntime -= thresh;
5198-
}
5199-
5200-
/*
5201-
* Pull vruntime of the entity being placed to the base level of
5202-
* cfs_rq, to prevent boosting it if placed backwards. If the entity
5203-
* slept for a long time, don't even try to compare its vruntime with
5204-
* the base as it may be too far off and the comparison may get
5205-
* inversed due to s64 overflow.
5206-
*/
5207-
if (!entity_is_long_sleeper(se))
5208-
vruntime = max_vruntime(se->vruntime, vruntime);
52095152
}
52105153

5211-
se->vruntime = vruntime;
5154+
se->vruntime = vruntime - lag;
52125155

52135156
/*
52145157
* When joining the competition; the exisiting tasks will be,

kernel/sched/features.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22

3-
/*
4-
* Only give sleepers 50% of their service deficit. This allows
5-
* them to run sooner, but does not allow tons of sleepers to
6-
* rip the spread apart.
7-
*/
8-
SCHED_FEAT(FAIR_SLEEPERS, false)
9-
SCHED_FEAT(GENTLE_FAIR_SLEEPERS, true)
10-
113
/*
124
* Using the avg_vruntime, do the right thing and preserve lag across
135
* sleep+wake cycles. EEVDF placement strategy #1, #2 if disabled.

0 commit comments

Comments
 (0)