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 15Credit2 is the default virtual CPU (vCPU) scheduler available in the 16Xen hypervisor. 17 18Credit2 was designed as a general purpose scheduler, with particular 19focus on improving handling of mixed workloads, scalability and 20support for low latency applications inside VMs. 21 22# User details 23 24Xen supports multiple schedulers. As said, Credit2 is the default, so 25it is used automatically, unless the `sched=$SCHED` (with `$SCHED` 26different than `credit2`) parameter is passed to Xen via the 27bootloader. 28 29Other parameters are available for tuning the behavior of Credit2 30(see `docs/misc/xen-command-line.markdown` for a complete list and 31for their meaning). 32 33Once the system is live, for creating a cpupool with Credit2 as 34its scheduler, either compile a cpupool configuration file, as 35described in `docs/man/xlcpupool.cfg.pod.5` (and as exemplified 36in `tools/examples/cpupool`), or use just `xl` directly: 37 38 xl cpupool-create name=\"pool1\" sched=\"credit2\" cpus=[1,2] 39 40Two 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 52Implementation entirely lives in the hypervisor. Xen has a pluggable, 53hook based, architecture for schedulers. Thanks to this, Credit2 code 54is all contained in `xen/common/sched_credit2.c`. 55 56Global scheduling parameters, such as context switching rate 57limiting, is only available from Xen 4.8 onward. In libxl, the 58LIBXL_HAVE_SCHED_CREDIT2_PARAMS symbol is introduced to 59indicate their availability. 60 61# Testing 62 63Any change done in Credit2 wants to be tested by doing at least the 64following: 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 72Ideally, all the above steps should **also** be performed in a configuration 73where Credit2 is used as the scheduler of a cpupool, and by also doing the 74following: 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------------------------------------------------------------------------ 103Date Revision Version Notes 104---------- -------- -------- ------------------------------------------- 1052016-10-14 1 Xen 4.8 Document written 1062017-11-6 2 Xen 4.10 Soft-affinity and caps implemented 1072019-02-7 3 Xen 4.12 Made the default scheduler 108---------- -------- -------- ------------------------------------------- 109