| 1 |
% Credit Scheduler |
| 2 |
% Revision 1 |
| 3 |
|
| 4 |
\clearpage |
| 5 |
|
| 6 |
# Basics |
| 7 |
---------------- ---------------------------------------------------- |
| 8 |
Status: **Supported** |
| 9 |
|
| 10 |
Component: Hypervisor |
| 11 |
---------------- ---------------------------------------------------- |
| 12 |
|
| 13 |
# Overview |
| 14 |
|
| 15 |
Credit (also known as Credit1) is the old virtual CPU (vCPU) scheduler |
| 16 |
of the Xen hypervisor. |
| 17 |
|
| 18 |
It is a general purpose, weighted fair-share scheduler. |
| 19 |
|
| 20 |
# User details |
| 21 |
|
| 22 |
Xen supports multiple schedulers. Credit is no longer the default. In |
| 23 |
order to use it as the Xen scheduler the following parameter should be |
| 24 |
passed to the hypervisor at boot: |
| 25 |
|
| 26 |
`sched=credit` |
| 27 |
|
| 28 |
Once the system is live, for creating a cpupool with Credit as its |
| 29 |
scheduler, either compile a cpupool configuration file, as described |
| 30 |
in `docs/man/xlcpupool.cfg.pod.5` (and as exemplified in |
| 31 |
`tools/examples/cpupool`), or use just `xl` directly: |
| 32 |
|
| 33 |
xl cpupool-create name=\"pool1\" sched=\"credit\" cpus=[4,8] |
| 34 |
|
| 35 |
Two kind of interactions with the scheduler are possible: |
| 36 |
|
| 37 |
* checking or changing the global parameters, via, e.g.: |
| 38 |
* `xl sched-credit -s` |
| 39 |
* `xl sched-credit -s -p pool1` |
| 40 |
* `xl sched-credit -s -t 20` |
| 41 |
* checking or changing a VM's scheduling parameters, via, e.g.: |
| 42 |
* `xl sched-credit -d vm1` |
| 43 |
* `xl sched-credit -d vm1 -w 512` |
| 44 |
|
| 45 |
# Technical details |
| 46 |
|
| 47 |
Implementation entirely lives in the hypervisor. Xen has a pluggable, |
| 48 |
hook based, architecture for schedulers. Thanks to this, Credit code |
| 49 |
is all contained in `xen/common/sched_credit.c`. |
| 50 |
|
| 51 |
# Limitations |
| 52 |
|
| 53 |
In Credit, a vCPU has a priority, a status (i.e., active or inactive), |
| 54 |
a weight and some credits... and all these things interact in a rather |
| 55 |
involved way. Also, with years of use, things have gotten even more |
| 56 |
complex (due to, e.g., the introduction of boosting, caps and vCPU |
| 57 |
soft-affinity). |
| 58 |
|
| 59 |
Dealing with such complexity is starting to be an issue. Odd behavior |
| 60 |
or subtle scheduling anomalies, that is not always possible to act upon, |
| 61 |
have been identified already. [1][2][3] |
| 62 |
|
| 63 |
A certain lack of scalability and difficulties and weakness in dealing |
| 64 |
with mixed workloads and VMs with low latency requirements are other |
| 65 |
known problems. [4] For all these reasons, effort is ongoing to have |
| 66 |
Credit2 become the new default scheduler. |
| 67 |
|
| 68 |
# Testing |
| 69 |
|
| 70 |
Any change to Credit code must to be tested by doing at least the following: |
| 71 |
|
| 72 |
* create a few virtual machine and verify that they boot and can |
| 73 |
run some basic workload (e.g., login into them and run simple commands), |
| 74 |
* shutdown/reboot the virtual machines, |
| 75 |
* shutdown the system. |
| 76 |
|
| 77 |
Ideally, all the above steps should **also** be performed in a configuration |
| 78 |
that includes cpupools, better if with pools using different schedulers, and |
| 79 |
by also doing the following: |
| 80 |
|
| 81 |
* move the virtual machines between cpupools. |
| 82 |
|
| 83 |
# References |
| 84 |
|
| 85 |
* [potential non-ideal behavior on hyperthreaded systems](https://lists.xenproject.org/archives/html/xen-devel/2014-07/msg01848.html) [1] |
| 86 |
* [long standing BOOST vs. migration bug](https://lists.xen.org/archives/html/xen-devel/2015-10/msg02851.html) [2] |
| 87 |
* [priority handling issues](https://lists.xenproject.org/archives/html/xen-devel/2016-05/msg01362.html) [3] |
| 88 |
* "Scheduler development update", XenSummit Asia 2009 [whitepaper](http://www-archive.xenproject.org/files/xensummit_intel09/George_Dunlap.pdf) [4] |
| 89 |
* "Scheduling in Xen" [XPDS15 Presentation](http://events.linuxfoundation.org/sites/events/files/slides/Faggioli_XenSummit.pdf) |
| 90 |
* "The Credit Scheduler" [on the Xen-Project wiki](https://wiki.xenproject.org/wiki/Credit_Scheduler) |
| 91 |
* "Xen Project Schedulers" [on the Xen-Project wiki](https://wiki.xenproject.org/wiki/Xen_Project_Schedulers) |
| 92 |
|
| 93 |
# History |
| 94 |
|
| 95 |
------------------------------------------------------------------------ |
| 96 |
Date Revision Version Notes |
| 97 |
---------- -------- -------- ------------------------------------------- |
| 98 |
2016-10-14 1 Xen 4.8 Document written |
| 99 |
2019-02-7 3 Xen 4.12 No longer default scheduler |
| 100 |
---------- -------- -------- ------------------------------------------- |