The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH V2 0/2] sched: Reduce the default slice to avoid tasks getting an extra tick
@ 2025-02-07  6:09 zihan zhou
  2025-02-07  6:14 ` [PATCH V2 1/2] " zihan zhou
  2025-02-07  6:24 ` [PATCH V2 2/2] " zihan zhou
  0 siblings, 2 replies; 7+ messages in thread
From: zihan zhou @ 2025-02-07  6:09 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, vschneid
  Cc: linux-kernel, zihan zhou

The old default value for slice is 0.75 msec * (1 + ilog(ncpus)) which
means that we have a default slice of
0.75 for 1 cpu
1.50 up to 3 cpus
2.25 up to 7 cpus
3.00 for 8 cpus and above.

For HZ=250 and HZ=100, because of the tick accuracy, the runtime of
tasks is far higher than their slice.
For HZ=1000 with 8 cpus or more, the accuracy of tick is already
satisfactory, but there is still an issue that tasks will get an extra
tick because the tick often arrives a little faster than expected. In this
case, the task can only wait until the next tick to consider that it has
reached its deadline, and will run 1ms longer.

vruntime + sysctl_sched_base_slice =     deadline
        |-----------|-----------|-----------|-----------|
             1ms          1ms         1ms         1ms
                   ^           ^           ^           ^
                 tick1       tick2       tick3       tick4(nearly 4ms)

There are two reasons for tick error: clockevent precision and the
CONFIG_IRQ_TIME_ACCOUNTING/CONFIG_PARAVIRT_TIME_ACCOUNTING.
with CONFIG_IRQ_TIME_ACCOUNTING every tick will be less than 1ms, but
even
without it, because of clockevent precision, tick still often less than
1ms.

In order to make scheduling more precise, we changed 0.75 to 0.70,
Using 0.70 instead of 0.75 should not change much for other configs
and would fix this issue:
0.70 for 1 cpu
1.40 up to 3 cpus
2.10 up to 7 cpus
2.8 for 8 cpus and above.

This does not guarantee that tasks can run the slice time accurately
every
time, but occasionally running an extra tick has little impact.

Changes from v1:
  - update sysctl_sched_base_slice with debugfs, limit its value and
    update normalized_sysctl_sched_base_slice.

zihan zhou (2):
  sched/fair: reduce the default slice.
  sched/debug: update sysctl_sched_base_slice with debugfs.

 kernel/sched/debug.c | 51 +++++++++++++++++++++++++++++++++++++++++++-
 kernel/sched/fair.c  | 47 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 93 insertions(+), 5 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-08  8:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-07  6:09 [PATCH V2 0/2] sched: Reduce the default slice to avoid tasks getting an extra tick zihan zhou
2025-02-07  6:14 ` [PATCH V2 1/2] " zihan zhou
2025-02-07 13:46   ` Vincent Guittot
2025-02-08  8:51     ` zihan zhou
2025-02-07  6:24 ` [PATCH V2 2/2] " zihan zhou
2025-02-08  1:04   ` kernel test robot
2025-02-08  5:59   ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox