| 1 |
% Credit2 Scheduler |
| 2 |
% Revision 2 |
| 3 |
|
| 4 |
\clearpage |
| 5 |
|
| 6 |
# Basics |
| 7 |
---------------- ---------------------------------------------------- |
| 8 |
Status: **Supported** |
| 9 |
|
| 10 |
Component: Hypervisor |
| 11 |
---------------- ---------------------------------------------------- |
| 12 |
|
| 13 |
# Overview |
| 14 |
|
| 15 |
Credit2 is the default virtual CPU (vCPU) scheduler available in the |
| 16 |
Xen hypervisor. |
| 17 |
|
| 18 |
Credit2 was designed as a general purpose scheduler, with particular |
| 19 |
focus on improving handling of mixed workloads, scalability and |
| 20 |
support for low latency applications inside VMs. |
| 21 |
|
| 22 |
# User details |
| 23 |
|
| 24 |
Xen supports multiple schedulers. As said, Credit2 is the default, so |
| 25 |
it is used automatically, unless the `sched=$SCHED` (with `$SCHED` |
| 26 |
different than `credit2`) parameter is passed to Xen via the |
| 27 |
bootloader. |
| 28 |
|
| 29 |
Other parameters are available for tuning the behavior of Credit2 |
| 30 |
(see `docs/misc/xen-command-line.pandoc` for a complete list and |
| 31 |
for their meaning). |
| 32 |
|
| 33 |
Once the system is live, for creating a cpupool with Credit2 as |
| 34 |
its scheduler, either compile a cpupool configuration file, as |
| 35 |
described in `docs/man/xlcpupool.cfg.pod.5` (and as exemplified |
| 36 |
in `tools/examples/cpupool`), or use just `xl` directly: |
| 37 |
|
| 38 |
xl cpupool-create name=\"pool1\" sched=\"credit2\" cpus=[1,2] |
| 39 |
|
| 40 |
Two kind of interactions with the scheduler are possible: |
| 41 |
|
| 42 |
* checking or changing the global parameters, via, e.g.: |
| 43 |
* `xl sched-credit2 -s` |
| 44 |
* `xl sched-credit2 -s -p pool1` |
| 45 |
* `xl sched-credit2 -s -r 100` |
| 46 |
* checking or changing a VM scheduling parameters, via, e.g.: |
| 47 |
* `xl sched-credit2 -d vm1` |
| 48 |
* `xl sched-credit2 -d vm1 -w 1024` |
| 49 |
|
| 50 |
# Technical details |
| 51 |
|
| 52 |
Implementation entirely lives in the hypervisor. Xen has a pluggable, |
| 53 |
hook based, architecture for schedulers. Thanks to this, Credit2 code |
| 54 |
is all contained in `xen/common/sched_credit2.c`. |
| 55 |
|
| 56 |
Global scheduling parameters, such as context switching rate |
| 57 |
limiting, is only available from Xen 4.8 onward. In libxl, the |
| 58 |
LIBXL_HAVE_SCHED_CREDIT2_PARAMS symbol is introduced to |
| 59 |
indicate their availability. |
| 60 |
|
| 61 |
# Testing |
| 62 |
|
| 63 |
Any change done in Credit2 wants to be tested by doing at least the |
| 64 |
following: |
| 65 |
|
| 66 |
* boot the system with `sched=credit2`, |
| 67 |
* create a few virtual machine and verify that they boot and can |
| 68 |
run some basic workload (e.g., login into them and run simple commands), |
| 69 |
* shutdown/reboot the virtual machines, |
| 70 |
* shutdown/reboot the system. |
| 71 |
|
| 72 |
Ideally, all the above steps should **also** be performed in a configuration |
| 73 |
where Credit2 is used as the scheduler of a cpupool, and by also doing the |
| 74 |
following: |
| 75 |
|
| 76 |
* move a virtual machine inside and outside a Credit2 cpupool. |
| 77 |
|
| 78 |
# Areas for improvement |
| 79 |
|
| 80 |
* vCPUs' reservations (similar to caps, but providing a vCPU with guarantees |
| 81 |
about some pCPU time it will always be able to execute for); |
| 82 |
* benchmarking for assessing the best combination of values for the various |
| 83 |
parameters (`sched_credit2_migrate_resist`, `credit2_balance_over`, |
| 84 |
`credit2_balance_under`) |
| 85 |
|
| 86 |
# Known issues |
| 87 |
|
| 88 |
* I/O oriented benchmarks (like network and disk throughput) have given |
| 89 |
contradictory and non-conclusive results so far. Need to run more of |
| 90 |
those. |
| 91 |
|
| 92 |
# References |
| 93 |
|
| 94 |
* "Scheduler development update", XenSummit Asia 2009 [whitepaper](http://www-archive.xenproject.org/files/xensummit_intel09/George_Dunlap.pdf) |
| 95 |
* "Scheduling in Xen" [XPDS15 Presentation](http://events.linuxfoundation.org/sites/events/files/slides/Faggioli_XenSummit.pdf) |
| 96 |
* "Scope and Performance of Credit-2 Scheduler" [XPDS16 Presentation](http://www.slideshare.net/xen_com_mgr/xpds16-scope-and-performance-of-credit2-scheduler-anshul-makkar-ctirix-systems-uk-ltd) |
| 97 |
* "The Credit2 Scheduler" [on the Xen-Project wiki](https://wiki.xenproject.org/wiki/Credit2_Scheduler_Development) |
| 98 |
* "Xen Project Schedulers" [on the Xen-Project wiki](https://wiki.xenproject.org/wiki/Xen_Project_Schedulers) |
| 99 |
|
| 100 |
# History |
| 101 |
|
| 102 |
------------------------------------------------------------------------ |
| 103 |
Date Revision Version Notes |
| 104 |
---------- -------- -------- ------------------------------------------- |
| 105 |
2016-10-14 1 Xen 4.8 Document written |
| 106 |
2017-11-6 2 Xen 4.10 Soft-affinity and caps implemented |
| 107 |
2019-02-7 3 Xen 4.12 Made the default scheduler |
| 108 |
---------- -------- -------- ------------------------------------------- |