diff options
author | Josh Don <joshdon@google.com> | 2021-08-20 04:04:03 +0300 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2021-10-05 16:51:39 +0300 |
commit | 2cae3948edd488ebdef4deaf1d1043f92f47e665 (patch) | |
tree | 1eec087e76212e1c7a3d4aaf20ae8eb0f0d8e139 | |
parent | 51ce83ed523b00d58f2937ec014b12daaad55185 (diff) | |
download | linux-2cae3948edd488ebdef4deaf1d1043f92f47e665.tar.xz |
sched: adjust sleeper credit for SCHED_IDLE entities
Give reduced sleeper credit to SCHED_IDLE entities. As a result, woken
SCHED_IDLE entities will take longer to preempt normal entities.
The benefit of this change is to make it less likely that a newly woken
SCHED_IDLE entity will preempt a short-running normal entity before it
blocks.
We still give a small sleeper credit to SCHED_IDLE entities, so that
idle<->idle competition retains some fairness.
Example: With HZ=1000, spawned four threads affined to one cpu, one of
which was set to SCHED_IDLE. Without this patch, wakeup latency for the
SCHED_IDLE thread was ~1-2ms, with the patch the wakeup latency was
~5ms.
Signed-off-by: Josh Don <joshdon@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Link: https://lore.kernel.org/r/20210820010403.946838-5-joshdon@google.com
-rw-r--r-- | kernel/sched/fair.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d835061a9bd2..5457c8001c2a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4230,7 +4230,12 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) /* sleeps up to a single latency don't count. */ if (!initial) { - unsigned long thresh = sysctl_sched_latency; + unsigned long thresh; + + if (se_is_idle(se)) + thresh = sysctl_sched_min_granularity; + else + thresh = sysctl_sched_latency; /* * Halve their sleep time's effect, to allow |