Load scheduling method and system
By determining the idle core in the host and matching the virtual machine tasks, the problem of large delay in virtual machine task scheduling in virtualized scenarios is solved, and the operation efficiency of virtual machine tasks is significantly improved.
Patent Information
- Application Number
- CN202111372448.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-18
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2041-11-18
AI Technical Summary
In virtualization scenarios, the scheduling delay of the virtual machine central processor (vcpu) is large, resulting in a decline in the performance of virtual machine tasks. In the existing technology, the two-layer scheduling of the host and virtual machine lacks correlation, resulting in a large scheduling delay. .
By implementing the load scheduling method in the host, when determining that the preempted host task is the virtual thread of the virtual machine, the current idle core is determined, and the task is matched with the idle core according to the preset matching rules. If there is no matching idle core. , then record preemption information and pass it to the virtual machine through shared memory to avoid the virtual machine tasks continuing to migrate to the preempted vcpu.
It significantly reduces the scheduling delay of virtual machine tasks, improves the operation efficiency of virtual machine tasks, and solves the problem of large delay of vcpu thread scheduling in virtualized scenarios.
Smart Images

Figure CN114253708B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present specification relate to the field of computer technology, and in particular to a load scheduling method. Background Art
[0002] In virtualization implementation technology, the virtual machine central processing unit (vcpu) used by a virtual machine (guest) is generally implemented as a thread on the host. For the host, scheduling a vcpu is actually scheduling a thread. That is, in the virtualization scenario, the guest environment is reflected as several vcpu threads on the host. The overall scheduling performance of the system is determined by the two-level scheduling of the host kernel (host kernel) and the guest kernel (virtual machine kernel). Currently, these two levels of scheduling belong to separate systems and have no correlation, resulting in relatively large scheduling delays in most scenarios. Summary of the invention
[0003] In view of this, the present specification provides a load scheduling method. One or more embodiments of the present specification also relate to a load scheduling system, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.
[0004] According to a first aspect of an embodiment of this specification, a load scheduling method is provided, which is applied to a load scheduling system, the system comprising a host machine and a virtual machine running on the host machine, wherein the method comprises:
[0005] The host machine determines a current idle core when determining that the preempted host machine task is a virtual thread of the virtual machine, wherein the virtual thread is a central processing unit thread of the virtual machine and the idle core is an idle host machine central processing unit;
[0006] The host machine matches the preempted host machine task with the current idle core according to a preset matching rule, and when it is determined that there is no target idle core in the current idle core that matches the preempted host machine task, records the preemption information of the preempted host machine task and transmits the preemption information to the virtual machine.
[0007] According to a second aspect of an embodiment of this specification, a load scheduling system is provided, the system comprising a host machine and a virtual machine running on the host machine, wherein:
[0008] The host machine is configured to determine a current idle core when it is determined that the preempted host machine task is a virtual thread of the virtual machine, wherein the virtual thread is a central processing unit thread of the virtual machine and the idle core is an idle host machine central processing unit;
[0009] The host machine is configured to match the preempted host machine task with the current idle core according to a preset matching rule, and when it is determined that there is no target idle core in the current idle core that matches the preempted host machine task, record the preemption information of the preempted host machine task and pass the preemption information to the virtual machine.
[0010] According to a third aspect of an embodiment of this specification, a computing device is provided, including:
[0011] Memory and processor;
[0012] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the above-mentioned load scheduling method are implemented.
[0013] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the above-mentioned load scheduling method are implemented.
[0014] An embodiment of the present specification implements a load scheduling method, which is applied to a load scheduling system, wherein the system includes a host machine and a virtual machine running on the host machine, wherein the method includes: the host machine determines a current idle core when it is determined that a preempted host machine task is a virtual thread of the virtual machine, wherein the virtual thread is a virtual machine central processing unit thread, and the idle core is an idle host machine central processing unit; the host machine matches the preempted host machine task with the current idle core according to a preset matching rule, and when it is determined that there is no target idle core in the current idle core that matches the preempted host machine task, records the preemption information of the preempted host machine task, and transmits the preemption information to the virtual machine.
[0015] Specifically, the load scheduling method provides a top-down collaborative scheduling optimization method. When the host machine determines that the CPU (host central processing unit) corresponding to a host task (vcpu thread) is preempted and there is no idle core to process it, the preemption information of the vcpu thread is transmitted to the virtual machine through the shared memory. The subsequent virtual machine can avoid continuing to migrate the virtual machine task to the vcpu thread based on the preemption information, which significantly reduces the scheduling delay of the entire guset and improves the operating efficiency of the virtual machine tasks running in the guset. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a flow chart of a load scheduling method provided by an embodiment of this specification;
[0017] Figure 2 It is a schematic diagram of a processing process of a load scheduling method provided by an embodiment of this specification;
[0018] Figure 3 It is a structural diagram of a load scheduling system provided by an embodiment of this specification;
[0019] Figure 4 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0020] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0021] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0022] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0023] First, the terms involved in one or more embodiments of this specification are explained.
[0024] host: host environment in a virtualization scenario.
[0025] guest: The guest environment in a virtualization scenario.
[0026] Secure container: A container form with higher security and isolation using virtualization technology.
[0027] odps: open data processing service, open data processing service.
[0028] kvm: system virtualization module.
[0029] cfs scheduler: completely fair scheduler.
[0030] vcpu scheduler: virtual thread scheduler.
[0031] In the project of secure container in the colocation scenario, the offline odps job originally running on the host was migrated to the secure container. Due to the addition of virtualization scenario, the offline performance has been significantly reduced. After analysis, it was found that the main factor was the large delay of vcpu thread scheduling in the virtualization scenario; based on this, the load scheduling method provided in the embodiment of this specification solves this problem and improves the performance of offline odps in the secure container.
[0032] Specifically, in this specification, a load scheduling method is provided. This specification also relates to a load scheduling system, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0033] See also Figure 1 , Figure 1 A flow chart of a load scheduling method provided according to an embodiment of the present specification is shown, wherein the method is applied to a load scheduling system, the system comprising a host machine and a virtual machine running on the host machine; specifically, the method comprises the following steps.
[0034] Step 102: The host machine determines a current idle core when determining that the preempted host machine task is a virtual thread of the virtual machine, wherein the virtual thread is a virtual machine central processing unit thread and the idle core is an idle host machine central processing unit.
[0035] Among them, the host machine can be understood as the above-mentioned host, and the virtual machine can be understood as the above-mentioned guest, that is, the secure container in the host; in addition, the host machine includes a kvm module, which is a module in the host machine that supports the virtual machine.
[0036] In practical applications, the implementation principle of the load scheduling method is to implement a zero-delay balance (load balancing) framework in the host environment. The above-mentioned kvm module is the user of the balance framework, that is, the kvm module that supports the virtual machine in the host machine uses the balance framework, which solves the technical problem that the two-layer scheduling of the host machine and the virtual machine in the above-mentioned prior art belongs to separate systems and has no correlation, resulting in a relatively large job scheduling delay for the virtual machine in most scenarios.
[0037] The specific implementation method is: when the vcpu thread (host task) of a virtual machine registered with this framework is preempted by other tasks, it will be immediately pushed to other idle cpus in the host, and quickly scheduled to run to ensure scheduling efficiency; and when no suitable idle cpu can be found for pushing, the preemption information of the preempted vcpu thread will be recorded in the kvm module and transmitted to the virtual machine through shared memory, so that subsequent virtual machines can avoid migrating other virtual machine tasks to the vcpu thread based on the preemption information, avoid the vcpu thread being preempted in the cpu in the host environment and unable to process tasks, causing processing delays for virtual machine tasks migrated to the vcpu thread, significantly reducing the scheduling delay of the entire guset and improving the operating efficiency of virtual machine tasks running in the guset.
[0038] Specifically, a host task can be understood as a task running on the host CPU, including ordinary online tasks and vcpu tasks; wherein a vcpu task can be understood as a vcpu thread running on the host CPU, i.e., a virtual thread, or a virtual machine CPU thread. An idle core can be understood as an idle host CPU. In the embodiments of this specification, a core can be understood as a host CPU (CPU).
[0039] In specific implementation, the host machine determines the current idle core when it is determined that the preempted host task is a virtual thread of the virtual machine; it can be understood that the task scheduler of the host machine schedules the host task to the corresponding CPU in real time to run, and when a host task is preempted and it is determined that the preempted host task is a vcpu thread, all currently idle CPUs in the host machine are determined. In actual use, the task scheduler of the host machine includes the cfs scheduler (general scheduler, that is, the scheduler that can schedule all host machine tasks) and the vcpu scheduler, among which the vcpu scheduler can be understood as the superposition scheduler of the cfs scheduler, that is, the cfs scheduler schedules all host machine tasks. When the cpu corresponding to a host machine task is preempted, and the host machine task is determined to be a vcpu thread based on the characteristics of the host machine task, the vcpu scheduler is used to process the preempted vcpu thread, that is, to determine the current idle cpu and allocate a target idle cpu to it for task processing; or if there is no target idle cpu, the preempted vcpu thread is marked for preemption. The specific implementation method is as follows:
[0040] The host machine includes a completely fair scheduler and a virtual thread scheduler;
[0041] Accordingly, when the host machine determines that the preempted host machine task is a virtual thread of the virtual machine, the host machine determines the current idle core, including:
[0042] When the completely fair scheduler determines that the preempted host task is a virtual thread of the virtual machine, the completely fair scheduler sends the preempted host task to the virtual thread scheduler for processing;
[0043] The virtual thread scheduler receives the preempted host machine task and determines a current idle core.
[0044] Specifically, when the cfs scheduler determines that the preempted host task is a virtual thread of the virtual machine, the cfs scheduler sends the preempted host task to the vcpu scheduler for processing; the vcpu scheduler receives the preempted host task and determines the current idle core.
[0045] That is, the host machine uses the cfs scheduler and the vcpu scheduler, which is actually equivalent to adding a layer of scheduling logic to the host machine's task scheduler when the vcpu thread is preempted, so as to ensure the rapid scheduling and operation of the vcpu thread.
[0046] Step 104: The host machine matches the preempted host machine task with the current idle core according to a preset matching rule. When it is determined that there is no target idle core in the current idle core that matches the preempted host machine task, the host machine records the preemption information of the preempted host machine task and transmits the preemption information to the virtual machine.
[0047] Specifically, the host machine matches the preempted host machine task with the current idle core according to a preset matching rule, and when it is determined that there is no target idle core matching the preempted host machine task in the current idle core, records the preemption information of the preempted host machine task, and transmits the preemption information to the virtual machine, including:
[0048] The virtual thread scheduler matches the preempted host task with the current idle core according to a preset matching rule. When it is determined that there is no target idle core in the current idle core that matches the preempted host task, the virtual thread scheduler records the preemption information of the preempted host task and transmits the preemption information to the virtual machine through shared memory.
[0049] That is, when the preempted host task is a vcpu thread, the vcpu scheduler will match the preempted host task with the current idle core according to the preset matching rule, and when it is determined that there is no target idle core matching the preempted host task in the current idle core, the preemption information of the preempted host task will be recorded and transferred to the virtual machine through the shared memory. And the preemption information is transferred to the virtual machine through the shared memory, saving network resource occupation.
[0050] After determining the current idle core, the vcpu scheduler will match the current idle core with the preempted host task according to the preset matching rules to determine which current idle core is more suitable for the preempted host task to run on. The specific implementation method is as follows:
[0051] The host machine matches the preempted host machine task with the current idle core according to a preset matching rule, including:
[0052] The host machine determines whether the preempted host machine task meets the preset running condition of the current idle core, and / or
[0053] Whether the average idle time of the current idle core is greater than the migration time of the preempted host task.
[0054] The preset running condition includes that the preempted host machine task is in the executable task list corresponding to the current idle core, and / or the preempted host machine task is not evicted by the current idle core.
[0055] During the specific implementation, the host machine obtains the current idle cores, such as idle cpu1, idle cpu2 and idle cpu3; then determines whether the preempted host machine task (vcpu thread) meets the preset operating conditions of each current idle core, and / or whether the average idle time of each current idle core is greater than the migration time of the preempted vcpu thread.
[0056] In actual applications, each currently idle core corresponds to a task runnable list, which stores at least one host task to be run. In a co-location scenario, when a high-priority online task runs on one logical core of a pair of logical cores of an idle core, a low-priority task (such as an offline task) on the other logical core will be evicted. That is, in a co-location scenario, if a preempted vcpu thread wants to run on a currently idle core, it is necessary to determine whether the preempted vcpu will be evicted based on the priority of the preempted vcpu thread.
[0057] Specifically, the host machine determines whether the preempted host machine task meets the preset running conditions of the current idle core; it can be understood that the host machine's vcpu scheduler determines whether the preempted vcpu thread is in the task runnable list corresponding to the current idle core, and / or determines whether the preempted vcpu will be evicted by the current idle core.
[0058] In addition, whether the average idle time of the current idle core is greater than the migration time of the preempted host task can be understood as whether the average idle time of each idle core is greater than the shortest migration time of the preempted vcpu thread, so as to avoid frequent push leading to excessive cache miss (cache miss rate).
[0059] In the load scheduling method provided in the embodiment of this specification, after the host machine determines the idle core, it matches the preempted vcpu thread with each current idle core according to the preset matching rules, determines a target idle core that matches the preempted vcpu thread, and subsequently migrates the preempted vcpu thread to the target idle core for operation. In the specific implementation, the matching rules for the target idle core that matches the preempted vcpu are not limited to the above method. For example, the preset operating conditions may also include that the executable core corresponding to the preempted host machine task includes the current idle core, that is, the current idle core exists in the executable cpu list corresponding to the preempted vcpu thread. In the embodiment of this specification, only the above is taken as an example to explain that in the process of considering cpu migration, it is necessary to consider multiple target idle cpus and the preempted vcpu thread to ensure that a more suitable target idle cpu can be selected for the preempted vcpu thread to ensure its operating efficiency.
[0060] When it is determined that there is no target idle core matching the preempted vcpu thread in the current idle cores, the preemption information of the preempted vcpu thread is recorded, and the preemption information is passed to the virtual machine through shared memory. Continuing with the above example, the current idle cores include idle cpu1, idle cpu2, and idle cpu3. Each idle cpu is matched with the preempted vcpu thread according to the preset matching rules. Idle cpu1, idle cpu2, and idle cpu3 do not match the preempted vcpu thread, that is, there is no target idle core that can run the preempted vcpu thread, then the preemption information of the preempted vcpu thread is recorded. The specific implementation method is described as follows:
[0061] When the host machine determines that there is no target idle core matching the preempted host machine task in the current idle cores, recording the preemption information of the preempted host machine task includes:
[0062] When the host machine determines that there is no target idle core matching the preempted host machine task in the current idle cores, the host machine adds a preempted mark to the preempted host machine task and records association information between the preempted host machine task and the corresponding preempted mark.
[0063] Among them, the preempted mark can be set according to the actual application. For example, a mark 1 is added to the preempted host task, indicating that the CPU corresponding to the host task is preempted. On the contrary, if the host task is not preempted, a mark 0 can be added to it to indicate that the CPU corresponding to the host task is not preempted.
[0064] Specifically, when the vcpu scheduler determines that there is no target idle cpu matching the preempted vcpu thread in the current idle core of the host machine, it adds a preempted mark 1 to the preempted vcpu and records the association information between the preempted vcpu and the corresponding preempted mark 1, that is, it can be determined that the vcpu is preempted through the association information.
[0065] In an embodiment of the present specification, a preempted mark is added to the preempted host task, and the preempted host task and the preempted mark are subsequently shared with the virtual machine. This allows the virtual machine scheduler to avoid allocating tasks to the vCPU with the preempted mark when scheduling virtual machine tasks, thereby ensuring efficient operation of the virtual machine tasks in the virtual machine.
[0066] In specific implementation, after receiving the preemption information of the preempted vcpu thread through the shared memory, the virtual machine modifies the vcpu thread to a non-idle state based on the preemption information, that is, the vcpu is regarded as a non-idle core. When the scheduler in the subsequent virtual machine calculates the load weight, the scheduler will try to avoid migrating the virtual machine tasks to these preempted vcpus. The specific implementation method is as follows:
[0067] After the preemption information is transmitted to the virtual machine through the shared memory, the method further includes:
[0068] The virtual machine determines, based on the preemption information, that the virtual thread corresponding to the preemption information is in a non-idle state.
[0069] In actual applications, before the virtual machine receives the preemption information of the preempted vcpu thread, in the virtual machine, the state of the vcpu is non-idle, and the vcpu is an idle core of the virtual machine. The scheduler of the virtual machine will assign pending virtual machine tasks to the vcpu according to the number of current virtual machine tasks or pressure weight of the vcpu; after the virtual machine receives the preemption information of the preempted vcpu thread, the virtual machine will modify the state of the vcpu to non-idle, and the scheduler of the virtual machine will no longer assign virtual machine tasks to the vcpu.
[0070] When waking up a new virtual machine task, if the target cpu (target vcpu) corresponds to the vcpu thread on the host in the preempted state, the wake affine of the target cpu is always set to 1, which means that the target cpu is in a non-idle state. Then the wake cpu (the vcpu that performs the wake-up operation) is used as the first priority target for virtual machine task processing to avoid waking up the virtual machine task to the preempted virtual machine vcpu. The specific implementation method is as follows:
[0071] After the virtual machine determines the virtual thread corresponding to the preemption information as a non-idle state based on the preemption information, the method further includes:
[0072] When the virtual thread corresponding to the awakened virtual machine task is determined to be in a non-idle state, the virtual machine uses the awakened virtual thread of the virtual machine task as a target virtual thread.
[0073] There are many ways to wake up the virtual machine task, for example, the virtual machine task is woken up after the previous task is processed, or it is woken up after the set sleep cycle ends.
[0074] In the embodiments of the present specification, the example of waking up a new virtual machine task after the previous virtual machine task processing is completed can be used for explanation, that is, when a virtual machine task is awakened, and the virtual machine determines that the vcpu thread corresponding to the virtual machine task is in a non-idle state based on the preemption information, the vcpu that performs the wake-up operation is used as the target vcpu to execute the awakened virtual machine task; avoiding the delayed processing of the awakened virtual machine task after being assigned to a non-idle vcpu, thereby ensuring the processing efficiency of the virtual machine tasks in the virtual machine and reducing delays.
[0075] Then, when the host machine determines that there is a target CPU matching the preempted vcpu thread in the current idle core, the preempted vcpu thread can be migrated to the target CPU for execution, so that the preempted vcpu thread can be quickly scheduled and executed, thereby improving its operation efficiency. The specific implementation method is as follows:
[0076] After the host machine matches the preempted host machine task with the current idle core according to a preset matching rule, the method further includes:
[0077] When the host machine determines that there is a target idle core matching the preempted host machine task in the current idle cores, the host machine migrates the preempted host machine task to the target idle core for execution.
[0078] The target idle core may be understood as a current idle core of the preempted host machine that is determined to be suitable for running the preempted host machine task after matching the current idle core with the preempted host machine task according to the above preset matching rule.
[0079] In addition, the virtual machine will also pass the task parameters of the virtual machine tasks run by all its vcpu cores to the host through shared memory. Later, when there is an idle cpu in the host, the host scheduler can decide which vcpu thread to run on the idle cpu based on the task parameters of the vcpu thread to be run. The specific implementation method is as follows:
[0080] The load balancing method further includes:
[0081] The virtual machine determines task parameters for each virtual thread in all virtual threads to run a virtual machine task, and transmits the task parameters to the host machine through a shared memory;
[0082] The task parameter is the number of virtual machine tasks corresponding to each virtual thread, or the scheduling pressure weight of the virtual machine tasks corresponding to each virtual thread.
[0083] Specifically, each virtual thread can be understood as each vcpu in the virtual machine that runs a virtual machine task, and the task parameter of each vcpu can be understood as the task load of each vcpu; wherein the task parameter can be the number of virtual machine tasks to be run on each vcpu; or it can be a scheduling pressure weight calculated by a preset calculation method based on the number of virtual machine tasks to be run and the task level.
[0084] In actual applications, the task load of each vcpu can be determined based on the task parameters of each vcpu. After the task parameters of each vcpu in the virtual machine are transferred to the host machine through shared memory, the host machine's scheduler can select the vcpu with the heaviest load to run on the idle cpu based on the task parameters of each vcpu to reduce the pressure on its vcpu. The specific implementation method is as follows:
[0085] After the task parameters are transmitted to the host machine through the shared memory, the method further includes:
[0086] The host machine determines, when there are idle cores, at least one virtual thread to be scheduled and a task parameter for each virtual thread to be scheduled to run a virtual machine task; and
[0087] A corresponding virtual thread to be scheduled is allocated to the idle core based on the task parameters.
[0088] In specific implementation, when the host machine determines that there is an idle CPU, it obtains the vcpu threads to be scheduled and the task parameters of each vcpu thread to be scheduled determined through shared memory, and allocates the vcpu threads to be scheduled to the idle CPU according to the task parameters; for example, the vcpu thread to be scheduled with the heaviest task load is allocated to the idle CPU.
[0089] In addition, during the specific implementation, there may be multiple host tasks that are preempted at the same time in the host machine. In order to avoid multiple preempted host tasks from selecting the same target idle CPU, when determining the target idle CPU, the idle CPU start and end nodes can be divided for each preempted host task, and the next CPU corresponding to the preempted host task is used as the start node, and the previous CPU is used as the end node; for example, if the system has 8 CPUs, and the CPU corresponding to the preempted host task is cpu3, cpu4 is used as the start node for finding idle CPUs, and cpu2 is used as the end node for finding idle CPUs. Then the order of finding target idle CPUs is cpu4->cpu5->cpu6->cpu7->cpu8->cpu1->cpu2. Of course, in actual applications, the method of avoiding target idle CPU conflicts is not limited to the above method, and other methods can also be used to avoid conflicts, such as grouping.
[0090] The load scheduling method provided in the embodiments of this specification provides a top-down collaborative scheduling optimization method. When the host machine determines that the CPU (host central processing unit) corresponding to a host task (vcpu thread) is preempted and there is no idle core to process it, the preemption information of the vcpu thread is transmitted to the virtual machine through shared memory. The subsequent virtual machine can avoid continuing to migrate the virtual machine task to the vcpu thread based on the preemption information, thereby significantly reducing the scheduling delay of the entire guset and improving the operating efficiency of the virtual machine tasks running in the guset.
[0091] The following combination Figure 2 , taking the application of the load scheduling method provided in this specification in a host environment as an example, the load scheduling method is further described. Figure 2 A schematic diagram of a processing process of a load scheduling method provided by an embodiment of this specification is shown.
[0092] Figure 2 It includes two parts: host os (host operating system) and guestos (virtual machine operating system) running in the kvm module of host os.
[0093] Among them, the host OS includes four physical cores, namely, the CFS scheduler, the vcpu scheduler superimposed on the CFS scheduler, and cpu0-3, which run the vcpu threads of the virtual machine; the tasks on the CFS scheduler and the vcpu scheduler can be understood as ordinary tasks running on the physical cores, while vcpu1, vcpu3, and vcpu4 can be understood as vcpu threads of the virtual machine running on the physical cores.
[0094] The guest os also includes a scheduler and the scheduling information of the vcpu threads running in the host machine passed through the shared memory; the guest os task can be understood as the virtual machine task to be run in the virtual machine; and the cpu1-4 on the task can be understood as the virtual core cpu of the virtual machine, and each virtual cpu is reflected in the host os as a vcpu thread, that is, the cpu1 of the guest os corresponds to the vcpu1 in the host os, the cpu2 of the guest os corresponds to the vcpu2 in the host os, the cpu3 of the guest os corresponds to the vcpu3 in the host os, and the cpu4 of the guest os corresponds to the vcpu4 in the host os.
[0095] In the specific implementation, taking the preemption of the physical core cpu0 running the vcpu1 thread in the host os as an example, the cfs scheduler of the host os determines that the vcpu1 thread is a virtual thread of the guest os, and triggers the vcpu scheduler. The vcpu scheduler obtains the current idle physical cores in the host os, and then selects a target physical core from the currently obtained idle physical cores according to the preset matching rules, and migrates the vcpu1 thread to the target physical core for operation.
[0096] Taking the preemption of the physical core cpu2 running the vcpu3 thread in the host os as an example, the cfs scheduler of the host os determines that the vcpu3 thread is a virtual thread of the guest os, and triggers the vcpu scheduler. The vcpu scheduler obtains the current idle physical cores in the hostos, and when it is determined according to the preset matching rule that there is no idle physical core suitable for the vcpu3 thread in the currently obtained idle physical cores, the vcpu3 is marked as preempted, and the marking information is passed to the guest os through the shared memory; when the scheduler in the guest os performs virtual machine task scheduling, when it determines that the cpu3 corresponding to the vcpu3 thread is preempted, it will schedule as few virtual machine tasks as possible to the cpu3 of the virtual machine.
[0097] In addition, if the physical core cpu3 in the host os is idle, and there are vcpu1, vcpu2, vcpu3 and vcpu4 threads in the pending list, the guest os calculates the task scheduling pressure weights of cpu1, cpu2, cpu3 and cpu4 in the virtual machine corresponding to the vcpu1, vcpu2, vcpu3 and vcpu4 threads, and passes the calculated task scheduling pressure weights of cpu1, cpu2, cpu3 and cpu4 in the guest os to the guest os through shared memory; the vcpu scheduler in the guest os will assign the vcpu4 thread corresponding to the virtual core cpu4 in the guest os with the largest task scheduling pressure weight to the physical core cpu3 for processing.
[0098] The load scheduling method provided in the embodiments of this specification provides a top-down collaborative scheduling optimization method. When the host machine determines that the CPU (host central processing unit) corresponding to a host task (vcpu thread) is preempted and there is no idle core to process it, the preemption information of the vcpu thread is transmitted to the virtual machine through shared memory. The subsequent virtual machine can avoid continuing to migrate the virtual machine task to the vcpu thread based on the preemption information, thereby significantly reducing the scheduling delay of the entire guset and improving the operating efficiency of the virtual machine tasks running in the guset.
[0099] Corresponding to the above method embodiment, this specification also provides a load scheduling system embodiment. Figure 3 FIG. 1 shows a schematic diagram of a load scheduling system provided by an embodiment of the present specification. Figure 3 As shown, the system includes a host machine 302 and a virtual machine 304 running on the host machine, wherein:
[0100] The host machine 302 is configured to determine a current idle core when it is determined that the preempted host machine task is a virtual thread of the virtual machine 304, wherein the virtual thread is a virtual machine central processing unit thread and the idle core is an idle host machine central processing unit;
[0101] The host machine 302 is configured to match the preempted host machine task with the current idle core according to a preset matching rule, and when it is determined that there is no target idle core in the current idle core that matches the preempted host machine task, record the preemption information of the preempted host machine task and pass the preemption information to the virtual machine 304.
[0102] Optionally, the host machine 302 includes a completely fair scheduler and a virtual thread scheduler;
[0103] Accordingly, when the completely fair scheduler determines that the preempted host task is a virtual thread of the virtual machine, the completely fair scheduler sends the preempted host task to the virtual thread scheduler for processing;
[0104] The virtual thread scheduler receives the preempted host machine task and determines a current idle core.
[0105] Optionally, the virtual thread scheduler matches the preempted host task with the current idle core according to a preset matching rule. When it is determined that there is no target idle core in the current idle core that matches the preempted host task, the virtual thread scheduler records the preemption information of the preempted host task and passes the preemption information to the virtual machine through shared memory.
[0106] Optionally, when the host machine 302 determines that there is a target idle core matching the preempted host machine task in the current idle cores, the host machine 302 migrates the preempted host machine task to the target idle core for execution.
[0107] Optionally, the virtual machine 304 determines the virtual thread corresponding to the preemption information as a non-idle state based on the preemption information.
[0108] Optionally, when determining that the virtual thread corresponding to the awakened virtual machine task is in a non-idle state, the virtual machine 304 uses the virtual thread of the awakened virtual machine task as the target virtual thread.
[0109] Optionally, the host machine 302 determines whether the preempted host machine task meets the preset running condition of the current idle core, and / or
[0110] Whether the average idle time of the current idle core is greater than the migration time of the preempted host task;
[0111] The preset running condition includes that the preempted host machine task is in the executable task list corresponding to the current idle core, and / or the preempted host machine task is not evicted by the current idle core.
[0112] Optionally, the virtual machine 304 determines task parameters for each virtual thread in all virtual threads to run a virtual machine task, and transmits the task parameters to the host machine through a shared memory;
[0113] The task parameter is the number of virtual machine tasks corresponding to each virtual thread, or the scheduling pressure weight of the virtual machine tasks corresponding to each virtual thread.
[0114] Optionally, the host machine 302 determines, when there are idle cores, at least one virtual thread to be scheduled and a task parameter of each virtual thread to be scheduled to run a virtual machine task; and
[0115] A corresponding virtual thread to be scheduled is allocated to the idle core based on the task parameters.
[0116] Optionally, when the host machine 302 determines that there is no target idle core matching the preempted host machine task in the current idle cores, it adds a preempted mark to the preempted host machine task and records the association information between the preempted host machine task and the corresponding preempted mark.
[0117] The load scheduling system provided in the embodiments of this specification provides a top-down collaborative scheduling optimization method. When the host machine determines that the CPU (host central processing unit) corresponding to a host task (vcpu thread) is preempted and there is no idle core to process it, the preemption information of the vcpu thread is transmitted to the virtual machine through shared memory. Subsequent virtual machines can avoid continuing to migrate virtual machine tasks to the vcpu thread based on the preemption information, thereby significantly reducing the scheduling delay of the entire guset and improving the operating efficiency of virtual machine tasks running in the guset.
[0118] The above is a schematic scheme of a load dispatching system of this embodiment. It should be noted that the technical scheme of the load dispatching system and the technical scheme of the load dispatching method described above are of the same concept, and the details not described in detail in the technical scheme of the load dispatching system can be found in the description of the technical scheme of the load dispatching method described above.
[0119] Figure 4 The block diagram of a computing device 400 according to one embodiment of the present specification is shown. The components of the computing device 400 include but are not limited to a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and the database 450 is used to store data.
[0120] The computing device 400 also includes an access device 440 that enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 440 may include one or more of any type of network interface (e.g., a network interface card (NIC)) wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0121] In one embodiment of the present specification, the above components of the computing device 400 and Figure 4 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 4 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0122] Computing device 400 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. Computing device 400 may also be a mobile or stationary server.
[0123] The processor 420 is used to execute the following computer executable instructions, which implement the steps of the above-mentioned load scheduling method when executed by the processor.
[0124] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above load scheduling method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above load scheduling method.
[0125] An embodiment of the present specification also provides a computer-readable storage medium storing computer-executable instructions, which implement the steps of the above-mentioned load scheduling method when executed by a processor.
[0126] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the load scheduling method described above are of the same concept, and the details not described in detail in the technical scheme of the storage medium can be found in the description of the technical scheme of the load scheduling method described above.
[0127] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned load scheduling method.
[0128] The above is a schematic scheme of a computer program of this embodiment. It should be noted that the technical scheme of the computer program and the technical scheme of the above load scheduling method belong to the same concept, and the details not described in detail in the technical scheme of the computer program can be referred to the description of the technical scheme of the above load scheduling method.
[0129] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0130] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0131] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0132] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0133] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A load scheduling method, applied to a load scheduling system, the system comprising a host machine and a virtual machine running on the host machine, wherein: The method comprises: The host machine determines a current idle core when determining that the preempted host machine task is a virtual thread of the virtual machine, wherein the virtual thread is a central processing unit thread of the virtual machine and the idle core is an idle host machine central processing unit; The host machine matches the preempted host machine task with the current idle core according to a preset matching rule, and when it is determined that there is no target idle core in the current idle core that matches the preempted host machine task, records the preemption information of the preempted host machine task and transmits the preemption information to the virtual machine.
2. According to the load scheduling method of claim 1, the host machine includes a completely fair scheduler and a virtual thread scheduler; Accordingly, when the host machine determines that the preempted host machine task is a virtual thread of the virtual machine, the host machine determines the current idle core, including: When the completely fair scheduler determines that the preempted host task is a virtual thread of the virtual machine, the completely fair scheduler sends the preempted host task to the virtual thread scheduler for processing; The virtual thread scheduler receives the preempted host machine task and determines a current idle core.
3. The load scheduling method according to claim 2, wherein the host machine matches the preempted host machine task with the current idle core according to a preset matching rule, and when it is determined that there is no target idle core matching the preempted host machine task in the current idle core, records the preemption information of the preempted host machine task, and transmits the preemption information to the virtual machine, comprising: The virtual thread scheduler matches the preempted host task with the current idle core according to a preset matching rule. When it is determined that there is no target idle core in the current idle core that matches the preempted host task, the virtual thread scheduler records the preemption information of the preempted host task and transmits the preemption information to the virtual machine through shared memory.
4. The load scheduling method according to claim 1, after the host machine matches the preempted host machine task with the current idle core according to a preset matching rule, further comprising: When the host machine determines that there is a target idle core matching the preempted host machine task in the current idle cores, the host machine migrates the preempted host machine task to the target idle core for execution.
5. The load scheduling method according to claim 1, after transmitting the preemption information to the virtual machine through the shared memory, further comprising: The virtual machine determines, based on the preemption information, that the virtual thread corresponding to the preemption information is in a non-idle state.
6. The load scheduling method according to claim 5, after the virtual machine determines the virtual thread corresponding to the preemption information as a non-idle state based on the preemption information, further comprising: When the virtual thread corresponding to the awakened virtual machine task is determined to be in a non-idle state, the virtual machine uses the awakened virtual thread of the virtual machine task as a target virtual thread.
7. The load scheduling method according to claim 1, wherein the host machine matches the preempted host machine task with the current idle core according to a preset matching rule, comprising: The host machine determines whether the preempted host machine task meets the preset running condition of the current idle core, and / or Whether the average idle time of the current idle core is greater than the migration time of the preempted host task; The preset running condition includes that the preempted host machine task is in the executable task list corresponding to the current idle core, and / or the preempted host machine task is not evicted by the current idle core.
8. The load scheduling method according to claim 1, further comprising: The virtual machine determines task parameters for each virtual thread in all virtual threads to run a virtual machine task, and transmits the task parameters to the host machine through a shared memory; The task parameter is the number of virtual machine tasks corresponding to each virtual thread, or the scheduling pressure weight of the virtual machine tasks corresponding to each virtual thread.
9. The load scheduling method according to claim 8, after transferring the task parameters to the host machine through the shared memory, further comprising: The host machine determines, when there are idle cores, at least one virtual thread to be scheduled and task parameters for each virtual thread to be scheduled to run a virtual machine task; as well as A corresponding virtual thread to be scheduled is allocated to the idle core based on the task parameters.
10. The load scheduling method according to claim 1, wherein the host machine records the preemption information of the preempted host machine task when determining that there is no target idle core matching the preempted host machine task in the current idle cores, comprising: When the host machine determines that there is no target idle core matching the preempted host machine task in the current idle cores, the host machine adds a preempted mark to the preempted host machine task and records association information between the preempted host machine task and the corresponding preempted mark.
11. A load scheduling system, comprising a host machine and a virtual machine running on the host machine, wherein: The host machine is configured to determine a current idle core when it is determined that the preempted host machine task is a virtual thread of the virtual machine, wherein the virtual thread is a central processing unit thread of the virtual machine and the idle core is an idle host machine central processing unit; The host machine is configured to match the preempted host machine task with the current idle core according to a preset matching rule, and when it is determined that there is no target idle core in the current idle core that matches the preempted host machine task, record the preemption information of the preempted host machine task and pass the preemption information to the virtual machine.
12. A computing device comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the load scheduling method described in any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the steps of the load scheduling method according to any one of claims 1 to 10.
