Skip to content

RFC sched,fair: flatten CPU controller runqueues

Rik van Riel lkml 5 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 RFC Latest15 patches 0 repliesNew
  2. v4 RFC15 patches 30 repliesSuperseded
  3. v3 RFC13 of 14 patches 13 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC10 patches14 repliesSuperseded
v18 patches15 repliesSuperseded

Changes in v5 from the cover letter

- drop patch that removes __sched_slice (Vincent Guittot)
- remove se->depth (Dietmar Eggemann)
- various other small cleanups and improvements suggested by people

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15sched: introduce task_se_h_load helperkernel/sched/fair.c+14 -140 replies
2/15sched: change /proc/sched_debug fieldskernel/sched/debug.c+2 -90 replies
3/15sched,fair: redefine runnable_load_avg as the sum of task_h_loadinclude/linux/sched.h kernel/sched/core.c kernel/sched/debug.c +3 more+56 -1450 replies
4/15sched,fair: move runnable_load_avg to cfs_rqinclude/linux/sched.h kernel/sched/debug.c kernel/sched/fair.c +1 more+6 -70 replies
5/15sched,fair: remove cfs_rqs from leaf_cfs_rq_list bottom upkernel/sched/fair.c+34 -10 replies
6/15sched,cfs: use explicit cfs_rq of parent se helperkernel/sched/fair.c+13 -40 replies
7/15sched,cfs: fix zero length timeslice calculationkernel/sched/fair.c+7 -00 replies
8/15sched,fair: refactor enqueue/dequeue_entitykernel/sched/fair.c+42 -220 replies
9/15sched,fair: add helper functions for flattened runqueuekernel/sched/fair.c+31 -00 replies
10/15sched,fair: flatten hierarchical runqueuesinclude/linux/sched.h kernel/sched/fair.c kernel/sched/pelt.c +2 more+170 -3440 replies
11/15sched,fair: flatten update_curr functionalitykernel/sched/fair.c+12 -120 replies
12/15sched,fair: propagate sum_exec_runtime up the hierarchyinclude/linux/sched.h kernel/sched/core.c kernel/sched/fair.c+22 -20 replies
13/15sched,fair: ramp up task_se_h_weight quicklykernel/sched/fair.c+6 -10 replies
14/15sched,fair: scale vdiff in wakeup_preempt_entitykernel/sched/fair.c+1 -00 replies
15/15sched,fair: remove se->depthinclude/linux/sched.h kernel/sched/fair.c+2 -490 replies

Reviews trailers per patch

3 of 15 patches have a Reviewed-by or Acked-by.

PatchJosef BacikRik van RielVincent Guittot
1/15R-b
2/15R-b
3/15
4/15
5/15A-b
6/15
7/15
8/15
9/15
10/15
11/15
12/15
13/15Not-yet-signed-off-by
14/15
15/15

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v5 thread

Cover letter [PATCH RFC v5 0/15] sched,fair: flatten CPU controller runqueues

The current implementation of the CPU controller uses hierarchical runqueues, where on wakeup a task is enqueued on its group's runqueue, the group is enqueued on the runqueue of the group above it, etc.

This increases a fairly large amount of overhead for workloads that do a lot of wakeups a second, especially given that the default systemd hierarchy is 2 or 3 levels deep.

This patch series is an attempt at reducing that overhead, by placing all the tasks on the same runqueue, and scaling the task priority by the priority of the group, which is calculated periodically.

My main TODO items for the next period of time are likely going to be testing, testing, and testing. I hope to find and flush out any corner case I can find, and make sure performance does not regress with any workloads, and hopefully improves some.

Other TODO items:
- More code cleanups.
- Remove some more now unused code.
- Reimplement CONFIG_CFS_BANDWIDTH.

Plan for the CONFIG_CFS_BANDWIDTH reimplementation:
- When a cgroup gets throttled, mark the cgroup and its children as throttled.
- When pick_next_entity finds a task that is on a throttled cgroup, stash it on the cgroup runqueue (which is not used for runnable tasks any more). Leave the vruntime unchanged, and adjust that runqueue's vruntime to be that of the left-most task.
- When a cgroup gets unthrottled, and has tasks on it, place it on a vruntime ordered heap separate from the main runqueue.
- Have pick_next_task_fair grab one task off that heap every time it is called, and the min vruntime of that heap is lower than the vruntime of the CPU's cfs_rq (or the CPU has no other runnable tasks).
- Place that selected task on the CPU's cfs_rq, renormalizing its vruntime with the GENTLE_FAIR_SLEEPERS logic. That should help interleave the already runnable tasks with the recently unthrottled group, and prevent thundering herd issues.
- If the group gets throttled again before all of its task had a chance to run, vruntime sorting ensures all the tasks in the throttled cgroup get a chance to run over time.

Changes from v4:
- drop patch that removes __sched_slice (Vincent Guittot)
- remove se->depth (Dietmar Eggemann)
- various other small cleanups and improvements suggested by people

Changes from v3:
- replace max_h_load with another hacky idea to ramp up the task_se_h_weight; I believe this new idea is wrong as well, but it will hopefully inspire a better solution (thanks to Peter Zijlstra)
- fix the ordering inside enqueue_task_fair to get task weights set up right (thanks to Peter Zijlstra)
- change wakeup_preempt_entity to reduce the number of task preemptions, hopefully resulting in behavior closer to what people configure in sysctl
- various other small cleanups and fixes

Changes from v2:
- fixed the web server performance regression, in a way vaguely similar to what Josef Bacik suggested (blame me for the implementation)
- removed some code duplication so the diffstat is redder than before
- propagate sum_exec_runtime up the tree, in preparation for CFS_BANDWIDTH
- small cleanups left and right

Changes from v1:
- use task_se_h_weight instead of task_se_h_load in calc_delta_fair and sched_slice, this seems to improve performance a little, but I still have some remaining regression to chase with our web server workload
- implement a number of the changes suggested by Dietmar Eggemann (still holding out for a better name for group_cfs_rq_of_parent)

This series applies on top of 5.2

 include/linux/sched.h |    8 
 kernel/sched/core.c   |    3 
 kernel/sched/debug.c  |   15 
 kernel/sched/fair.c   |  821 ++++++++++++++++++++------------------------------
 kernel/sched/pelt.c   |   68 +---
 kernel/sched/pelt.h   |    2 
 kernel/sched/sched.h  |    9 
 7 files changed, 367 insertions(+), 559 deletions(-)