Xen credit Scheduling Algorithm

Source: Internet
Author: User

Basic Principles of credit Scheduling Algorithms

The credit scheduling algorithm is the default scheduling algorithm used since xen3.0. Proportional and fair sharing of non-preemptible Scheduling Algorithms. The credit scheduling algorithm sets a binary group (weight, Cap) for each guest operating system ), The ratio of weight between various guest operating systems determines the proportion of CPU time slice they occupy. Cap determines the upper limit of CPU time used by a guest operating system.For example, Cap = 50 indicates that the guest operating system can only occupy up to half of the total time of the physical CPU, Cap = 100, it indicates that the guest operating system can only occupy one physical CPU for all times.
The credit scheduling algorithm divides each virtual CPU into two queues. , Under queue and over queue, which only schedules virtual CPU in the under queue. At first, all the virtual CPUs are in the under queue, and the initial credit of each domain is the corresponding weight value. When the virtual CPU is scheduled, the credit of the domain corresponding to the virtual CPU is reduced. When the credit of the domain corresponding to the virtual CPU is found to be negative, the virtual CPU is put into the over queue; when all the virtual CPUs are in the over queue, the credit scheduling algorithm proportionally adds the credit of all domains with the weight value originally set for the domain, and add the corresponding virtual CPU to the under queue.The system runs the vcpu with the First Scheduling and under priority. When a processor is idle or the processor's ready vcpu queue has no under priority vcpu, it will view other processors to find a vcpu that can run on the current processor.
Currently, the research on the Credit algorithm focuses on the impact of this algorithm on system performance. Ludmila Cherkasova analyzes the impact of the algorithm on the disk read/write speed, network throughput, and CPU allocation accuracy when applied in the xen Virtual Machine manager; diego ongaro analyzes the impact of the credit algorithm on the I/O performance of xen virtual machines.

 

Credit scheduling algorithm advantages and disadvantages


The biggest advantage of the credit scheduling algorithm is that it can manage multiple physical CPUs globally, so that the CPU time can be allocated to each virtual CPU fairly and efficiently. It can allocate physical CPUs to virtual CPUs in SMP mode to achieve load balancing: it can implement the non-working-conserving (NWC) scheduling mode by adjusting the CAP parameter of the guest operating system, so that the administrator can easily control the allocation of physical CPU. Credit Scheduling Algorithm The disadvantage is that the real-time performance cannot be guaranteed.In applications with high response speed requirements, the event response latency is closely related to the queue location, and the response latency is generally long and fluctuating significantly. The global load balancing policy of this algorithm is too simple, and it is still easy to cause the processor to be idle because the process is not ready. The CPU allocation error rate generated by global allocation is high, making management more complicated.

Each VM is assigned a weight and a cap. If the cap is 0, then
The VM can receive any extra CPU (WC-mode). A non-zero cap
(Expressed as a percentage) limits the amount of CPU a VM has es
(NWC-mode). The credit scheduler uses 30 MS time slices for CPU
Allocation. a vm (vcpu) CPUs ES 30 MS before being preempted
To run another VM. Once every 30 MS, the priorities (credits) of all
Runnable VMS are recalculated. The scheduler monitors Resource
Usage every 10 ms. To some degree, credit's computation of credits
Resembles virtual time computation in BVT. However, BVT has
Context switch allowance C for defining a different size of the Basic
Time slice (Time quantum), and an additional low-latency support (
Warp) for real-time applications.
In summary, credit has the following features:
? Non-preemptive, WC and NWC modes;
? Global load balancing on multiprocessors.
In the next section, we present results of a performance study comparing
These schedulers and their features in more detail.

Domain has two statuses: under and over. Over indicates that the VM's credit value is used up, and under indicates that the credit value is still available. During scheduling, the Scheduler only cares about the status of the virtual machine, rather than the remaining credit value. The VM in the under status takes precedence over the VM in the over status, the VM in the over state is scheduled only when the under State cannot be run. Therefore, the fair scheduling policy of credit can be broken only when the processor is idle. Virtual machines in the same status run in FIFO mode,When a VM in the queue header is scheduled, it is allowed to run three scheduling durations (30 ms) if its credit value is sufficient. The system triggers a scheduling interruption every 10 ms. The number of currently running Virtual opportunities is reduced by 100 credits. When the total number of credits of all virtual machines changes to a negative value, the system re-allocates credit to all virtual machines:

1. Each physical CPU has a virtual CPU running queue.

2. Each vcpu in the running queue has a credit value

3. Credit indicates the value of vcpu priority

4. The CPU schedules the first vcpu in the under status

5. Each 10 MSEC is a time slice with an interruption. If the credit of the scheduled vcpu is in the over state, it will no longer be scheduled and re-calculate the credit value. The first vcpu in the under State after the Scheduling

6. if the original vcpu is still not in the over status when three time slices (namely, 30msec) are executed, the vcpu will not be rescheduled and the credit value will be re-calculated, steps after Step 5

7. calculation formula in the Code: credit of vcpu = credit-csched_credits_per_tick (100) + 30 msec/N (number of vcpu)

8. The value of vcpu credit in the over status is not increased.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.