CN104503838A - Method for scheduling virtual CPU (Central Processing Unit) - Google Patents

Method for scheduling virtual CPU (Central Processing Unit) Download PDF

Info

Publication number
CN104503838A
CN104503838A CN201410676265.3A CN201410676265A CN104503838A CN 104503838 A CN104503838 A CN 104503838A CN 201410676265 A CN201410676265 A CN 201410676265A CN 104503838 A CN104503838 A CN 104503838A
Authority
CN
China
Prior art keywords
cpu
virtual
load
physical
physical cpu
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201410676265.3A
Other languages
Chinese (zh)
Other versions
CN104503838B (en
Inventor
童薇
冯丹
刘景宁
刘珂男
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huazhong University of Science and Technology
Original Assignee
Huazhong University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huazhong University of Science and Technology filed Critical Huazhong University of Science and Technology
Priority to CN201410676265.3A priority Critical patent/CN104503838B/en
Priority to PCT/CN2014/094010 priority patent/WO2016078178A1/en
Publication of CN104503838A publication Critical patent/CN104503838A/en
Application granted granted Critical
Publication of CN104503838B publication Critical patent/CN104503838B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]

Abstract

The invention discloses a method for scheduling virtual CPU (Central Processing Unit), belongs to the technical field of computer virtualization and solves the problems that I/O processing can not be responded in time, load characteristics can not be satisfied and a load balancing strategy in a traditional scheduling algorithm is too simple. The method comprises the following steps: carrying out scheduling initialization, inserting into a virtual CPU running queue, carrying out virtual CPU operation, carrying out load balancing, updating a credit value and system load, reassigning the credit value, reassigning physical CPUs and revising the type of a virtual machine. The virtual machine is divided into three classes, carries out dynamic isolation on different types of load and is bound to two groups of physical CPU with different types of load to run, and different time slices are given to the virtual CPU on which different types of load are operated to improve operation efficiency and guarantee I/O performance. The virtual CPU scheduling method redesigns the load balancing strategy, and selects the strategy with minimum migration expenses in addition to that the isolation of different types of load is guaranteed, and the problem that the load balancing strategy in the traditional scheduling algorithm is too simple is solved.

Description

A kind of virtual cpu dispatching method
Technical field
The invention belongs to computer virtualized technical field, be specifically related to a kind of virtual cpu dispatching method, meet types of applications demand by arranging polytype virtual machine, and the load balancing of dynamically load isolation and optimization improves the performance of whole virtual platform greatly.
Background technology
Current, computing power has all had the lifting of matter in CPU, internal memory or network facet, run the convention computer architecture of an operating system on one server, cannot well utilize these advantages, cause the utilization factor of computing machine very undesirable, according to International Data Corporation (IDC) of market survey company (International Data Corporation, IDC) report, in the typical data center of IT enterprises, the average utilization of basic physics framework only has 10% to 15%, and most of computer resource is not fully used; Secondly, along with energy consumption and maintenance issues obtain the concern of more and more people, Intel Virtualization Technology starts the concern obtaining academia and industry member.
In computer realm, the virtual computer software that typically refers to runs on a virtual platform instead of in real physical machine.Intel Virtualization Technology allows a computer platform to run multiple operating system simultaneously, and its application journey is run and is independent of each other in environment independent of each other, while ensure that security and isolation, significantly improves the work efficiency of computing machine.Modern computer is that Intel Virtualization Technology provides powerful support, ensure that the multiple stage virtual machine run on a physical machine all can obtain enough performances, and independent operation system example is run in each virtual machine, therefore, increasing manufacturer runs under starting that virtual platform is transplanted in the service of oneself and application.Through development for many years, CPU is virtual to reach its maturity with internal memory virtualization technology, and the development of I/O Intel Virtualization Technology relatively lags behind, because the consideration of security, the intervention of the I/O action need monitor of virtual machine (virtualization abstraction layer) of virtual machine, between virtual machine, the lifting that time delay governs I/O performance is all the time responded to the competition of I/O resource and I/O simultaneously, have impact on the overall performance of virtual platform, also limit the further genralrlization application of Intel Virtualization Technology.Therefore, one of I/O performance research emphasis becoming current virtualization technique how improving virtual machine.
At present, promote virtual machine I/O performance and mainly contain two kinds of modes, a kind of mode reduces the intervention of monitor of virtual machine, and the intervention of monitor of virtual machine can affect the normal operation of virtual machine, contextual processing occurs, causes huge expense; Another kind of mode optimizes the scheduling of virtual cpu, allows virtual function be responded faster.What the virtual cpu dispatching algorithm of current main flow was focused on is allow virtual machine Fairshare computer resource in proportion, real-time can not be ensured, in the application that response time requirement is higher, the operating lag of event and virtual cpu queue position residing for it closely related, so not only time delay is unstable, and once is in the position comparatively will stand great time delay.2008, the people such as Diego Ongaro at " Scheduling I/O in Virtual Machine Monitors " (see ACM SIGPLAN/SIGOPS Conferenceon Virtual Execution Environments, 2008) propose in a literary composition in the credit value dispatching method of virtual platform Xen, add burst (BOOST) state, when virtual cpu is waken up by I/O event at arrested state, then enter bursty state, cause a virtual cpu scheduling, in this scheduling, the virtual cpu being in bursty state seizes physical cpu, process I/O event, even if but burst mechanism is also only just useful when virtual cpu is waken up, once there be other application can continue to consume the timeslice of virtual cpu, virtual cpu just can not block, therefore most I/O type task is still existed to the problem of response time delay.2012, Cong Xu, the people such as Sahan Gamage at " vSlicer:Latency-Aware Virtual Machine Scheduling via Differentiated-Frequency CPU Slicing " (see The 21st international symposium on High-Performance Parallel and Distributed Computing, 2012) the CPU time sheet of employing different length is proposed in a literary composition to run the virtual machine of dissimilar load, for the virtual machine running the load of I/O type distributes shorter CPU time sheet, for the virtual machine of moving calculation type load distributes longer CPU time sheet, so just can reduce the stand-by period of the virtual machine running the load of I/O type and increase its frequency be scheduled, promote I/O performance.But still there is following problems in the method: when the virtual cpu of virtual cpu and the load of moving calculation type that (a) runs the load of I/O type is in same virtual cpu operation queue, the former is large by the impact of the latter, very large time delay is just had once wait for that the virtual cpu of a calculation type load runs, therefore, this method can only reduce time delay to a certain extent; B () virtual machine only has a kind of fixing CPU time sheet, therefore can only run the load of single type, cannot meet the demand of Effec-tive Function calculation type load simultaneously and the load of I/O type in a virtual machine.2013, Cong Xu, the people such as Sahan Gamage at " vTurbo:Accelerating Virtual Machine I/OProcessing Using Designated Turbo-Sliced Core " (see USENIX Annual Technical Conference, 2013) literary composition proposes further improving countermeasure, a physics core is separated for the treatment of I/O event specially from physical cpu, and on the original virtual cpu basis of virtual machine, mostly be it again and distribute a virtual cpu, this virtual cpu is exclusively used in and runs I/O load, and dispatched by the physics core of specific assigned.The scheme eliminates the impact of calculation type load on I/O process, further improve I/O performance, but still come with some shortcomings: the physical cpu Resourse Distribute that (a) is static, resource utilization can be caused when the duty factor that system is dissimilar heavily differs greatly very low; B () virtual machine has the virtual cpu of two types, when running the load of single type, and cannot by virtual cpu performance to ultimate attainment.Popular along with polycaryon processor, load balancing in current virtual cpu dispatching algorithm is also considered to too simple, physical cpu only in Ergodic Theory, and find busy virtual cpu in queue and move, do not consider the expense of migration and further improving performance.In high-speed applications now, quite high to the requirement of bandwidth sum I/O time delay, such as in the Ethernet optical-fibre channel that IT enterprises data center is widely used, require high application for this type of to operating lag, existing virtual cpu dispatching algorithm is also inapplicable.
In order to be expressly understood the present invention, below the term used in the present invention is made an explanation:
Physical cpu (Physical Central Processing Unit, PCPU): real processor unit in computer system; A computer system can have multiple physical cpu, and computer system is marked by physical cpu bitmap, manage each physical cpu.
Physical cpu scheduling structure: in dispatching algorithm, each physical cpu has a corresponding physical cpu scheduling structure, preserves the secondary timer etc. of the virtual cpu operation queue on this physical cpu, clocked flip.If first initialized physical cpu scheduling structure in system, need this physical cpu to be labeled as primary physical CPU, and master timer is set for it.
Physical cpu bitmap: be an integer array, in array, each represents a physical cpu of Computer, by putting 1 operation to mark the physical cpu of specifying to certain execution in physical cpu bitmap.
I/O bitmap: the physical cpu bitmap types that physical cpu bitmap user is defined, 1 operation is put to mark the physical cpu that those are exclusively used in management and running I/O load virtual cpu to certain execution in I/O bitmap, arranges function to set up the compatibility running I/O load virtual cpu and mid-1 physical cpu of I/O bitmap by compatibility.
Calculate bitmap: the physical cpu bitmap types that physical cpu bitmap user is defined, 1 operation is put to mark the physical cpu that those are exclusively used in management and running calculation type load virtual cpu to certain execution calculated in bitmap, function is set by compatibility and sets up moving calculation type load virtual cpu and the compatibility calculating mid-1 physical cpu of bitmap.
The compatibility (affinity) of virtual cpu and physical cpu: refer in virtual platform, when there is multiple physical cpu, function can be set by the compatibility of system definition and some or multiple virtual cpu be specified to the physical cpu that can run, ensure the physical cpu that this one or more virtual cpu can not move to beyond appointment runs.For the virtual cpu being provided with compatibility, the position of physical cpu corresponding in the compatibility variable in its data structure can put 1, for the virtual cpu not arranging compatibility, all positions of compatibility variable in its data structure are 1, and expression can be dispatched on all physical cpus.
Virtual machine (Virtual Machine): refer to by software simulation have complete hardware system function, the complete computer operated in a completely isolated environment.
Scheduling virtual machine structure: in dispatching algorithm, each virtual machine has a corresponding scheduling virtual machine structure, preserves its virtual cpu number, virtual cpu chained list, the information such as virtual machine credit value weight.
Virtual cpu chained list: each virtual machine has a virtual cpu chained list, manages the virtual cpu that this virtual machine has.The number of the virtual cpu in virtual cpu chained list is the virtual cpu number that this virtual machine distributes, according to virtual cpu number sorting.
Virtual cpu (VCPU): virtual platform distributes to the CPU of virtual machine.
Free virtual CPU (IDLE VCPU): be used for the virtual cpu of occupy-place, does not complete real work, has minimum priority-3, the virtual cpu operation queue of each physical cpu all has a free virtual CPU.
Virtual cpu scheduling structure: in dispatching algorithm, each virtual cpu has a corresponding virtual cpu scheduling structure, preserves its credit value, priority, the information such as affiliated virtual machine.
Virtual cpu operation queue: each physical cpu has a virtual cpu operation queue, is made up of according to priority order from high to low the virtual cpu run on this physical cpu; The priority value of virtual cpu is-1 ,-2 ,-3 from high to low, represents that it can be scheduled respectively, can not be scheduled, only for occupy-place;
Polycaryon processor framework: in polycaryon processor framework now, often there is multiple physical package (socket) in a main frame, multiple physics core (core) is encapsulated again in each physical package, after adopting Hyper-Threading, each physics core (core) comprises again multiple physical cpu, and each physics nuclear energy in Same Physical encapsulation enough shares three grades of buffer memorys; Physical cpu in Same Physical core can share L2 cache; Such buffer structure significantly can promote the hit rate that data are read in CPU inside, and need not find on internal memory or hard disk again, improves system performance with this.
Virtual platform: be allow multiple virtual machine can the software and hardware system of safe operation on a set of physical hardware, provide the company of virtual platform to have at present: Microsoft, think outstanding, prestige be farsighted.
Xen: a kind of virtual platform being the exploitation of univ cambridge uk computer laboratory, it and virtual machine combine closely, take resource few, and with high-performance, to take resource few famous.
Monitor of virtual machine (Virtual Machine Monitor, VMM): operate in the virtualization abstraction layer between basic physics server and operating system, can allow multiple operating system and Application share hardware, monitor of virtual machine is that every platform I/O equipment sets up corresponding I/O request queue.
Credit value (credit): the kernel variable in credit dispatching algorithm, determine the priority of virtual cpu and obtainable CPU time leaf length, its codomain is-300 ~ 300, only have when the credit value of virtual cpu is greater than 0, this virtual cpu just can be dispatched, dispatch the credit value amount that virtual cpu all can consume 10 × timeslice length each time, when the credit value amount of virtual cpu is less than or equal to 0, then need to wait for that credit value distributes next time.
I/O type load: be operating as main application program with I/O, CPU burden is very light, usually only runs the very short time, it is desirable that respond more frequently.
Calculation type load: be operating as main application program with CPU, usual cpu load reaches 100%, it is desirable that reduce scheduling frequency and as far as possible long working time.
Mixed type load: have in running environment simultaneously and be operating as main application program with I/O and be operating as main application program with CPU, often with CPU be operating as main application program can close to 100% take cpu resource, and be operating as main application program with I/O and be not also finished timeslice and just get clogged, therefore to give I/O in this environment and be operating as the higher priority of main application program, increase its scheduling frequency.
Ethernet optical-fibre channel: optical-fibre channel is mapped to Ethernet, can optical-fibre channel information be inserted in Ethernet packets of information, thus the optical-fibre channel between server and memory device summed data please can be connected by Ethernet and transmit, and without the need to special Fibre Channel Fabric.
Summary of the invention
The invention provides a kind of virtual cpu dispatching method, for multiprocessor virtualized environment, solve the problem that I/O process cannot be responded in time, load characteristic is not being met and in current main-stream dispatching algorithm, load balancing is too simple in virtualized environment.
A kind of virtual cpu dispatching method provided by the present invention, comprise scheduling initialization step, insertion virtual cpu operation queue step, virtual cpu operating procedure, load-balancing step, renewal credit value and system load step, redistribute credit value step, redistribute physical cpu step and change virtual machine type step, it is characterized in that:
(1) initialization step is dispatched: for each physical cpu creates physical cpu scheduling structure: arrange master timer for primary physical CPU and regulate timer, other physical cpu arranges secondary timer; For each virtual machine creating scheduling virtual machine structure: initialization of virtual machine credit value weight, setting virtual machine type; Virtual cpu initialization of virtual CPU scheduling structure for each virtual machine: the load variation of each virtual cpu of initialization, I/O task pressing degree, for each virtual cpu distributes credit value; Initialization I/O bitmap A bwith calculating bitmap A c, A bin physical cpu be exclusively used in the virtual cpu of management and running I/O type load, A cin physical cpu be exclusively used in the virtual cpu of management and running calculation type load, they are complementary physical cpu bitmaps; The I/O load variation L of the initialization overall situation band computational load variables L c, L band L cthe credit value resource that the virtual cpu running the load of I/O type and calculation type load in register system respectively consumes; The priority of each virtual cpu is set;
(2) virtual cpu operation queue step is inserted: if the load of current virtual CPU moving calculation type, then after directly inserting all virtual cpus of same priority in virtual cpu operation queue; If current virtual CPU runs the load of I/O type, then sequentially insert virtual cpu operation queue by its priority, for the virtual cpu that priority is equal, then sort from big to small according to I/O pressing degree;
(3) virtual cpu operating procedure: if the head of the queue virtual cpu credit value of present physical CPU is less than or equal to 0, then trigger load is balanced, goes to step (4); Otherwise run head of the queue virtual cpu, if present physical CPU is primary physical CPU, in operational process, secondary timer, to the time, goes to step (5), master timer is to the time, go to step (6), regulate timer to the time, go to step (7), user sends amendment virtual machine type command, performs step (8); Present physical CPU is non-master physical cpu, and in operational process, secondary timer, to the time, goes to step (5), and user sends amendment virtual machine type command, performs step (8); Virtual cpu goes to step (2) after reaching working time, reinserts queue;
(4) load-balancing step: judge whether present physical CPU corresponding position in I/O bitmap is 1, is, I/O bitmap is put the busy physical cpu of 1 as target CPU group, otherwise calculating bitmap is put the busy physical cpu of 1 as target CPU group; Then the physical cpu selecting migration optimum from target physical CPU group, as the target physical CPU of migration, if the physical cpu not finding migration optimum, abandons this load balancing;
After finding target physical CPU, judge whether present physical CPU corresponding position in I/O bitmap is 1 again, be then using virtual cpu the most urgent for I/O task in the virtual cpu operation queue of target physical CPU as destination virtual CPU, otherwise using historic load in the virtual cpu operation queue of target physical CPU closest to the virtual cpu of the difference half of target physical CPU and present physical CPU historic load as destination virtual CPU, destination virtual CPU is deleted from former queue and inserts the virtual cpu queue head of the queue of present physical CPU; Go back to step (3);
(5) credit value and system load step is upgraded: upgrade the credit value of current virtual CPU, load variation, and upgrade the historic load variable of related physical CPU, judge whether the physical cpu corresponding place value in I/O bitmap running current virtual CPU is 1, be upgrade the I/O load variation of the urgent variable of its I/O task and the overall situation, go back to step (3); Otherwise upgrade the computational load variable of the overall situation; Go back to step (3);
(6) credit value step is redistributed: the credit value according to current virtual CPU judges priority, recalculate the credit value amount that each virtual cpu distributes, and upgrade the credit value of all virtual cpus, judge after upgrading, whether the credit value of virtual cpu just becomes from anon-normal, be change its priority, go back to step (3); Otherwise about the priority of virtual cpu does not change, directly go back to step (3);
(7) physical cpu step is redistributed: calculate respectively according to global I/O load variation and computational load variable and run the physical cpu number of I/O load and the physical cpu number of moving calculation type load; And revise corresponding I/O bitmap according to the physical cpu number calculated and calculate bitmap, re-establish the compatibility between virtual cpu and physical cpu; By I/O load variation and computational load variable clear 0, and upgrade the I/O task pressing degree variable of all virtual cpus, go back to step (3);
(8) virtual machine type step is changed: read user command, according to virtual machine ID wherein, virtual machine type Q and virtual cpu number X i, read former virtual machine type S i, according to virtual machine type Q and former virtual machine type S i, re-establish each virtual cpu of virtual machine and I/O bitmap or calculate the compatibility of bitmap, and revise virtual machine categorical variable, go back to step (3).
Described virtual cpu dispatching method, it is further characterized in that:
(1) dispatch initialization step, comprise following sub-step:
(1.1) for each physical cpu creates physical cpu scheduling structure:
Determining whether that first physical cpu creates physical cpu scheduling structure, is carry out sub-step (1.2); Otherwise rotor step (1.3);
(1.2) first physical cpu is labeled as primary physical CPU, and master timer is set for it and regulates timer, master timer cycle T main=30 ~ 100ms is the integral multiple of 10ms, is T simultaneously secondaryintegral multiple, regulate timer cycle T adjust=1200 ~ 3000ms is T mainintegral multiple, rotor step (1.3);
(1.3) secondary timer is set, secondary timer period T secondaryfor (1 ~ 3) × 10ms; By the historic load variable H of this physical cpu pbe initialized as 0; Historic load variable H pbe recorded in the used up all credit value summations of virtual cpu that this physical cpu runs, physical cpu ordinal number p=1 ~ G, G are the physical cpu number in system, G=1 ~ 64;
(1.4) be each virtual machine creating scheduling virtual machine structure:
In the scheduling virtual machine structure of each virtual machine, by corresponding virtual machine credit value weights W ibe initialized as 256, corresponding virtual machine type S ibe set as 0, and its virtual cpu chained list is initialized as sky;
Wherein, virtual machine ordinal number i=1 ~ V, V are the virtual machine number that user creates, V=1 ~ 100; S ibe 0 expression calculation type load, S ibe 1 expression I/O type load, S ibe 2 expression mixed type loads, mixed type load is the load that calculation type is suitable with the load of I/O type;
(1.5) be the virtual cpu initialization of virtual CPU scheduling structure of each virtual machine:
Virtual cpu is added in the virtual cpu chained list of affiliated virtual machine;
By the load variation H of each virtual cpu ijbe initialized as 0,
By the I/O task pressing degree variable I of each virtual cpu ijbe initialized as 0, I ij=0 ~ 1, I ijbe worth larger expression I/O task more urgent, I ij=0, represent there is no I/O load;
And be that each virtual cpu distributes credit value, wherein the credit value C of a jth virtual cpu of i-th virtual machine ij=G × 10 × T main× W i/ (W t× M i);
Wherein, the total weight of system W T = Σ i = 1 V ( W i × M i ) ,
Ordinal number j=1 ~ the M of virtual cpu in virtual machine i, M ibe the virtual cpu number of i-th virtual machine, be set by the user, for being less than the integer of G;
(1.6) by I/O bitmap A bwith calculating bitmap A cinitialization:
Set up I/O bitmap A bwith calculating bitmap A c, by A bin everybody be initialized as full 0, A cin everybody be initialized as complete 1, represent the load of system default initialization moving calculation type;
(1.7), during initialization, the load of all virtual cpu acquiescence moving calculation types, sets up each virtual cpu and calculates bitmap A cthe compatibility of the physical cpu of mid-1;
(1.8) the I/O load variation L of the overall situation is set band computational load variables L c, by L band L call be initialized as 0;
(1.9) by the priority P of each virtual cpu ijbe initialized as-1, represent that it can be scheduled;
(2) insert virtual cpu operation queue step, comprise following sub-step:
(2.1) judge current virtual CPU whether with calculating bitmap A ccompatibility is set, is, represent this virtual cpu moving calculation type load, carry out sub-step (2.2), otherwise represent that this virtual cpu runs the load of I/O type, rotor step (2.3),
(2.2) from the virtual cpu operation queue head of the queue of present physical CPU, the priority P of current virtual CPU is compared ijwhether be greater than the virtual cpu priority P in virtual cpu operation queue ij, be that before current virtual CPU is inserted the virtual cpu compared in virtual cpu operation queue, otherwise order compares, until virtual cpu operation queue tail of the queue backward; After insertion completes, go to step (3);
(2.3) from the virtual cpu operation queue head of the queue of present physical CPU, the priority P of current virtual CPU is compared ijwhether be greater than the virtual cpu priority P in virtual cpu operation queue ij, be current virtual CPU to be inserted in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise carry out sub-step (2.4);
(2.4) priority P of current virtual CPU is compared ijwhether equal the virtual cpu priority P in virtual cpu operation queue ij, be carry out sub-step (2.5), otherwise order compares backward, until virtual cpu operation queue tail of the queue, after having inserted, goes to step (3);
(2.5) I of current virtual CPU is compared ijwhether value is greater than the I of the virtual cpu in virtual cpu operation queue ijvalue, is, to be inserted by current virtual CPU in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise order backward, compares the priority P of current virtual CPU ijwhether be greater than the virtual cpu priority P compared ij, be current virtual CPU to be inserted in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise carry out sub-step (2.4);
(3) virtual cpu operating procedure, comprises following sub-step:
(3.1) in the virtual cpu operation queue of present physical CPU, head of the queue virtual cpu credit value C is judged ijwhether be greater than 0, be, carry out sub-step (3.2); Otherwise trigger load balance policy, goes to step (4);
(3.2) judge whether the target physical CPU group that in virtual cpu operation queue, head of the queue virtual cpu compatibility is arranged is A bphysical cpu representated by mid-1 of bitmap, is, shows that it runs the load of I/O type, arranges its working time of leaf length T s=1ms ~ 5ms; Otherwise show its moving calculation type load, its working time of leaf length T is set s=30ms ~ 100ms;
(3.3) described head of the queue virtual cpu is deleted from the virtual cpu operation queue of place;
(3.4) judge whether present physical CPU is primary physical CPU, is, carry out sub-step (3.5); Otherwise carry out sub-step (3.8);
(3.5) on primary physical CPU, described head of the queue virtual cpu is run, the timing simultaneously of the secondary timer of primary physical CPU, master timer and adjustment timer; Whether supervisory user sends amendment virtual machine type command simultaneously, is perform step (8); Otherwise carry out sub-step (3.6);
(3.6) judge whether the working time of this head of the queue virtual cpu is less than T s, be carry out sub-step (3.7); Otherwise this head of the queue virtual cpu is removed from primary physical CPU, goes to step (2);
(3.7) when secondary timer experienced by time T secondary, then secondary timer reset, goes to step (5); When master timer experienced by time T main, then master timer resets, and goes to step (6); When adjustment timer experienced by time T adjust, then regulate timer reset, go to step (7); If at T sany timer is not triggered, virtual cpu continuous working period T in time s, this head of the queue virtual cpu is removed from primary physical CPU, goes to step (2);
(3.8) on present physical CPU, described head of the queue virtual cpu is run, during the secondary timer of present physical CPU; Whether supervisory user revises virtual machine type simultaneously, is perform step (8); Otherwise carry out sub-step (3.9);
(3.9) judge whether the working time of this head of the queue virtual cpu is less than T s, be carry out sub-step (3.10); Otherwise this head of the queue virtual cpu is removed from present physical CPU, goes to step (2);
(3.10) when secondary timer experienced by time T secondary, then secondary timer reset, goes to step (5), if at T sany timer is not triggered, virtual cpu continuous working period T in time s, this head of the queue virtual cpu is removed from present physical CPU, goes to step (2);
(4) load-balancing step, comprises following sub-step:
(4.1) the physical cpu group of carrying out load balancing is selected: judge that present physical CPU is at I/O bitmap A bwhether middle corresponding position is 1, is, what the virtual cpu operation queue representing this physical cpu ran is the load of I/O type, by I/O bitmap A bthe busy physical cpu of mid-1, as the target physical CPU group can carrying out load balancing, carries out sub-step (4.2); Otherwise represent that what this physical cpu queue ran is calculation type load, will calculate bitmap A cthe busy physical cpu of mid-1, as the target physical CPU group can carrying out load balancing, carries out sub-step (4.2);
(4.2) physical cpu selecting migration optimum from target physical CPU group: at corresponding A bor A cin, travel through described target physical CPU group, judging whether to find and the busy physical cpu of present physical CPU on same physics core, is it can be used as the target physical CPU of migration, rotor step (4.8), otherwise rotor step (4.3);
(4.3) at corresponding A bor A cin, again travel through target physical CPU group, judge whether to find the busy physical cpu with present physical CPU in same physical package, be, carry out sub-step (4.4), otherwise rotor step (4.5);
(4.4) H of this busy physical cpu is judged pwhether be greater than the H of present physical CPU p, be then using the target physical CPU of this physical cpu as migration, rotor step (4.8), otherwise rotor step (4.5);
(4.5) in respective objects physical cpu group, order judges whether to find the busy physical cpu with present physical CPU in same physical package backward, is then rotor step (4.4), otherwise rotor step (4.6);
(4.6) again target physical CPU group is traveled through, judge whether to find the busy physical cpu from present physical CPU in different physical package, carry out sub-step (4.7), otherwise present physical CPU is labeled as the free time, run idle virtual cpu, rotor step (3.4);
(4.7) H of this busy physical cpu is judged pwhether be greater than the H of present physical CPU ptwice, be then using this busy physical cpu as migration target physical CPU, rotor step (4.8); Otherwise present physical CPU is labeled as the free time, runs idle virtual cpu, rotor step (3.4);
(4.8) on target physical CPU, suitable virtual cpu is selected to shift:
Judge that present physical CPU is at I/O bitmap A bwhether middle corresponding position is 1, is, travels through the virtual cpu operation queue of target physical CPU, incites somebody to action wherein I ijbe worth the destination virtual CPU of maximum virtual cpu as migration, rotor step (4.9); Otherwise the virtual cpu operation queue of traversal target physical CPU, finds H ijclosest to the H of target physical CPU pthe H of the physical cpu balanced with trigger load pthe virtual cpu of difference half as the destination virtual CPU of migration, rotor step (4.9);
(4.9) the destination virtual CPU of migration removed from the virtual cpu operation queue of target physical CPU and be inserted into the head of the queue of the virtual cpu operation queue of present physical CPU, rotor step (3.2);
(5) upgrade credit value and system load step, comprise following sub-step:
(5.1) the credit value C of current virtual CPU is upgraded ij: by C ij-10 × T 1value give C ij;
Upgrade the load variation H of current virtual CPU ij: by H ij+ 10 × T 1value give H ij;
Upgrade the historic load variable H of the physical cpu running current virtual CPU p: by H p+ 10 × T 1value give H p;
The credit value amount of virtual cpu operation 1ms consumption is 10, T 1for current virtual CPU brought into operation the time experienced so far from last time, unit is ms;
(5.2) judge that the physical cpu running current virtual CPU is at I/O bitmap A bwhether middle corresponding place value is 1, is, represents and has run I/O task, upgrades its I ij, by I ij-1/ (10 × T 1) value give I ij, carry out sub-step (5.3); Otherwise directly carry out sub-step (5.3);
(5.3) according to the type of current virtual CPU running load, its used up credit value is added in system load: judge that the physical cpu running current virtual CPU is at bitmap A bwhether middle corresponding place value is 1, is, upgrades the I/O load variation L of the overall situation b, by L b+ 10 × T 1value give L b, rotor step (3.4); Otherwise upgrade the computational load variables L of the overall situation c, by L c+ 10 × T 1value give L c, rotor step (3.4);
(6) redistribute credit value step, comprise following sub-step:
(6.1) judge whether current virtual CPU credit value is greater than 0, is, carry out sub-step (6.2); Otherwise by the priority P of current virtual CPU ijbe arranged to-2, expression cannot be dispatched again, carries out sub-step (6.2);
(6.2) for the virtual cpu of each virtual machine newly distributes credit value NC ij:
NC ij=G × T main× 10 × W i/ (W t× M i);
Wherein NC ijit is the credit value that a jth virtual cpu of i-th virtual machine newly obtains;
(6.3) the credit value C of each virtual cpu is upgraded ij:
By NC ij+ C ijvalue give C ij,
Judge whether C ij> 0 and P ijvalue, for-2, is then by the priority P about virtual cpu ijchange to-1, rotor step (3.4), otherwise about the priority P of virtual cpu ijdo not change, direct rotor step (3.4);
(7) redistribute physical cpu step, comprise following sub-step:
(7.1) respective physical CPU number is calculated;
Run the load of I/O type physical cpu number N ( ab):
N( Ab)=(L b/(L b+L c))×G;
The physical cpu number N of moving calculation type load ( ac):
N( Ac)=G-N( Ab);
(7.2) I/O bitmap A is judged bthe physical cpu number of mid-1 whether be less than N ( ab), be carry out sub-step (7.3), otherwise rotor step (7.4);
(7.3) from the physical cpu of moving calculation type load, shift the physical cpu of difference number to run the load of I/O type: make Y=N ( ab)-I/O bitmap A bthe physical cpu number of mid-1, by I/O bitmap A bin before Y be 0 position all put 1, and bitmap A will be calculated cmiddle corresponding position clear 0, rotor step (7.6);
(7.4) I/O bitmap A is judged bthe physical cpu number of mid-1 whether equal N ( ab), be then rotor step (7.7); Otherwise carry out sub-step (7.5);
(7.5) physical cpu shifting difference number from the physical cpu running the load of I/O type carrys out the load of moving calculation type: make Y=I/O bitmap A bphysical cpu number-the N of mid-1 ( ab), by I/O bitmap A bin before Y put 1 all clear 0, and bitmap A will be calculated cmiddle correspondence position 1, rotor step (7.6);
(7.6) virtual cpu compatibility is reset: re-establish all virtual cpus and I/O bitmap A that run the load of I/O type bthe compatibility of the physical cpu of mid-1;
Re-establish all virtual cpus of moving calculation type load and calculating bitmap A cthe compatibility of the physical cpu of mid-1;
(7.7) by I/O load variation L band computational load variables L cclear 0, and the I/O task pressing degree variable I upgrading all virtual cpus ij: by 1/H ijvalue give I ij, rotor step (3.4);
(8) change virtual machine type step, comprise following sub-step:
(8.1) according to the amendment virtual machine type command that user sends, virtual machine ID, virtual machine type Q wherein and virtual cpu number X is read i, according to virtual machine ID, in its scheduling virtual machine structure, read its virtual machine type S i;
Described amendment virtual machine type command comprises virtual machine id field, virtual machine type field and virtual cpu number field, and virtual machine id field provides the virtual machine ID of type to be modified; Virtual machine type field provides virtual machine type Q to be modified, and Q is 0 expression calculation type load, and Q is 1 expression I/O type load, and Q is 2 expression mixed type loads; Virtual cpu number field provides for running the virtual cpu number of I/O load in mixed virtual machine, and only as Q=2, this field is just effective;
(8.2) judge whether Q=0, be, carry out sub-step (8.3), otherwise carry out sub-step (8.6);
(8.3) S is judged whether i=0, be keep virtual machine type S iconstant, rotor step (3.5); Otherwise judge whether S i=1, be carry out sub-step (8.4), otherwise carry out sub-step (8.5);
(8.4) S is judged i=1, represent the virtual machine virtual machine running the load of I/O type being changed into calculation type load, remove its each virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, all virtual cpus re-establishing this virtual machine with calculate bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 0, rotor step (3.5);
(8.5) S is judged i=2, represent the virtual machine virtual machine running mixed type load being changed into the load of moving calculation type, remove its each virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, re-establishes its each virtual cpu and calculates bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 0, rotor step (3.5);
(8.6) judge whether Q=1, be, carry out sub-step (8.7), otherwise carry out sub-step (8.11);
(8.7) S is judged whether i=0, be carry out step (8.8), otherwise carry out sub-step (8.9);
(8.8) represent the virtual machine being changed into by the virtual machine of moving calculation type load and run the load of I/O type, remove its each virtual cpu and calculate bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes all virtual cpus and the I/O bitmap A of this virtual machine bthe compatibility of the physical cpu of mid-1, and by S ibe revised as 1, rotor step (3.5);
(8.9) S is judged whether i=1, be keep virtual machine type S iconstant, rotor step (3.5); Otherwise carry out sub-step (8.10);
(8.10) S is judged i=2, represent and change the virtual machine running mixed type load into run the load of I/O type virtual machine, remove its each virtual cpu and calculate bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes its each virtual cpu and I/O bitmap A ithe compatibility of the physical cpu of mid-1, and by S ibe revised as 1, rotor step (3.5);
(8.11) judge Q=2, judge whether S i=0, be carry out sub-step (8.12), otherwise carry out sub-step (8.13);
(8.12) S is judged i=0, represent the virtual machine being changed into by the virtual machine of moving calculation type load and run mixed type load, remove X before in this virtual machine iindividual virtual cpu and calculating bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes X before in this virtual machine iindividual virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, and by S ibe revised as 2, rotor step (3.5);
(8.13) S is judged whether i=1, be carry out sub-step (8.14), otherwise carry out sub-step (8.15);
(8.14) S is judged i=1, represent and change the virtual machine running the load of I/O type into run mixed type load virtual machine, remove M after in this virtual machine i-X iindividual virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, re-establishes M after in this virtual machine i-X iindividual virtual cpu and calculating bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 2, rotor step (3.5);
(8.15) S is judged i=2, keep virtual machine type S iconstant, rotor step (3.5).
Described scheduling initialization step, to redistribute in physical cpu step and change virtual machine type step, set up each virtual cpu and I/O bitmap A bor calculate bitmap A cduring the compatibility of the physical cpu of mid-1, compatibility function can be set by system definition;
Remove each virtual cpu and I/O bitmap A bor calculate bitmap A cduring the compatibility of the physical cpu of mid-1, compatibility function can be set by system definition, re-establish each virtual cpu and I/O bitmap A bor calculate bitmap A cthe compatibility of the physical cpu of mid-1.
In existing dispatching algorithm, what focus on is that physical cpu resource fairness given each virtual cpu, but this justice is only on surface, because the demand of different loads to running environment is different, the I/O type load usual execution time is short, but wish low delay and high-frequency scheduling, according to existing dispatching algorithm, the virtual cpu running the load of I/O type is easy to wait in line because be absorbed in and cause very high time delay.
The present invention, in order to meet different application demand and ensure I/O performance, classifies to virtual machine, and the virtual machine of delay sensitive runs the load of I/O type specially; The virtual machine special moving calculation type load of non-delayed responsive type; Mixed virtual machine, runs multiclass load simultaneously.For the virtual machine of moving calculation type load distributes longer timeslice, reduce the expense of environment changing; For the virtual machine running the load of I/O type distributes shorter timeslice, obtain higher scheduling frequency; For the virtual machine of mixed type load, need the feature simultaneously taking into account two kinds of loads, then carry out inner virtual cpu and divide, to the virtual cpu setting short time sheet running the load of I/O type, to the virtual cpu of moving calculation type load setting sheet normal time, allow it can Effec-tive Function.In order to not allow calculation type load effect I/O performance, invention has been dynamic load isolation, physical cpu be divide into two groups, one group scheduling runs the virtual cpu of I/O load, the virtual cpu of one group scheduling moving calculation type load, the weight according to system total load shared by the load of I/O type and calculation type load of grouping, readjust the grouping of physical cpu every some cycles according to adjustment timer, the system that ensure that under the prerequisite of load isolation has good dirigibility.Adjust to solve current virtual CPU the problem calculated and cannot embody the pressing degree of I/O task, the present invention is the pressing degree index that virtual cpu adds an I/O task, allows urgent I/O event can obtain preferential process, invention contemplates existing virtual cpu dispatching algorithm load balancing too simple question, according to physical cpu in the present invention, the scheduling structure of virtual machine and virtual cpu has redesigned a set of load balancing, consider the hierarchical structure of physical cpu, successively at Same Physical core, select to move optimum target physical CPU in Same Physical encapsulation and different physical package, except ensureing the isolation of dissimilar load, select the strategy that migration overhead is minimum, also different according to loadtype when selecting the destination virtual CPU of migration, for calculation type load, select the scheme that the rear physical cpu operation queue load of migration is suitable, for the load of I/O type, the virtual cpu migration selecting I/O task the most urgent, ensures I/O performance.
Accompanying drawing explanation
Fig. 1 is schematic flow sheet of the present invention;
Fig. 2 is for inserting virtual cpu operation queue steps flow chart block diagram;
Fig. 3 is virtual cpu operating procedure FB(flow block);
Fig. 4 is load-balancing step FB(flow block);
Fig. 5 is again dispensers reason CPU steps flow chart block diagram;
Fig. 6 is change virtual machine type steps flow chart block diagram.
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is further described.
As shown in Figure 1, the present invention includes scheduling initialization step, insertion virtual cpu operation queue step, virtual cpu operating procedure, load-balancing step, renewal credit value and system load step, redistribute credit value step, redistribute physical cpu step and change virtual machine type step;
(1) initialization step is dispatched: for each physical cpu creates physical cpu scheduling structure: arrange master timer for primary physical CPU and regulate timer, other physical cpu arranges secondary timer; For each virtual machine creating scheduling virtual machine structure: initialization of virtual machine credit value weight, setting virtual machine type; Virtual cpu initialization of virtual CPU scheduling structure for each virtual machine: the load variation of each virtual cpu of initialization, I/O task pressing degree, for each virtual cpu distributes credit value; Initialization I/O bitmap A bwith calculating bitmap A c, A bin physical cpu be exclusively used in the virtual cpu of management and running I/O type load, A cin physical cpu be exclusively used in the virtual cpu of management and running calculation type load, they are complementary physical cpu bitmaps; The I/O load variation L of the initialization overall situation band computational load variables L c, L band L cthe credit value resource that the virtual cpu running the load of I/O type and calculation type load in register system respectively consumes; The priority of each virtual cpu is set;
(2) virtual cpu operation queue step is inserted: if the load of current virtual CPU moving calculation type, then after directly inserting all virtual cpus of same priority in virtual cpu operation queue; If current virtual CPU runs the load of I/O type, then sequentially insert virtual cpu operation queue by its priority, for the virtual cpu that priority is equal, then sort from big to small according to I/O pressing degree;
(3) virtual cpu operating procedure: if the head of the queue virtual cpu credit value of present physical CPU is less than or equal to 0, then trigger load is balanced, goes to step (4); Otherwise run head of the queue virtual cpu, if present physical CPU is primary physical CPU, in operational process, secondary timer, to the time, goes to step (5), master timer is to the time, go to step (6), regulate timer to the time, go to step (7), user sends amendment virtual machine type command, performs step (8); Present physical CPU is non-master physical cpu, and in operational process, secondary timer, to the time, goes to step (5), and user sends amendment virtual machine type command, performs step (8); Virtual cpu goes to step (2) after reaching working time, reinserts queue;
(4) load-balancing step: judge whether present physical CPU corresponding position in I/O bitmap is 1, is, I/O bitmap is put the busy physical cpu of 1 as target CPU group, otherwise calculating bitmap is put the busy physical cpu of 1 as target CPU group; Then the physical cpu selecting migration optimum from target physical CPU group, as the target physical CPU of migration, if the physical cpu not finding migration optimum, abandons this load balancing;
After finding target physical CPU, judge whether present physical CPU corresponding position in I/O bitmap is 1 again, be then using virtual cpu the most urgent for I/O task in the virtual cpu operation queue of target physical CPU as destination virtual CPU, otherwise using historic load in the virtual cpu operation queue of target physical CPU closest to the virtual cpu of the difference half of target physical CPU and present physical CPU historic load as destination virtual CPU, destination virtual CPU is deleted from former queue and inserts the virtual cpu queue head of the queue of present physical CPU; Go back to step (3);
(5) credit value and system load step is upgraded: upgrade the credit value of current virtual CPU, load variation, and upgrade the historic load variable of related physical CPU, judge whether the physical cpu corresponding place value in I/O bitmap running current virtual CPU is 1, be upgrade the I/O load variation of the urgent variable of its I/O task and the overall situation, go back to step (3); Otherwise upgrade the computational load variable of the overall situation; Go back to step (3);
(6) credit value step is redistributed: the credit value according to current virtual CPU judges priority, recalculate the credit value amount that each virtual cpu distributes, and upgrade the credit value of all virtual cpus, judge after upgrading, whether the credit value of virtual cpu just becomes from anon-normal, be change its priority, go back to step (3); Otherwise about the priority of virtual cpu does not change, directly go back to step (3);
(7) physical cpu step is redistributed: calculate respectively according to global I/O load variation and computational load variable and run the physical cpu number of I/O load and the physical cpu number of moving calculation type load; And revise corresponding I/O bitmap according to the physical cpu number calculated and calculate bitmap, re-establish the compatibility between virtual cpu and physical cpu; By I/O load variation and computational load variable clear 0, and upgrade the I/O task pressing degree variable of all virtual cpus, go back to step (3);
(8) virtual machine type step is changed: read user command, according to virtual machine ID wherein, virtual machine type Q and virtual cpu number X i, read former virtual machine type S i, according to virtual machine type Q and former virtual machine type S i, re-establish each virtual cpu of virtual machine and I/O bitmap or calculate the compatibility of bitmap, and revise virtual machine categorical variable, go back to step (3).
Embodiments of the invention application background is: main frame has two physical package, has four physics cores in each physical package, opens hyperthread.Each physics core contains two physical cpus, experiment porch operating system is CentOS-6.4, virtual machine monitor is Xen-4.2.0, kernel version is Linux-3.2.0, main frame runs 16 virtual machines, each virtual machine 4 virtual cpus, VME operating system is CentOS-6.4, and kernel version is Linux-3.2.0.
Embodiments of the invention, comprise scheduling initialization step, insertion virtual cpu operation queue step, virtual cpu operating procedure, load-balancing step, renewal credit value and system load step, redistribute credit value step, redistribute physical cpu step and change virtual machine type step:
(1) dispatch initialization step, comprise following sub-step:
(1.1) for each physical cpu creates physical cpu scheduling structure:
Determining whether that first physical cpu creates physical cpu scheduling structure, is carry out sub-step (1.2); Otherwise rotor step (1.3);
(1.2) first physical cpu is labeled as primary physical CPU, and master timer is set for it and regulates timer, master timer cycle T main=30ms, regulates timer cycle T adjust=1200ms, rotor step (1.3);
(1.3) secondary timer is set, secondary timer period T secondaryfor 10ms; By the historic load variable H of this physical cpu pbe initialized as 0; P=1 ~ 16;
(1.4) be each virtual machine creating scheduling virtual machine structure:
In the scheduling virtual machine structure of each virtual machine, by corresponding virtual machine credit value weights W ibe initialized as 256, corresponding virtual machine type S ibe set as 0, and its virtual cpu chained list is initialized as sky;
Wherein, virtual machine ordinal number i=1 ~ 16;
(1.5) be the virtual cpu initialization of virtual CPU scheduling structure of each virtual machine:
Virtual cpu is added in the virtual cpu chained list of affiliated virtual machine;
By the load variation H of each virtual cpu ijbe initialized as 0,
By the I/O task pressing degree variable I of each virtual cpu ijbe initialized as 0, represent there is no I/O load;
And be that each virtual cpu distributes credit value, wherein the credit value C of a jth virtual cpu of i-th virtual machine ij=16 × 10 × 30 × 256/ (W t× M i)=75; Wherein, the total weights W of system t=16384,
Ordinal number j=1 ~ the M of virtual cpu in virtual machine i, M i=4, be the virtual cpu number of i-th virtual machine;
(1.6) by I/O bitmap A bwith calculating bitmap A cinitialization:
Set up I/O bitmap A bwith calculating bitmap A c, they are complementary physical cpu bitmaps, by A bin everybody be initialized as full 0, A cin everybody be initialized as complete 1, represent the load of system default initialization moving calculation type;
(1.7), during initialization, the load of all virtual cpu acquiescence moving calculation types, sets up each virtual cpu and calculates bitmap A cthe compatibility of the physical cpu of mid-1;
(1.8) the I/O load variation L of the overall situation is set band computational load variables L c, by L band L call be initialized as 0;
(1.9) by the priority P of each virtual cpu ijbe initialized as-1, represent that it can be scheduled;
(2) as shown in Figure 2, insert virtual cpu operation queue step, comprise following sub-step:
(2.1) judge current virtual CPU whether with calculating bitmap A ccompatibility is set, is, represent this virtual cpu moving calculation type load, carry out sub-step (2.2), otherwise represent that this virtual cpu runs the load of I/O type, rotor step (2.3),
(2.2) from the virtual cpu operation queue head of the queue of present physical CPU, the priority P of current virtual CPU is compared ijwhether be greater than the virtual cpu priority P in virtual cpu operation queue ij, be that before current virtual CPU is inserted the virtual cpu compared in virtual cpu operation queue, otherwise order compares, until virtual cpu operation queue tail of the queue backward; After insertion completes, go to step (3);
(2.3) from the virtual cpu operation queue head of the queue of present physical CPU, the priority P of current virtual CPU is compared ijwhether be greater than the virtual cpu priority P in virtual cpu operation queue ij, be current virtual CPU to be inserted in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise carry out sub-step (2.4);
(2.4) priority P of current virtual CPU is compared ijwhether equal the virtual cpu priority P in virtual cpu operation queue ij, be carry out sub-step (2.5), otherwise order compares backward, until virtual cpu operation queue tail of the queue, after having inserted, goes to step (3);
(2.5) I of current virtual CPU is compared ijwhether value is greater than the I of the virtual cpu in virtual cpu operation queue ijvalue, is, to be inserted by current virtual CPU in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise order backward, compares the priority P of current virtual CPU ijwhether be greater than the virtual cpu priority P compared ij, be current virtual CPU to be inserted in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise carry out sub-step (2.4);
(3) as shown in Figure 3, virtual cpu operating procedure, comprises following sub-step:
(3.1) in the virtual cpu operation queue of present physical CPU, head of the queue virtual cpu credit value C is judged ijwhether be greater than 0, be, carry out sub-step (3.2); Otherwise trigger load balance policy, goes to step (4);
(3.2) judge whether the target physical CPU group that in virtual cpu operation queue, head of the queue virtual cpu compatibility is arranged is A bphysical cpu representated by mid-1 of bitmap, is, shows that it runs the load of I/O type, arranges its working time of leaf length T s=1ms; Otherwise show its moving calculation type load, its working time of leaf length T is set s=30ms;
(3.3) described head of the queue virtual cpu is deleted from the virtual cpu operation queue of place;
(3.4) judge whether present physical CPU is primary physical CPU, is, carry out sub-step (3.5); Otherwise carry out sub-step (3.8);
(3.5) on primary physical CPU, described head of the queue virtual cpu is run, the timing simultaneously of the secondary timer of primary physical CPU, master timer and adjustment timer; Whether supervisory user sends amendment virtual machine type command simultaneously, is perform step (8); Otherwise carry out sub-step (3.6);
(3.6) judge whether the working time of this head of the queue virtual cpu is less than T s, be carry out sub-step (3.7); Otherwise this head of the queue virtual cpu is removed from primary physical CPU, goes to step (2);
(3.7) when secondary timer experienced by time T secondary, then secondary timer reset, goes to step (5); When master timer experienced by time T main, then master timer resets, and goes to step (6); When adjustment timer experienced by time T adjust, then regulate timer reset, go to step (7); If at T sany timer is not triggered, virtual cpu continuous working period T in time s, this head of the queue virtual cpu is removed from primary physical CPU, goes to step (2);
(3.8) on present physical CPU, described head of the queue virtual cpu is run, during the secondary timer of present physical CPU; Whether supervisory user revises virtual machine type simultaneously, is perform step (8); Otherwise carry out sub-step (3.9);
(3.9) judge whether the working time of this head of the queue virtual cpu is less than T s, be carry out sub-step (3.10); Otherwise this head of the queue virtual cpu is removed from present physical CPU, goes to step (2);
(3.10) when secondary timer experienced by time T secondary, then secondary timer reset, goes to step (5), if at T sany timer is not triggered, virtual cpu continuous working period T in time s, this head of the queue virtual cpu is removed from present physical CPU, goes to step (2);
(4) as shown in Figure 4, load-balancing step, comprises following sub-step:
(4.1) the physical cpu group of carrying out load balancing is selected: judge that present physical CPU is at I/O bitmap A bwhether middle corresponding position is 1, is then by I/O bitmap A bin busy physical cpu as the target physical CPU group can carrying out load balancing, carry out sub-step (4.2); Otherwise bitmap A will be calculated cin busy physical cpu as the target physical CPU group can carrying out load balancing, carry out sub-step (4.2);
(4.2) physical cpu selecting migration optimum from target physical CPU group: at corresponding A bor A cin, travel through described target physical CPU group, judging whether to find and the busy physical cpu of present physical CPU on same physics core, is it can be used as the target physical CPU of migration, rotor step (4.8), otherwise rotor step (4.3);
(4.3) at corresponding A bor A cin, again travel through target physical CPU group, judge whether to find the busy physical cpu with present physical CPU in same physical package, be, carry out sub-step (4.4), otherwise rotor step (4.5);
(4.4) H of this busy physical cpu is judged pwhether be greater than the H of present physical CPU p, be then using the target physical CPU of this physical cpu as migration, rotor step (4.8), otherwise rotor step (4.5);
(4.5) in respective objects physical cpu group, order judges whether to find the busy physical cpu with present physical CPU in same physical package backward, is then rotor step (4.4), otherwise rotor step (4.6);
(4.6) again target physical CPU group is traveled through, judge whether to find the busy physical cpu from present physical CPU in different physical package, carry out sub-step (4.7), otherwise present physical CPU is labeled as the free time, run idle virtual cpu, rotor step (3.4);
(4.7) H of this busy physical cpu is judged pwhether be greater than the H of present physical CPU ptwice, be then using this busy physical cpu as migration target physical CPU, rotor step (4.8); Otherwise present physical CPU is labeled as the free time, runs idle virtual cpu, rotor step (3.4);
(4.8) on target physical CPU, suitable virtual cpu is selected to shift:
Judge that present physical CPU is at I/O bitmap A bwhether middle corresponding position is 1, is, travels through the virtual cpu operation queue of target physical CPU, incites somebody to action wherein I ijbe worth the destination virtual CPU of maximum virtual cpu as migration, rotor step (4.9); Otherwise the virtual cpu operation queue of traversal target physical CPU, finds H ijclosest to the H of target physical CPU pthe H of the physical cpu balanced with trigger load pthe virtual cpu of difference half as the destination virtual CPU of migration, rotor step (4.9);
(4.9) the destination virtual CPU of migration removed from the virtual cpu operation queue of target physical CPU and be inserted into the head of the queue of the virtual cpu operation queue of present physical CPU, rotor step (3.2);
(5) upgrade credit value and system load step, comprise following sub-step:
(5.1) the credit value C of current virtual CPU is upgraded ij: by C ij-10 × T 1value give C ij;
Upgrade the load variation H of current virtual CPU ij: by H ij+ 10 × T 1value give H ij;
Upgrade the historic load variable H of the physical cpu running current virtual CPU p: by H p+ 10 × T 1value give H p;
(5.2) judge that the physical cpu running current virtual CPU is at I/O bitmap A bwhether middle corresponding place value is 1, is, upgrades its I ij, by I ij-1/ (10 × T 1) value give I ij, carry out sub-step (5.3); Otherwise directly carry out sub-step (5.3);
(5.3) according to the type of current virtual CPU running load, its used up credit value is added in system load: judge that the physical cpu running current virtual CPU is at bitmap A bwhether middle corresponding place value is 1, is, upgrades the I/O load variation L of the overall situation b, by L b+ 10 × T 1value give L b, rotor step (3.4); Otherwise upgrade the computational load variables L of the overall situation c, by L c+ 10 × T 1value give L c, rotor step (3.4);
(6) redistribute credit value step, comprise following sub-step:
(6.1) judge whether current virtual CPU credit value is greater than 0, is, carry out sub-step (6.2); Otherwise by the priority P of current virtual CPU ijbe arranged to-2, expression cannot be dispatched again, carries out sub-step (6.2);
(6.2) for the virtual cpu of each virtual machine newly distributes credit value NC ij, NC ij=75;
Wherein NC ijit is the credit value that a jth virtual cpu of i-th virtual machine newly obtains;
(6.3) the credit value C of each virtual cpu is upgraded ij:
By NC ij+ C ijvalue give C ij,
Judge whether C ij> 0 and P ijvalue, for-2, is then by the priority P about virtual cpu ijchange to-1, rotor step (3.4), otherwise about the priority P of virtual cpu ijdo not change, direct rotor step (3.4);
(7) as shown in Figure 5, redistribute physical cpu step, comprise following sub-step:
(7.1) respective physical CPU number is calculated;
Run the load of I/O type physical cpu number N ( ab):
N( Ab)=(L b/(L b+L c))×16;
The physical cpu number N of moving calculation type load ( ac):
N( Ac)=16-N( Ab);
(7.2) I/O bitmap A is judged bthe physical cpu number of mid-1 whether be less than N ( ab), be carry out sub-step (7.3), otherwise rotor step (7.4);
(7.3) from the physical cpu of moving calculation type load, shift the physical cpu of difference number to run the load of I/O type: make Y=N ( ab)-I/O bitmap A bthe physical cpu number of mid-1, by I/O bitmap A bin before Y be 0 position all put 1, and bitmap A will be calculated cmiddle corresponding position clear 0, rotor step (7.6);
(7.4) I/O bitmap A is judged bthe physical cpu number of mid-1 whether equal N ( ab), be then rotor step (7.7); Otherwise carry out sub-step (7.5);
(7.5) physical cpu shifting difference number from the physical cpu running the load of I/O type carrys out the load of moving calculation type: make Y=I/O bitmap A bphysical cpu number-the N of mid-1 ( ab), by I/O bitmap A bin before Y put 1 all clear 0, and bitmap A will be calculated cmiddle correspondence position 1, rotor step (7.6);
(7.6) virtual cpu compatibility is reset: re-establish all virtual cpus and I/O bitmap A that run the load of I/O type bthe compatibility of the physical cpu of mid-1;
Re-establish all virtual cpus of moving calculation type load and calculating bitmap A cthe compatibility of the physical cpu of mid-1;
(7.7) by I/O load variation L band computational load variables L cclear 0, and the I/O task pressing degree variable I upgrading all virtual cpus ij: by 1/H ijvalue give I ij, rotor step (3.4);
(8) as shown in Figure 6, change virtual machine type step, comprises following sub-step:
(8.1) according to the amendment virtual machine type command that user sends, virtual machine ID, virtual machine type Q and virtual cpu field X is wherein read i, according to virtual machine ID, in its scheduling virtual machine structure, read its virtual machine type S i;
(8.2) judge whether Q=0, be, carry out sub-step (8.3), otherwise carry out sub-step (8.6);
(8.3) S is judged whether i=0, be keep virtual machine type S iconstant, rotor step (3.5); Otherwise judge whether S i=1, be carry out sub-step (8.4), otherwise carry out sub-step (8.5);
(8.4) S is judged i=1, represent the virtual machine virtual machine running the load of I/O type being changed into calculation type load, remove its each virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, all virtual cpus re-establishing this virtual machine with calculate bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 0, rotor step (3.5);
(8.5) S is judged i=2, represent the virtual machine virtual machine running mixed type load being changed into the load of moving calculation type, remove its each virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, re-establishes its each virtual cpu and calculates bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 0, rotor step (3.5);
(8.6) judge whether Q=1, be, carry out sub-step (8.7), otherwise carry out sub-step (8.11);
(8.7) S is judged whether i=0, be carry out step (8.8), otherwise carry out sub-step (8.9);
(8.8) represent the virtual machine being changed into by the virtual machine of moving calculation type load and run the load of I/O type, remove its each virtual cpu and calculate bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes all virtual cpus and the I/O bitmap A of this virtual machine bthe compatibility of the physical cpu of mid-1, and by S ibe revised as 1, rotor step (3.5);
(8.9) S is judged whether i=1, be keep virtual machine type S iconstant, rotor step (3.5); Otherwise carry out sub-step (8.10);
(8.10) S is judged i=2, represent and change the virtual machine running mixed type load into run the load of I/O type virtual machine, remove its each virtual cpu and calculate bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes its each virtual cpu and I/O bitmap A ithe compatibility of the physical cpu of mid-1, and by S ibe revised as 1, rotor step (3.5);
(8.11) judge Q=2, judge whether S i=0, be carry out sub-step (8.12), otherwise carry out sub-step (8.13);
(8.12) S is judged i=0, represent the virtual machine being changed into by the virtual machine of moving calculation type load and run mixed type load, remove X before in this virtual machine iindividual virtual cpu and calculating bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes X before in this virtual machine iindividual virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, and by S ibe revised as 2, rotor step (3.5);
(8.13) S is judged whether i=1, be carry out sub-step (8.14), otherwise carry out sub-step (8.15);
(8.14) S is judged i=1, represent and change the virtual machine running the load of I/O type into run mixed type load virtual machine, remove M after in this virtual machine i-X iindividual virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, re-establishes M after in this virtual machine i-X iindividual virtual cpu and calculating bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 2, rotor step (3.5);
(8.15) S is judged i=2, keep virtual machine type S iconstant, rotor step (3.5).
In the present embodiment, described scheduling initialization step, to redistribute in physical cpu step and change virtual machine type step, set up each virtual cpu and I/O bitmap A bor calculate bitmap A cduring the compatibility of the physical cpu of mid-1, by system definition, compatibility function int vcpu_set_affinity (struct vcpu*v is set, const cpumask_t*affinity), wherein parameter s truct vcpu*v is the virtual cpu pointer needing to arrange compatibility, and cpumask_t*affinity is the target physical CPU bitmap pointer arranging compatibility;
Remove each virtual cpu and I/O bitmap A bor calculate bitmap A cduring the compatibility of the physical cpu of mid-1, compatibility function int vcpu_set_affinity (struct vcpu*v, const cpumask_t*affinity) is set by system definition, re-establishes each virtual cpu and I/O bitmap A bor calculate bitmap A cthe compatibility of the physical cpu of mid-1, wherein parameter s truct vcpu*v is the virtual cpu pointer needing to reset compatibility, and cpumask_t*affinity is the target physical CPU bitmap pointer arranging compatibility.

Claims (3)

1. a virtual cpu dispatching method, comprise scheduling initialization step, insertion virtual cpu operation queue step, virtual cpu operating procedure, load-balancing step, renewal credit value and system load step, redistribute credit value step, redistribute physical cpu step and change virtual machine type step, it is characterized in that:
(1) initialization step is dispatched: for each physical cpu creates physical cpu scheduling structure: arrange master timer for primary physical CPU and regulate timer, other physical cpu arranges secondary timer; For each virtual machine creating scheduling virtual machine structure: initialization of virtual machine credit value weight, setting virtual machine type; Virtual cpu initialization of virtual CPU scheduling structure for each virtual machine: the load variation of each virtual cpu of initialization, I/O task pressing degree, for each virtual cpu distributes credit value; Initialization I/O bitmap A bwith calculating bitmap A c, A bin physical cpu be exclusively used in the virtual cpu of management and running I/O type load, A cin physical cpu be exclusively used in the virtual cpu of management and running calculation type load, they are complementary physical cpu bitmaps; The I/O load variation L of the initialization overall situation band computational load variables L c, L band L cthe credit value resource that the virtual cpu running the load of I/O type and calculation type load in register system respectively consumes; The priority of each virtual cpu is set;
(2) virtual cpu operation queue step is inserted: if the load of current virtual CPU moving calculation type, then after directly inserting all virtual cpus of same priority in virtual cpu operation queue; If current virtual CPU runs the load of I/O type, then sequentially insert virtual cpu operation queue by its priority, for the virtual cpu that priority is equal, then sort from big to small according to I/O pressing degree;
(3) virtual cpu operating procedure: if the head of the queue virtual cpu credit value of present physical CPU is less than or equal to 0, then trigger load is balanced, goes to step (4); Otherwise run head of the queue virtual cpu, if present physical CPU is primary physical CPU, in operational process, secondary timer, to the time, goes to step (5), master timer is to the time, go to step (6), regulate timer to the time, go to step (7), user sends amendment virtual machine type command, performs step (8); Present physical CPU is non-master physical cpu, and in operational process, secondary timer, to the time, goes to step (5), and user sends amendment virtual machine type command, performs step (8); Virtual cpu goes to step (2) after reaching working time, reinserts queue;
(4) load-balancing step: judge whether present physical CPU corresponding position in I/O bitmap is 1, is, I/O bitmap is put the busy physical cpu of 1 as target CPU group, otherwise calculating bitmap is put the busy physical cpu of 1 as target CPU group; Then the physical cpu selecting migration optimum from target physical CPU group, as the target physical CPU of migration, if the physical cpu not finding migration optimum, abandons this load balancing;
After finding target physical CPU, judge whether present physical CPU corresponding position in I/O bitmap is 1 again, be then using virtual cpu the most urgent for I/O task in the virtual cpu operation queue of target physical CPU as destination virtual CPU, otherwise using historic load in the virtual cpu operation queue of target physical CPU closest to the virtual cpu of the difference half of target physical CPU and present physical CPU historic load as destination virtual CPU, destination virtual CPU is deleted from former queue and inserts the virtual cpu queue head of the queue of present physical CPU; Go back to step (3);
(5) credit value and system load step is upgraded: upgrade the credit value of current virtual CPU, load variation, and upgrade the historic load variable of related physical CPU, judge whether the physical cpu corresponding place value in I/O bitmap running current virtual CPU is 1, be upgrade the I/O load variation of the urgent variable of its I/O task and the overall situation, go back to step (3); Otherwise upgrade the computational load variable of the overall situation; Go back to step (3);
(6) credit value step is redistributed: the credit value according to current virtual CPU judges priority, recalculate the credit value amount that each virtual cpu distributes, and upgrade the credit value of all virtual cpus, judge after upgrading, whether the credit value of virtual cpu just becomes from anon-normal, be change its priority, go back to step (3); Otherwise about the priority of virtual cpu does not change, directly go back to step (3);
(7) physical cpu step is redistributed: calculate respectively according to global I/O load variation and computational load variable and run the physical cpu number of I/O load and the physical cpu number of moving calculation type load; And revise corresponding I/O bitmap according to the physical cpu number calculated and calculate bitmap, re-establish the compatibility between virtual cpu and physical cpu; By I/O load variation and computational load variable clear 0, and upgrade the I/O task pressing degree variable of all virtual cpus, go back to step (3);
(8) virtual machine type step is changed: read user command, according to virtual machine ID wherein, virtual machine type Q and virtual cpu number X i, read former virtual machine type S i, according to virtual machine type Q and former virtual machine type S i, re-establish each virtual cpu of virtual machine and I/O bitmap or calculate the compatibility of bitmap, and revise virtual machine categorical variable, go back to step (3).
2. virtual cpu dispatching method as claimed in claim 1, is characterized in that:
(1) dispatch initialization step, comprise following sub-step:
(1.1) for each physical cpu creates physical cpu scheduling structure:
Determining whether that first physical cpu creates physical cpu scheduling structure, is carry out sub-step (1.2); Otherwise rotor step (1.3);
(1.2) first physical cpu is labeled as primary physical CPU, and master timer is set for it and regulates timer, master timer cycle T main=30 ~ 100ms is the integral multiple of 10ms, is T simultaneously secondaryintegral multiple, regulate timer cycle T adjust=1200 ~ 3000ms is T mainintegral multiple, rotor step (1.3);
(1.3) secondary timer is set, secondary timer period T secondaryfor (1 ~ 3) × 10ms; By the historic load variable H of this physical cpu pbe initialized as 0; Historic load variable H pbe recorded in the used up all credit value summations of virtual cpu that this physical cpu runs, physical cpu ordinal number p=1 ~ G, G are the physical cpu number in system, G=1 ~ 64;
(1.4) be each virtual machine creating scheduling virtual machine structure:
In the scheduling virtual machine structure of each virtual machine, by corresponding virtual machine credit value weights W ibe initialized as 256, corresponding virtual machine type S ibe set as 0, and its virtual cpu chained list is initialized as sky;
Wherein, virtual machine ordinal number i=1 ~ V, V are the virtual machine number that user creates, V=1 ~ 100; S ibe 0 expression calculation type load, S ibe 1 expression I/O type load, S ibe 2 expression mixed type loads, mixed type load is the load that calculation type is suitable with the load of I/O type;
(1.5) be the virtual cpu initialization of virtual CPU scheduling structure of each virtual machine:
Virtual cpu is added in the virtual cpu chained list of affiliated virtual machine;
By the load variation H of each virtual cpu ijbe initialized as 0,
By the I/O task pressing degree variable I of each virtual cpu ijbe initialized as 0, I ij=0 ~ 1, I ijbe worth larger expression I/O task more urgent, I ij=0, represent there is no I/O load;
And be that each virtual cpu distributes credit value, wherein the credit value C of a jth virtual cpu of i-th virtual machine ij=G × 10 × T main× W i/ (W t× M i);
Wherein, the total weight of system W T = Σ i = 1 V ( W i × M i ) ,
Ordinal number j=1 ~ the M of virtual cpu in virtual machine i, M ibe the virtual cpu number of i-th virtual machine, be set by the user, for being less than the integer of G;
(1.6) by I/O bitmap A bwith calculating bitmap A cinitialization:
Set up I/O bitmap A bwith calculating bitmap A c, by A bin everybody be initialized as full 0, A cin everybody be initialized as complete 1, represent the load of system default initialization moving calculation type;
(1.7), during initialization, the load of all virtual cpu acquiescence moving calculation types, sets up each virtual cpu and calculates bitmap A cthe compatibility of the physical cpu of mid-1;
(1.8) the I/O load variation L of the overall situation is set band computational load variables L c, by L band L call be initialized as 0;
(1.9) by the priority P of each virtual cpu ijbe initialized as-1, represent that it can be scheduled;
(2) insert virtual cpu operation queue step, comprise following sub-step:
(2.1) judge current virtual CPU whether with calculating bitmap A ccompatibility is set, is, represent this virtual cpu moving calculation type load, carry out sub-step (2.2), otherwise represent that this virtual cpu runs the load of I/O type, rotor step (2.3),
(2.2) from the virtual cpu operation queue head of the queue of present physical CPU, the priority P of current virtual CPU is compared ijwhether be greater than the virtual cpu priority P in virtual cpu operation queue ij, be that before current virtual CPU is inserted the virtual cpu compared in virtual cpu operation queue, otherwise order compares, until virtual cpu operation queue tail of the queue backward; After insertion completes, go to step (3);
(2.3) from the virtual cpu operation queue head of the queue of present physical CPU, the priority P of current virtual CPU is compared ijwhether be greater than the virtual cpu priority P in virtual cpu operation queue ij, be current virtual CPU to be inserted in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise carry out sub-step (2.4);
(2.4) priority P of current virtual CPU is compared ijwhether equal the virtual cpu priority P in virtual cpu operation queue ij, be carry out sub-step (2.5), otherwise order compares backward, until virtual cpu operation queue tail of the queue, after having inserted, goes to step (3);
(2.5) I of current virtual CPU is compared ijwhether value is greater than the I of the virtual cpu in virtual cpu operation queue ijvalue, is, to be inserted by current virtual CPU in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise order backward, compares the priority P of current virtual CPU ijwhether be greater than the virtual cpu priority P compared ij, be current virtual CPU to be inserted in virtual cpu operation queue before comparing virtual cpu and to go to step (3); Otherwise carry out sub-step (2.4);
(3) virtual cpu operating procedure, comprises following sub-step:
(3.1) in the virtual cpu operation queue of present physical CPU, head of the queue virtual cpu credit value C is judged ijwhether be greater than 0, be, carry out sub-step (3.2); Otherwise trigger load balance policy, goes to step (4);
(3.2) judge whether the target physical CPU group that in virtual cpu operation queue, head of the queue virtual cpu compatibility is arranged is A bphysical cpu representated by mid-1 of bitmap, is, shows that it runs the load of I/O type, arranges its working time of leaf length T s=1ms ~ 5ms; Otherwise show its moving calculation type load, its working time of leaf length T is set s=30ms ~ 100ms;
(3.3) described head of the queue virtual cpu is deleted from the virtual cpu operation queue of place;
(3.4) judge whether present physical CPU is primary physical CPU, is, carry out sub-step (3.5); Otherwise carry out sub-step (3.8);
(3.5) on primary physical CPU, described head of the queue virtual cpu is run, the timing simultaneously of the secondary timer of primary physical CPU, master timer and adjustment timer; Whether supervisory user sends amendment virtual machine type command simultaneously, is perform step (8); Otherwise carry out sub-step (3.6);
(3.6) judge whether the working time of this head of the queue virtual cpu is less than T s, be carry out sub-step (3.7); Otherwise this head of the queue virtual cpu is removed from primary physical CPU, goes to step (2);
(3.7) when secondary timer experienced by time T secondary, then secondary timer reset, goes to step (5); When master timer experienced by time T main, then master timer resets, and goes to step (6); When adjustment timer experienced by time T adjust, then regulate timer reset, go to step (7); If at T sany timer is not triggered, virtual cpu continuous working period T in time s, this head of the queue virtual cpu is removed from primary physical CPU, goes to step (2);
(3.8) on present physical CPU, described head of the queue virtual cpu is run, during the secondary timer of present physical CPU; Whether supervisory user revises virtual machine type simultaneously, is perform step (8); Otherwise carry out sub-step (3.9);
(3.9) judge whether the working time of this head of the queue virtual cpu is less than T s, be carry out sub-step (3.10); Otherwise this head of the queue virtual cpu is removed from present physical CPU, goes to step (2);
(3.10) when secondary timer experienced by time T secondary, then secondary timer reset, goes to step (5), if at T sany timer is not triggered, virtual cpu continuous working period T in time s, this head of the queue virtual cpu is removed from present physical CPU, goes to step (2);
(4) load-balancing step, comprises following sub-step:
(4.1) the physical cpu group of carrying out load balancing is selected: judge that present physical CPU is at I/O bitmap A bwhether middle corresponding position is 1, is, what the virtual cpu operation queue representing this physical cpu ran is the load of I/O type, by I/O bitmap A bthe busy physical cpu of mid-1, as the target physical CPU group can carrying out load balancing, carries out sub-step (4.2); Otherwise represent that what this physical cpu queue ran is calculation type load, will calculate bitmap A cthe busy physical cpu of mid-1, as the target physical CPU group can carrying out load balancing, carries out sub-step (4.2);
(4.2) physical cpu selecting migration optimum from target physical CPU group: at corresponding A bor A cin, travel through described target physical CPU group, judging whether to find and the busy physical cpu of present physical CPU on same physics core, is it can be used as the target physical CPU of migration, rotor step (4.8), otherwise rotor step (4.3);
(4.3) at corresponding A bor A cin, again travel through target physical CPU group, judge whether to find the busy physical cpu with present physical CPU in same physical package, be, carry out sub-step (4.4), otherwise rotor step (4.5);
(4.4) H of this busy physical cpu is judged pwhether be greater than the H of present physical CPU p, be then using the target physical CPU of this physical cpu as migration, rotor step (4.8), otherwise rotor step (4.5);
(4.5) in respective objects physical cpu group, order judges whether to find the busy physical cpu with present physical CPU in same physical package backward, is then rotor step (4.4), otherwise rotor step (4.6);
(4.6) again target physical CPU group is traveled through, judge whether to find the busy physical cpu from present physical CPU in different physical package, carry out sub-step (4.7), otherwise present physical CPU is labeled as the free time, run idle virtual cpu, rotor step (3.4);
(4.7) H of this busy physical cpu is judged pwhether be greater than the H of present physical CPU ptwice, be then using this busy physical cpu as migration target physical CPU, rotor step (4.8); Otherwise present physical CPU is labeled as the free time, runs idle virtual cpu, rotor step (3.4);
(4.8) on target physical CPU, suitable virtual cpu is selected to shift:
Judge that present physical CPU is at I/O bitmap A bwhether middle corresponding position is 1, is, travels through the virtual cpu operation queue of target physical CPU, incites somebody to action wherein I ijbe worth the destination virtual CPU of maximum virtual cpu as migration, rotor step (4.9); Otherwise the virtual cpu operation queue of traversal target physical CPU, finds H ijclosest to the H of target physical CPU pthe H of the physical cpu balanced with trigger load pthe virtual cpu of difference half as the destination virtual CPU of migration, rotor step (4.9);
(4.9) the destination virtual CPU of migration removed from the virtual cpu operation queue of target physical CPU and be inserted into the head of the queue of the virtual cpu operation queue of present physical CPU, rotor step (3.2);
(5) upgrade credit value and system load step, comprise following sub-step:
(5.1) the credit value C of current virtual CPU is upgraded ij: by C ij-10 × T 1value give C ij;
Upgrade the load variation H of current virtual CPU ij: by H ij+ 10 × T 1value give H ij;
Upgrade the historic load variable H of the physical cpu running current virtual CPU p: by H p+ 10 × T 1value give H p;
The credit value amount of virtual cpu operation 1ms consumption is 10, T 1for current virtual CPU brought into operation the time experienced so far from last time, unit is ms;
(5.2) judge that the physical cpu running current virtual CPU is at I/O bitmap A bwhether middle corresponding place value is 1, is, represents and has run I/O task, upgrades its I ij, by I ij-1/ (10 × T 1) value give I ij, carry out sub-step (5.3); Otherwise directly carry out sub-step (5.3);
(5.3) according to the type of current virtual CPU running load, its used up credit value is added in system load: judge that the physical cpu running current virtual CPU is at bitmap A bwhether middle corresponding place value is 1, is, upgrades the I/O load variation L of the overall situation b, by L b+ 10 × T 1value give L b, rotor step (3.4); Otherwise upgrade the computational load variables L of the overall situation c, by L c+ 10 × T 1value give L c, rotor step (3.4);
(6) redistribute credit value step, comprise following sub-step:
(6.1) judge whether current virtual CPU credit value is greater than 0, is, carry out sub-step (6.2); Otherwise by the priority P of current virtual CPU ijbe arranged to-2, expression cannot be dispatched again, carries out sub-step (6.2);
(6.2) for the virtual cpu of each virtual machine newly distributes credit value NC ij:
NC ij=G × T main× 10 × W i/ (W t× M i);
Wherein NC ijit is the credit value that a jth virtual cpu of i-th virtual machine newly obtains;
(6.3) the credit value C of each virtual cpu is upgraded ij:
By NC ij+ C ijvalue give C ij,
Judge whether C ij> 0 and P ijvalue, for-2, is then by the priority P about virtual cpu ijchange to-1, rotor step (3.4), otherwise about the priority P of virtual cpu ijdo not change, direct rotor step (3.4);
(7) redistribute physical cpu step, comprise following sub-step:
(7.1) respective physical CPU number is calculated;
Run the load of I/O type physical cpu number N ( ab):
N( Ab)=(L b/(L b+L c))×G;
The physical cpu number N of moving calculation type load ( ac):
N( Ac)=G-N( Ab);
(7.2) I/O bitmap A is judged bthe physical cpu number of mid-1 whether be less than N ( ab), be carry out sub-step (7.3), otherwise rotor step (7.4);
(7.3) from the physical cpu of moving calculation type load, shift the physical cpu of difference number to run the load of I/O type: make Y=N ( ab)-I/O bitmap A bthe physical cpu number of mid-1, by I/O bitmap A bin before Y be 0 position all put 1, and bitmap A will be calculated cmiddle corresponding position clear 0, rotor step (7.6);
(7.4) I/O bitmap A is judged bthe physical cpu number of mid-1 whether equal N ( ab), be then rotor step (7.7); Otherwise carry out sub-step (7.5);
(7.5) physical cpu shifting difference number from the physical cpu running the load of I/O type carrys out the load of moving calculation type: make Y=I/O bitmap A bphysical cpu number-the N of mid-1 ( ab), by I/O bitmap A bin before Y put 1 all clear 0, and bitmap A will be calculated cmiddle correspondence position 1, rotor step (7.6);
(7.6) virtual cpu compatibility is reset: re-establish all virtual cpus and I/O bitmap A that run the load of I/O type bthe compatibility of the physical cpu of mid-1;
Re-establish all virtual cpus of moving calculation type load and calculating bitmap A cthe compatibility of the physical cpu of mid-1;
(7.7) by I/O load variation L band computational load variables L cclear 0, and the I/O task pressing degree variable I upgrading all virtual cpus ij: by 1/H ijvalue give I ij, rotor step (3.4);
(8) change virtual machine type step, comprise following sub-step:
(8.1) according to the amendment virtual machine type command that user sends, virtual machine ID, virtual machine type Q wherein and virtual cpu number X is read i, according to virtual machine ID, in its scheduling virtual machine structure, read its virtual machine type S i;
Described amendment virtual machine type command comprises virtual machine id field, virtual machine type field and virtual cpu number field, and virtual machine id field provides the virtual machine ID of type to be modified; Virtual machine type field provides virtual machine type Q to be modified, and Q is 0 expression calculation type load, and Q is 1 expression I/O type load, and Q is 2 expression mixed type loads; Virtual cpu number field provides for running the virtual cpu number of I/O load in mixed virtual machine, and only as Q=2, this field is just effective;
(8.2) judge whether Q=0, be, carry out sub-step (8.3), otherwise carry out sub-step (8.6);
(8.3) S is judged whether i=0, be keep virtual machine type S iconstant, rotor step (3.5); Otherwise judge whether S i=1, be carry out sub-step (8.4), otherwise carry out sub-step (8.5);
(8.4) S is judged i=1, represent the virtual machine virtual machine running the load of I/O type being changed into calculation type load, remove its each virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, all virtual cpus re-establishing this virtual machine with calculate bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 0, rotor step (3.5);
(8.5) S is judged i=2, represent the virtual machine virtual machine running mixed type load being changed into the load of moving calculation type, remove its each virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, re-establishes its each virtual cpu and calculates bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 0, rotor step (3.5);
(8.6) judge whether Q=1, be, carry out sub-step (8.7), otherwise carry out sub-step (8.11);
(8.7) S is judged whether i=0, be carry out step (8.8), otherwise carry out sub-step (8.9);
(8.8) represent the virtual machine being changed into by the virtual machine of moving calculation type load and run the load of I/O type, remove its each virtual cpu and calculate bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes all virtual cpus and the I/O bitmap A of this virtual machine bthe compatibility of the physical cpu of mid-1, and by S ibe revised as 1, rotor step (3.5);
(8.9) S is judged whether i=1, be keep virtual machine type S iconstant, rotor step (3.5); Otherwise carry out sub-step (8.10);
(8.10) S is judged i=2, represent and change the virtual machine running mixed type load into run the load of I/O type virtual machine, remove its each virtual cpu and calculate bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes its each virtual cpu and I/O bitmap A ithe compatibility of the physical cpu of mid-1, and by S ibe revised as 1, rotor step (3.5);
(8.11) judge Q=2, judge whether S i=0, be carry out sub-step (8.12), otherwise carry out sub-step (8.13);
(8.12) S is judged i=0, represent the virtual machine being changed into by the virtual machine of moving calculation type load and run mixed type load, remove X before in this virtual machine iindividual virtual cpu and calculating bitmap A cthe compatibility of the physical cpu of mid-1, re-establishes X before in this virtual machine iindividual virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, and by S ibe revised as 2, rotor step (3.5);
(8.13) S is judged whether i=1, be carry out sub-step (8.14), otherwise carry out sub-step (8.15);
(8.14) S is judged i=1, represent and change the virtual machine running the load of I/O type into run mixed type load virtual machine, remove M after in this virtual machine i-X iindividual virtual cpu and I/O bitmap A bthe compatibility of the physical cpu of mid-1, re-establishes M after in this virtual machine i-X iindividual virtual cpu and calculating bitmap A cthe compatibility of the physical cpu of mid-1, and by S ibe revised as 2, rotor step (3.5);
(8.15) S is judged i=2, keep virtual machine type S iconstant, rotor step (3.5).
3. virtual cpu dispatching method as claimed in claim 2, is characterized in that:
Described scheduling initialization step, to redistribute in physical cpu step and change virtual machine type step, set up each virtual cpu and I/O bitmap A bor calculate bitmap A cduring the compatibility of the physical cpu of mid-1, compatibility function is set by system definition;
Remove each virtual cpu and I/O bitmap A bor calculate bitmap A cduring the compatibility of the physical cpu of mid-1, compatibility function is set by system definition, re-establishes each virtual cpu and I/O bitmap A bor calculate bitmap A cthe compatibility of the physical cpu of mid-1.
CN201410676265.3A 2014-11-23 2014-11-23 A kind of virtual cpu dispatching method Active CN104503838B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201410676265.3A CN104503838B (en) 2014-11-23 2014-11-23 A kind of virtual cpu dispatching method
PCT/CN2014/094010 WO2016078178A1 (en) 2014-11-23 2014-12-17 Virtual cpu scheduling method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410676265.3A CN104503838B (en) 2014-11-23 2014-11-23 A kind of virtual cpu dispatching method

Publications (2)

Publication Number Publication Date
CN104503838A true CN104503838A (en) 2015-04-08
CN104503838B CN104503838B (en) 2017-06-27

Family

ID=52945238

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410676265.3A Active CN104503838B (en) 2014-11-23 2014-11-23 A kind of virtual cpu dispatching method

Country Status (2)

Country Link
CN (1) CN104503838B (en)
WO (1) WO2016078178A1 (en)

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105045667A (en) * 2015-07-13 2015-11-11 中国科学院计算技术研究所 Resource pool management method for vCPU scheduling of virtual machines
CN105607950A (en) * 2015-10-30 2016-05-25 浪潮(北京)电子信息产业有限公司 Virtual machine resource configuration method and apparatus
CN107506286A (en) * 2017-09-26 2017-12-22 郑州云海信息技术有限公司 CPU and memory block automatically upper inserting method and system
CN107544843A (en) * 2017-08-28 2018-01-05 北京翼辉信息技术有限公司 A kind of partition system dispatching algorithm
CN108701046A (en) * 2015-12-23 2018-10-23 英特尔Ip公司 For avoiding the virtual cpu of the physical cpu contention between virtual machine from merging
CN109062629A (en) * 2018-07-13 2018-12-21 成都泛美视界科技有限公司 A kind of performance optimization method of flight simulation software
CN109298972A (en) * 2018-09-06 2019-02-01 高盈量化云科技(深圳)有限公司 A kind of High Availabitity policy engine
CN109840135A (en) * 2019-01-30 2019-06-04 郑州云海信息技术有限公司 A kind of load-balancing method, device and electronic equipment
US10445100B2 (en) 2016-06-09 2019-10-15 International Business Machines Corporation Broadcasting messages between execution slices for issued instructions indicating when execution results are ready
CN111274024A (en) * 2019-03-19 2020-06-12 中标软件有限公司 Ready queue average load optimization method based on CFS scheduler and data structure
CN111343275A (en) * 2020-03-02 2020-06-26 北京奇艺世纪科技有限公司 Resource scheduling method and system
CN111427673A (en) * 2020-03-16 2020-07-17 杭州迪普科技股份有限公司 Load balancing method, device and equipment
CN112204523A (en) * 2018-05-30 2021-01-08 超威半导体公司 Multi-kernel wavefront scheduler
CN112988399A (en) * 2021-04-30 2021-06-18 成都网安科技发展有限公司 Processor scheduling method and processor scheduling device based on virtualization technology
CN113032154A (en) * 2021-04-19 2021-06-25 深信服科技股份有限公司 Virtual CPU scheduling method and device, electronic equipment and storage medium
CN113282366A (en) * 2021-04-02 2021-08-20 中国船舶重工集团公司第七研究院 Static virtual machine placement method oriented to embedded virtualization environment
US11954527B2 (en) 2020-12-09 2024-04-09 Industrial Technology Research Institute Machine learning system and resource allocation method thereof

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109753339B (en) * 2017-11-06 2023-04-28 阿里巴巴集团控股有限公司 Resource allocation method and device and electronic equipment
CN108595249A (en) * 2018-05-02 2018-09-28 联想(北京)有限公司 A kind of virtual machine method for scheduling task and electronic equipment
CN111459622B (en) * 2020-04-15 2023-10-13 腾讯科技(深圳)有限公司 Method, device, computer equipment and storage medium for scheduling virtual CPU

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020087611A1 (en) * 2000-12-28 2002-07-04 Tsuyoshi Tanaka Virtual computer system with dynamic resource reallocation
CN102253857A (en) * 2011-06-24 2011-11-23 华中科技大学 Xen virtual machine scheduling control method in multi-core environment
CN103049332A (en) * 2012-12-06 2013-04-17 华中科技大学 Virtual CPU scheduling method
CN103678003A (en) * 2013-12-18 2014-03-26 华中科技大学 Virtual CPU scheduling method capable of enhancing real-time performance

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020087611A1 (en) * 2000-12-28 2002-07-04 Tsuyoshi Tanaka Virtual computer system with dynamic resource reallocation
CN102253857A (en) * 2011-06-24 2011-11-23 华中科技大学 Xen virtual machine scheduling control method in multi-core environment
CN103049332A (en) * 2012-12-06 2013-04-17 华中科技大学 Virtual CPU scheduling method
CN103678003A (en) * 2013-12-18 2014-03-26 华中科技大学 Virtual CPU scheduling method capable of enhancing real-time performance

Cited By (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105045667B (en) * 2015-07-13 2018-11-30 中国科学院计算技术研究所 A kind of resource pool management method for virtual machine vCPU scheduling
CN105045667A (en) * 2015-07-13 2015-11-11 中国科学院计算技术研究所 Resource pool management method for vCPU scheduling of virtual machines
CN105607950A (en) * 2015-10-30 2016-05-25 浪潮(北京)电子信息产业有限公司 Virtual machine resource configuration method and apparatus
CN108701046A (en) * 2015-12-23 2018-10-23 英特尔Ip公司 For avoiding the virtual cpu of the physical cpu contention between virtual machine from merging
CN108701046B (en) * 2015-12-23 2022-04-08 英特尔公司 Method, system, device, apparatus, and medium for virtual CPU merging to avoid physical CPU contention between virtual machines
US10445100B2 (en) 2016-06-09 2019-10-15 International Business Machines Corporation Broadcasting messages between execution slices for issued instructions indicating when execution results are ready
CN107544843A (en) * 2017-08-28 2018-01-05 北京翼辉信息技术有限公司 A kind of partition system dispatching algorithm
CN107506286A (en) * 2017-09-26 2017-12-22 郑州云海信息技术有限公司 CPU and memory block automatically upper inserting method and system
CN112204523A (en) * 2018-05-30 2021-01-08 超威半导体公司 Multi-kernel wavefront scheduler
CN109062629A (en) * 2018-07-13 2018-12-21 成都泛美视界科技有限公司 A kind of performance optimization method of flight simulation software
CN109298972A (en) * 2018-09-06 2019-02-01 高盈量化云科技(深圳)有限公司 A kind of High Availabitity policy engine
CN109298972B (en) * 2018-09-06 2019-11-15 高盈量化云科技(深圳)有限公司 A kind of High Availabitity policy engine
CN109840135B (en) * 2019-01-30 2022-02-18 郑州云海信息技术有限公司 Load balancing method and device and electronic equipment
CN109840135A (en) * 2019-01-30 2019-06-04 郑州云海信息技术有限公司 A kind of load-balancing method, device and electronic equipment
CN111274024A (en) * 2019-03-19 2020-06-12 中标软件有限公司 Ready queue average load optimization method based on CFS scheduler and data structure
CN111274024B (en) * 2019-03-19 2023-05-30 中标软件有限公司 CFS scheduler-based ready queue average load optimization method and data structure
CN111343275A (en) * 2020-03-02 2020-06-26 北京奇艺世纪科技有限公司 Resource scheduling method and system
CN111343275B (en) * 2020-03-02 2022-09-30 北京奇艺世纪科技有限公司 Resource scheduling method and system
CN111427673B (en) * 2020-03-16 2023-04-07 杭州迪普科技股份有限公司 Load balancing method, device and equipment
CN111427673A (en) * 2020-03-16 2020-07-17 杭州迪普科技股份有限公司 Load balancing method, device and equipment
US11954527B2 (en) 2020-12-09 2024-04-09 Industrial Technology Research Institute Machine learning system and resource allocation method thereof
CN113282366A (en) * 2021-04-02 2021-08-20 中国船舶重工集团公司第七研究院 Static virtual machine placement method oriented to embedded virtualization environment
CN113032154A (en) * 2021-04-19 2021-06-25 深信服科技股份有限公司 Virtual CPU scheduling method and device, electronic equipment and storage medium
CN113032154B (en) * 2021-04-19 2023-11-07 深信服科技股份有限公司 Scheduling method and device for virtual CPU, electronic equipment and storage medium
CN112988399B (en) * 2021-04-30 2021-07-20 成都网安科技发展有限公司 Processor scheduling method and processor scheduling device based on virtualization technology
CN112988399A (en) * 2021-04-30 2021-06-18 成都网安科技发展有限公司 Processor scheduling method and processor scheduling device based on virtualization technology

Also Published As

Publication number Publication date
WO2016078178A1 (en) 2016-05-26
CN104503838B (en) 2017-06-27

Similar Documents

Publication Publication Date Title
CN104503838A (en) Method for scheduling virtual CPU (Central Processing Unit)
US10503704B2 (en) Isolating resources and performance in a database management system
US9268394B2 (en) Virtualized application power budgeting
CN103248659B (en) A kind of cloud computing resource scheduling method and system
CN102253857B (en) Xen virtual machine scheduling control method in multi-core environment
CN103297499B (en) Scheduling method and system based on cloud platform
CN102521055B (en) Virtual machine resource allocating method and virtual machine resource allocating system
Nguyen et al. A hybrid scheduling algorithm for data intensive workloads in a mapreduce environment
US20160196157A1 (en) Information processing system, management device, and method of controlling information processing system
CN106125888B (en) The efficient power-economizing method of the utilization of resources in cloud data center based on virtual machine (vm) migration
US8694295B2 (en) System and method for time virtualization in computer systems
Sharma et al. An improved task allocation strategy in cloud using modified k-means clustering technique
CN106775949A (en) A kind of Application of composite feature that perceives migrates optimization method online with the virtual machine of the network bandwidth
Wang et al. Dependency-aware network adaptive scheduling of data-intensive parallel jobs
CN113342477A (en) Container group deployment method, device, equipment and storage medium
CN109815009A (en) Scheduling of resource and optimization method under a kind of CSP
Li et al. Energy-aware task scheduling optimization with deep reinforcement learning for large-scale heterogeneous systems
CN109739634A (en) A kind of atomic task execution method and device
CN105426247A (en) HLA federate planning and scheduling method
CN103106112A (en) Method and device based on maximum load and used for load balancing scheduling
Gouasmi et al. Cost-efficient distributed MapReduce job scheduling across cloud federation
Peng et al. Research on cloud computing resources provisioning based on reinforcement learning
KR20140125893A (en) Virtualized many-core environment job distribution system and method, and recording medium thereof
Islam et al. Resource management and scheduling for big data applications in cloud computing environments
Haque et al. A priority-based process scheduling algorithm in cloud computing

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant