Skip to content

Pluggable cpu scheduler framework

Con Kolivas lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest28 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/28Infrastructure for plugschedinclude/linux/sched.h include/linux/scheduler.h kernel/scheduler.c+234 -10 replies
2/28Export unique functionskernel/sched.c kernel/scheduler.c+74 -420 replies
3/28Make kick_process publickernel/sched.c kernel/scheduler.c+20 -960 replies
4/28Make preempt functions publickernel/scheduler.c+78 -00 replies
5/28Make sleep functions publickernel/sched.c kernel/scheduler.c+93 -930 replies
6/28Make nice syscalls publickernel/sched.c kernel/scheduler.c+278 -2680 replies
7/28Make more nice syscalls publickernel/sched.c kernel/scheduler.c+44 -450 replies
8/28Make conditional reschedule publickernel/sched.c kernel/scheduler.c+65 -660 replies
9/28Make yield privatekernel/sched.c kernel/scheduler.c+14 -140 replies
10/28Make io_schedule privateinclude/linux/sched.h include/linux/scheduler.h kernel/sched.c +1 more+20 -70 replies
11/28Make the family publickernel/sched.c kernel/scheduler.c+98 -980 replies
12/28Make miscellanous publickernel/sched.c kernel/scheduler.c+18 -180 replies
13/28Make wakeup functions publicinclude/linux/scheduler.h kernel/sched.c kernel/scheduler.c+134 -1280 replies
14/28add Makefile changeskernel/Makefile+2 -20 replies
15/28oom support functioninclude/linux/sched.h mm/oom_kill.c+2 -10 replies
16/28make rt_task privateinclude/linux/sched.h include/linux/scheduler.h kernel/sched.c +1 more+13 -10 replies
17/28Make unique task_struct variables privateinclude/linux/init_task.h include/linux/sched.h include/linux/scheduler.h +1 more+146 -1360 replies
18/28Remove private proc entryfs/proc/array.c+0 -20 replies
19/28Name and choose schedulerinclude/linux/scheduler.h kernel/sched.c kernel/scheduler.c+15 -10 replies
20/28Identify ingoschedinclude/linux/scheduler.h kernel/sched.c kernel/scheduler.c+15 -20 replies
21/28Move private macroinclude/linux/sched.h kernel/sched.c+11 -70 replies
22/28add boot messageinit/main.c+2 -00 replies
23/28Make scheduler selection configurableinclude/linux/sched.h include/linux/scheduler.h init/Kconfig +3 more+82 -80 replies
24/28Make public parts of sched_domainsinclude/linux/sched.h kernel/sched.c kernel/scheduler.c+52 -530 replies
25/28Make public parts of schedstatsinclude/linux/sched.h include/linux/scheduler.h kernel/sched.c +1 more+45 -270 replies
26/28Add description to procfs/proc/proc_misc.c+14 -00 replies
27/28Make new timekeeping privateinclude/linux/scheduler.h kernel/sched.c kernel/scheduler.c+25 -30 replies
28/28Make new sched_domains sysctls privateinclude/linux/scheduler.h kernel/sched.c kernel/scheduler.c+18 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH][plugsched 0/28] Pluggable cpu scheduler framework

With the recent interest in varying the cpu schedulers in linux, this set of patches provides a modular framework for adding multiple boot-time selectable cpu schedulers. William Lee Irwin III came up with the original design and I based my patchset on that.

This code was designed to touch the least number of files, be completely arch-independant, and allow extra schedulers to be coded in by only touching Kconfig, scheduler.c and scheduler.h. It should incur no overhead when run and will allow you to compile in only the scheduler(s) you desire. This allows, for example, embedded hardware to have a tiny new scheduler that takes up minimal code space.

This works by taking all functions that will be common to all scheduler designs and moving them from kernel/sched.c into kernel/scheduler.c.

Then it adds the scheduler driver struct into scheduler.h which is a set of pointers to functions that will all have per-scheduler versions. include/linux/scheduler.h has the definitions for the scheduler driver structure

kernel/sched.c remains as the default cpu scheduler in the same place to minimise the patch size and portability of the patch set.

All variables of the task_struct that could be unique to a different scheduler are now in a private struct held within a union in task_struct. rt_priority and static_priority are kept global for userspace interface and for the possibility of adding run-time switching later on.

The main disadvantage of this design is that there will (initially) be a
lot of code duplication by different scheduler designs in their own
private space. This will mean that if a new scheduler uses the same smp balancing algorithm then it will need to be modified to keep in sync with changes to the default scheduler. If, for example, you modified just the dynamic priority component of the current scheduler and left the runqueue and task_struct the same, you could make it depend on the default scheduler and point most functions to that one.

However, the same disadvantage can be a major advantage. The fact that so much of the scheduler is privatised means that wildly different designs can be plugged in without any reference to the number of runqueues, frame schedulers could be plugged in, shared runqueues (eg on numa designs), and we could even keep new balancing in a "developing" arm of the scheduler that can be booted by testers and so on.

What is left to do is add a per-scheduler entry into /sys which can be used to modify the unique controls each scheduler has, and write up some documentation for this and staircase.

Anyway the patches will follow shortly, and then (not surprisingly) a port of the staircase scheduler to plug into this framework which can also be used as an example for others wishing to code up or port their schedulers.

While I have tried to build this on as many configurations as possible, I am sure breakage will creep in given the type of modification so I apologise in advance.

Patches for those who want to download them separately here:

http://ck.kolivas.org/patches/plugsched/

Here is a diffstat of the patches rolled up.

 fs/proc/array.c           |    2
 fs/proc/proc_misc.c       |   14
 include/linux/init_task.h |    5
 include/linux/sched.h     |   39 -
 include/linux/scheduler.h |   83 ++
 init/Kconfig              |   37 +
 init/main.c               |   10
 kernel/Makefile           |    3
 kernel/sched.c            | 1313
++++++++--------------------------------------
 kernel/scheduler.c        | 1201
++++++++++++++++++++++++++++++++++++++++++
 mm/oom_kill.c             |    2
 11 files changed, 1599 insertions(+), 1110 deletions(-)

Thanks to William Lee Irwin III for design help, Alex Nyberg for testing and a bootload of others for ideas and help with the coding.

Cheers,
Con