Method, system and medium for limiting speed based on dirty page quota in virtual machine live migration
By setting dirty page quotas and dynamically adjusting rate limiting ratios during virtual machine hot migration, the performance loss and system overhead caused by load fluctuations during virtual machine hot migration are resolved, thereby improving migration success rate and performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GALAXY UNICORN SOFTWARE (CHANGSHA) CO LTD
- Filing Date
- 2022-10-19
- Publication Date
- 2026-07-31
AI Technical Summary
Existing virtual machine hot migration technology can lead to unnecessary virtual machine performance loss and system performance overhead caused by rate limiting operations under fluctuating business load conditions.
By setting dirty page quotas during virtual machine hot migration, the number of dirty pages generated by the virtual machine in each control cycle is controlled, the rate limiting ratio is dynamically adjusted to adapt to changes in memory write load, the amount of newly rewritten memory page data is reduced, and vCPU hibernation is used to implement rate limiting, avoiding system overhead caused by signal notification.
It improves the success rate of virtual machine hot migration and reduces virtual machine performance loss and system performance overhead caused by load fluctuations.
Smart Images

Figure CN115629839B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to virtual machine hot migration technology in a cloud computing environment, specifically to a rate limiting method, system, and medium based on dirty page quotas in virtual machine hot migration. Background Technology
[0002] A virtual machine (VM) is a new, isolated unit of resources distinct from processes in a virtualization environment, scheduled by the operating system. VM live-migration refers to the process of migrating a VM from a source physical host to a target physical host over a network without interrupting its operational lifecycle in a cloud computing or virtualization environment. VM live-migration technology in cloud computing environments is a crucial technique for server consolidation and is widely used in cloud data centers. A major challenge for live-migration technology in production is the success rate under high load conditions. Specifically, when the VM load is high, particularly in terms of memory write load, the amount of dirty pages generated by the VM per unit time exceeds the available bandwidth for migration, causing the migration process to fail within a limited time. To improve the success rate under high load conditions, the industry typically uses VM rate limiting (slowing down) methods. This involves reducing the VM's memory write activity per unit time, i.e., the dirty page generation rate, to support migration completion under high load conditions. VM migration cannot guarantee 100% deterministic success; the migration result is primarily affected by the workload of the services running on it. When the workload is low, the migration success rate is high; conversely, when the workload is high, the migration success rate is low. Although the hot migration rate limiting method can maximize the migration success rate, it inevitably causes a performance penalty to the virtual machine's business system during implementation. In practical applications, a key principle of implementing virtual machine rate limiting methods is to minimize the impact on virtual machine performance while ensuring a high migration success rate.
[0003] A major problem with existing virtual machine hot migration methods using rate limiting is their inability to adapt to fluctuations in workload during the migration process. This means that after reaching convergence equilibrium, when the virtual machine load fluctuates in the opposite direction (specifically, a decrease in load pressure), the current rate limiting method cannot detect this change and therefore cannot adjust the rate reduction ratio accordingly. This results in unnecessary performance loss for the later stages of the migration process, from the current convergence equilibrium to the end of the migration. The virtual machine load referred to here is the load affected by the hot migration process, specifically memory write load. For clarity, consider the following example: If the existing rate limiting migration method automatically converges to an 80% rate reduction ratio in a migration, denoted as time t1, and a decrease in workload occurs at this point, the actual rate reduction ratio required to reach convergence is less than 80%, assumed to be 30%. The migration completion time is t2. The subsequent migration time is t2-t1. During this time, the existing mechanism consistently completes the migration at an 80% rate reduction ratio, but the actual workload only requires a 30% rate reduction ratio. Therefore, during the period t2-t1, the virtual machine service system suffered a 50% performance loss due to excessive rate limiting. It's clear that the greater the jump in load pressure before and after convergence, and the longer the migration time from convergence equilibrium to the end of the migration process, the greater the impact of the migration operation on the virtual machine service performance. In actual production, load fluctuations are frequent, unpredictable, and random events, which inevitably have a certain impact on the performance of the service system.
[0004] Another major problem with rate limiting methods used in existing virtual machine hot migration technologies is the performance overhead introduced by the VCPU exiting the virtual machine runtime state during each rate limiting operation due to signal dependencies. Specifically, in existing methods, a separate rate limiting thread is maintained at the user space layer above virtualization, and this thread maintains a fixed rate limiting operation cycle. To trigger a rate limiting operation on the VCPU, this rate limiting thread needs to send a signal to the VCPU thread. The VCPU responds to the signal, triggering a virtual machine exit event (VMEXIT), and only then does the VCPU complete the actual rate limiting operation (with a pause for a period of time). The process can be simplified as: rate limiting cycle thread -> sending a signal to the VCPU thread -> VCPU responds to the signal, VMEXIT -> VCPU rate limiting operation. Clearly, this path is lengthy, and the signal notification required for each rate limiting operation and the VMEXIT event triggered by the signal are both overheads at the virtualization system layer, which are unavoidable under the existing technology framework. Summary of the Invention
[0005] The technical problem to be solved by this invention is as follows: Addressing the aforementioned problems in the prior art, this invention provides a method, system, and medium for rate limiting based on dirty page quotas during virtual machine hot migration. This invention aims to solve the problems of unnecessary virtual machine service performance loss during virtual machine rate-limited hot migration under fluctuating business load conditions, and the system performance overhead that can be avoided by the rate-limiting operation itself. This invention can avoid virtual machine performance loss caused by possible load fluctuations in scenarios where load fluctuations occur during hot migration, reducing system performance overhead. By applying runtime rate limiting (speed reduction) to running virtual machines during the virtual machine hot migration process, the amount of newly rewritten memory pages generated per unit time is reduced, thereby improving the migration success rate of virtual machine hot migration.
[0006] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0007] A rate-limiting method based on dirty page quotas during virtual machine hot migration includes:
[0008] S101, determine the control period T;
[0009] S102, during the hot migration of the virtual machine, the virtual machine is speed-limited to control the number of dirty pages actually generated by the virtual machine in each control cycle T to be less than the preset dirty page quota pgs_limit. This makes the performance loss or actual speed reduction ratio of the virtual machine during the hot migration process change with the size of the memory write load in units of control cycle T.
[0010] Optionally, in step S102, the speed limit for the virtual machine is achieved by putting the virtual machine's vCPU to sleep.
[0011] Optionally, step S102 further includes allocating reserved quotas and window quotas pgs_quota for each vCPU at the end of each control cycle T by the dirty page quota allocation thread corresponding to each virtual machine and operating in user mode, wherein the reserved quota refers to the dirty page quota reserved for all vCPUs; the step of implementing rate limiting by putting the vCPUs of the virtual machine to sleep includes:
[0012] S201, When the virtual machine's vCPU is in the running state, and a memory write operation performed during the virtual machine's hot migration causes the virtual machine's vCPU to exit from the virtual machine's running state to the kernel state, the process jumps to step S202.
[0013] S202: First, the vCPU of the virtual machine switched to kernel mode performs dirty page marking to obtain the number of marked dirty pages, pgs_counted. Then, it is determined whether the number of dirty pages, pgs_counted, exceeds the window quota, pgs_quota, of the current control cycle T. If it does not exceed the window quota, pgs_quota, the virtual machine returns to the running state and jumps to step S201. Otherwise, it is determined that a dirty page quota has been consumed and a dirty page quota exceeding event is generated. This dirty page quota exceeding event triggers an exit operation to the upper layer of virtualization, returning to the upper layer user mode of virtualization and jumping to step S203.
[0014] S203, the event response handling function pre-set in the upper layer of user-mode virtualization performs the response processing: determine whether a reserved quota can be obtained; if a reserved quota cannot be obtained, control the virtual machine's vCPU to hibernate, and then jump to step S201; if a reserved quota can be obtained, determine that hibernation is not required, consume one reserved quota and jump to step S201.
[0015] Optionally, controlling the virtual machine's vCPU to hibernate in step S203 means controlling the virtual machine's vCPU to immediately hibernate from the current moment until the end of this control cycle T.
[0016] Optionally, when allocating reserved quotas to virtual machines and window quotas pgs_quota for each vCPU in the next control cycle T at the end of each control cycle T, allocating reserved quotas to virtual machines includes: calculating the difference between the window quota pgs_quota of the current control cycle T and the total number of dirty page quotas consumed by each vCPU in the current control cycle T; if the difference between the window quota pgs_quota of the current control cycle T and the total number of dirty page quotas consumed by each vCPU in the current control cycle T is greater than or equal to 1, then the difference between the window quota pgs_quota of the current control cycle T and the total number of dirty page quotas consumed by each vCPU in the current control cycle T is added to the reserved quota.
[0017] Optionally, when allocating reserved quotas to virtual machines and window quotas pgs_quota for each vCPU in the next control cycle T at the end of each control cycle T, the function expression for the window quota pgs_quota allocated to each vCPU in the next control cycle T is:
[0018] pgs_quota = pgs_limit / N
[0019] In the above formula, pgs_limit is the preset dirty page quota within the control period T, and N is the number of virtual machine vcpus.
[0020] Optionally, step S202, which involves marking dirty pages to obtain the number of marked dirty pages pgs_counted, includes: using a dirty page counter located in the lower layer of virtualization that monotonically increases to count the dirty pages of the virtual machine to obtain the number of marked dirty pages pgs_counted.
[0021] Optionally, before step S102, a step of determining the preset dirty page quota pgs_limit is also included:
[0022] S301, Determine the upper limit V for the dirty page rate. page ;
[0023] S302, determining the upper limit value V of the dirty page rate. page Based on this, the preset dirty page quota pgs_limit is calculated according to the following formula:
[0024] pgs_limit = V page *1000 / T
[0025] In the above formula, V page is the upper limit of the dirty page rate; T is the control period, in milliseconds.
[0026] Furthermore, the present invention also provides a rate limiting system based on dirty page quotas during virtual machine hot migration, comprising a microprocessor and a memory interconnected thereto, the microprocessor being programmed or configured to perform the steps of the rate limiting method based on dirty page quotas during virtual machine hot migration.
[0027] Furthermore, the present invention also provides a computer-readable storage medium storing a computer program for being programmed or configured by a microprocessor to perform steps of the rate-limiting method based on dirty page quotas during virtual machine hot migration.
[0028] Compared with existing technologies, the present invention has the following advantages: The rate limiting method based on dirty page quota in virtual machine hot migration of the present invention includes: determining the control period T; during the hot migration of the virtual machine, by rate limiting the virtual machine to control the number of dirty pages actually generated by the virtual machine in each control period T to be less than the preset dirty page quota pgs_limit, so that the performance loss or actual speed reduction ratio of the virtual machine during the hot migration process changes with the size of the memory write load in units of control period T. The present invention can solve the problems of unnecessary virtual machine service performance loss under the condition of business load fluctuation during virtual machine rate limiting hot migration in the prior art and the system performance overhead that can be avoided by the rate limiting operation itself. It can avoid virtual machine performance loss caused by possible load fluctuation in the scenario of load fluctuation during hot migration speed reduction, reduce system performance overhead, and improve the migration success rate of virtual machine hot migration by adopting running rate limiting (speed reduction) on the running virtual machine during the virtual machine hot migration process, reducing the amount of newly rewritten memory page data generated per unit time. Attached Figure Description
[0029] Figure 1 This is a schematic diagram of the basic process of the method in an embodiment of the present invention.
[0030] Figure 2 This is a schematic diagram illustrating the principle of how dirty page quotas affect virtual machine performance in an embodiment of the present invention.
[0031] Figure 3 This is a schematic diagram illustrating the performance loss of virtual machines when the service load changes during hot migration rate limiting in an embodiment of the present invention.
[0032] Figure 4 This is a flowchart illustrating the vCPU operation pause control based on dirty page quota in an embodiment of the present invention.
[0033] Figure 5 This is a flowchart illustrating the allocation of dirty page quotas during hot migration rate limiting in an embodiment of the present invention. Detailed Implementation
[0034] like Figure 1 As shown, the rate limiting method based on dirty page quotas during virtual machine hot migration in this embodiment includes:
[0035] S101, determine the control period T;
[0036] S102, during the hot migration of the virtual machine, the virtual machine is speed-limited to control the number of dirty pages actually generated by the virtual machine in each control cycle T to be less than the preset dirty page quota pgs_limit. This makes the performance loss or actual speed reduction ratio of the virtual machine during the hot migration process change with the size of the memory write load in units of control cycle T.
[0037] The control period T can be set as needed and is not less than 10 ms in practice. The control period T can be understood as an independent new timer, independent of the original timer of the system. The virtual machine memory write load is a key influencing factor in virtual machine live migration. Controlling the number of dirty pages actually generated by the virtual machine within each control period T to be less than the preset dirty page quota pgs_limit is equivalent to controlling the memory dirty page rate. The memory dirty page rate is actually a quantitative indicator of the virtual machine memory write load, reflecting the magnitude of the virtual machine memory write load pressure. When the memory dirty page rate is large, it indicates that the virtual machine memory write load pressure is large, and vice versa. For the quantitative control of the memory dirty page rate, the virtual machine memory write load pressure can be directly controlled, achieving the effect of speed limit. Figure 2 Figure 2 is a schematic diagram of the principle of the effect of the dirty page quota on the virtual machine performance loss. It shows a schematic of the principle of the dirty page rate limiting method. The virtual machine load shown is the memory write load, and the dirty page rate is a quantitative representation of the magnitude of the memory write load pressure. The method of this application is to set an upper limit for the dirty page rate allowed for the virtual machine, shown as L_limit in the figure. In the figure, there are three different virtual machine loads, from high to low are L1, L2, and L3. When the virtual machine load is L1, because the load pressure at this time exceeds L_limit. The method mechanism controls the actual load generated by the virtual machine and suppresses it to L_limit. Then, compared with the original performance, the degree of virtual machine performance loss at this time can be represented by L1 - L_limit, which is the shaded part in Load 1. When the virtual machine load is L2, because the load pressure still exceeds L_limit at this time. The virtual machine performance degree is L2 - L_limit. Compared with the performance loss of Load 1, L2 - L_limit < L1 - L_limit, and the performance loss amplitude decreases. When the virtual machine load is L3, the load pressure is already lower than the set limit at this time, and the virtual machine operation is not affected by the limit, and the performance loss is zero at this time. Therefore, the method of this embodiment can ensure that when the virtual machine load is adjusted from large to small, the degree of performance loss or the actual speed reduction ratio also decreases. The fundamental reason for this method to achieve the above effect is that this method is actually speed limiting based on the actual load, so it can achieve load perception. While the prior art methods cannot achieve load perception and are completed based on a set fixed speed reduction ratio, and cannot adjust with the actual speed reduction ratio of the load. Figure 3This diagram illustrates the performance loss of virtual machines during hot migration rate limiting when service load changes, showing the specific process of performance loss caused by load fluctuations during the rate-limited migration process. The vertical axis represents the migration time axis, with T0 being the start of the migration and T4 being the end. The horizontal axis represents the proportion of virtual machine performance loss relative to the original performance loss. The time from T0 to T1 is the automatic convergence process of the migration. Due to the high load pressure, the automatic convergence process continuously reduces the rate reduction ratio until it reaches the convergence equilibrium point at 80%, at which point the performance loss is 80%. After reaching the convergence equilibrium, the load pressure remains stable for a period of time from T1 to T2. At time point T2, the service load pressure begins to change and decrease. From T2 to T3, the service load pressure continues to decrease and then remains stable. The original rate limiting mechanism, unable to adaptively adjust to the load changes starting from T2, always maintains the rate reduction ratio at the convergence equilibrium point of 80% until the migration is completed at time T4. This mechanism, based on the dirty page quota principle, can adapt to load changes. Depending on the load pressure, it automatically adjusts the throttling ratio to a new, relatively low level of 40%, thus avoiding this performance loss. The shaded area from time point T2 to T4 represents the performance loss area caused by the original mechanism.
[0038] Existing techniques are based on VCPU (virtual CPU) runtime ratio control, a key feature of which is a deterministic rate-limiting ratio. The rate-limiting ratio refers to the degree of rate limiting relative to the original performance requirements in order to achieve migration convergence (auto-converge, a process where the rate-limited migration gradually increases the rate-limiting ratio to bring the migration process closer to an equilibrium point where migration can be completed), corresponding to the performance loss relative to the original. For example, a rate-limiting ratio of 10% results in a 10% performance loss relative to the original, leaving 90% of the performance; a rate-limiting ratio of 80% results in an 80% performance loss relative to the original, leaving 20% of the performance. Specifically, a fixed rate-limiting operation cycle is maintained. In each rate-limiting operation cycle, when the rate-limiting ratio is greater than zero, the rate-limiting operation is deterministically executed to achieve the rate-limiting effect; for example, when the rate-limiting ratio is 10%, a 10% time-based VCPU execution pause will definitely be implemented; when the rate-limiting ratio is 20%, an additional 20% time-based VCPU execution pause will definitely be implemented. To clarify the significance of this method, we will further explain the distinguishing features between this method and existing methods: In existing methods, the direct cause of speed reduction is runtime pause, and the result of speed limiting is a reduction in memory write load. This can be simplified as: Virtual machine runtime pause -> Actual runnable time reduced -> Memory write load reduced. It is important to emphasize that the reduction in memory write load is a result of runtime pause. This method, in its overall approach, is almost "inverted" compared to the original method. Controlling the reduction in write load is the direct cause of speed limiting, not the result. This can be simplified as: Controlling the rate of dirty page generation (i.e., controlling memory write load) -> Memory write load reduced. The cause is the result. Virtual machine runtime pause is a necessary technical means in this method's approach, not the direct cause of speed limiting. In this embodiment, the direct cause of speed limiting is the direct control of the virtual machine's dirty page rate, i.e., the dirty page quota. The dirty page quota is actually an upper limit set for the virtual machine load; when the virtual machine load changes, the actual speed reduction ratio changes dynamically. For example, setting the dirty page quota value to 1200 means that 1200 dirty pages are allowed to be generated per second. If the virtual machine workload is 6000 at a certain moment, the actual rate reduction ratio is 1200 / 6000 × 100% = 80%; if the virtual machine workload is 3000 at a certain moment, the actual rate reduction ratio is 1200 / 3000 × 100% = 40%; if the virtual machine workload is only 1000 at a certain moment, the virtual machine will not actually be rate-limited, that is, the rate reduction ratio is 0. This process can be understood as "when it is decided to rate limit, it is just setting an upper limit. As long as it does not exceed the upper limit, it will not be penalized (rate-limited); conversely, if it exceeds the upper limit, it will be penalized; at the same time, the more it exceeds the upper limit, the heavier the penalty; the less it exceeds the upper limit, the lighter the penalty." From a technical principle perspective, one effect of this method is that after reaching the convergence equilibrium point, if the business load fluctuates in the opposite direction, that is, the business load becomes lighter, the actual rate reduction ratio can be adaptively reduced.In the original technical method, because it is impossible to detect changes in business load and the throttling ratio is constant, after reaching the convergence equilibrium, the maximum throttling ratio is maintained from the convergence equilibrium point to the end of the migration, which causes a loss of virtual machine performance during this period.
[0039] To achieve the goal of limiting the rate of a virtual machine, the virtual machine's vCPU can be blocked, put to sleep, or cyclically operated as needed. The goal is to prevent the virtual machine from generating more dirty pages, ensuring that the actual number of dirty pages generated by the virtual machine within each control cycle T is less than the preset dirty page quota pgs_limit. As an optional implementation, in step S102 of this embodiment, the rate limiting of the virtual machine is specifically achieved by putting the virtual machine's vCPU to sleep. Regarding the current dirty page limit, there are two possible methods in practice: First, a method based on theoretical calculations, using a convergence condition where the amount of dirty page data generated per unit time is less than the amount of data the bandwidth can provide, to calculate the number of dirty pages. However, this method has limitations in practical application due to unmeasurable factors. Secondly, a convergence approximation method similar to existing mechanisms is adopted. This involves acquiring an initial performance value before the migration begins, and then performing a convergence determination during the migration copy iteration cycle or decision cycle (during the convergence process, it is necessary to determine whether the conditions for migration completion can be met; this determination process is called convergence determination. There are two possible outcomes: non-convergence, meaning the migration cannot be completed within a finite time; or reaching the convergence equilibrium point, meaning the migration can be completed through multiple iterations within a subsequent finite time). Based on the determination result, the quota value is proportionally reduced. For example, if the determination result is non-convergence, the quota value is further reduced until convergence is achieved.
[0040] Figure 4 The flowchart below illustrates the vCPU operation pause control based on dirty page quota in this embodiment. It shows the vCPU operation pause method used in the migration rate limiting in this application. This method involves two threads: the vCPU thread and the dirty page allocation thread. However, the main operation is only completed by the vCPU thread, while the dirty page allocation thread only completes the setting operation for the vCPU quota.
[0041] See Figure 4 In step S102 of this embodiment, the dirty page quota allocation thread corresponding to each virtual machine and working in user mode allocates reserved quotas and window quota pgs_quota for each vCPU in the next control cycle T at the end of each control cycle T. The reserved quota refers to the dirty page quota reserved for all vCPUs. The dirty page quota allocation thread is located in the virtualization upper layer, and the period of the dirty page quota allocation thread is called the dirty page quota allocation cycle.
[0042] See Figure 4 In this embodiment, speed limiting is achieved by putting the virtual machine's vCPU to sleep, including:
[0043] S201, When the virtual machine's vCPU is in the running state, and a memory write operation performed during the virtual machine's hot migration causes the virtual machine's vCPU to exit from the virtual machine's running state to the kernel state, the process jumps to step S202.
[0044] S202: First, the vCPU of the virtual machine switched to kernel mode performs dirty page marking to obtain the number of marked dirty pages, pgs_counted. Then, it is determined whether the number of dirty pages, pgs_counted, exceeds the window quota, pgs_quota, of the current control cycle T. If it does not exceed the window quota, pgs_quota, the virtual machine returns to the running state and jumps to step S201. Otherwise, it is determined that a dirty page quota has been consumed and a dirty page quota exceeding event is generated. This dirty page quota exceeding event triggers an exit operation to the upper layer of virtualization, returning to the upper layer user mode of virtualization and jumping to step S203.
[0045] S203, the event response handling function pre-set in the upper layer of user-mode virtualization performs the response processing: determine whether a reserved quota can be obtained; if a reserved quota cannot be obtained, control the virtual machine's vCPU to hibernate, and then jump to step S201; if a reserved quota can be obtained, determine that hibernation is not required, consume one reserved quota and jump to step S201.
[0046] A key feature that distinguishes this process from existing technologies is that the vCPU operation pause during the rate limiting process is completed independently by the vCPU thread, without any communication or interaction with other threads, specifically the dirty page quota allocation thread, or signals. Figure 4 The dirty page quota allocation thread shown only sets the dirty page quota value and does not need to involve the interaction and communication between the rate limiting cycle thread and the vCPU thread through the signal mechanism, thus avoiding the system-level overhead of the signal mechanism itself.
[0047] It should be noted that when the vCPU performs dirty page marking in step S202, the vCPU has already completed the exit from the running state (vmexit) to the kernel state. This application's method utilizes this opportunity to continue the possible pause operation for the vCPU to return to user state. That is, this application's method only needs to utilize the system's existing vmexit timing for the vCPU's pause operation; this process will not cause vmexit outside the existing mechanism, while existing methods require signals to trigger vmexit outside the existing mechanism. Therefore, this method can avoid the system overhead caused by the additional vmexit introduced by existing mechanisms. In this embodiment, a data structure for dirty page quota management per vCPU is set at the lower virtualization layer and is shared with the upper virtualization layer. The lower virtualization layer refers to the part of the hypervisor located in kernel state; the upper virtualization layer refers to the part of the hypervisor located in user state. The aforementioned data structure includes a dirty page counter and a dirty page quota threshold. The dirty page counter (pgs_counted) is used to count the number of dirty pages in the virtual machine, and its value monotonically increases. The dirty page quota threshold is used to set the dirty page quota value and is used to record the window quota (pgs_quota). A shared rather than synchronous approach is used for the data structure because this method requires high-frequency interaction between the upper and lower virtualization layers to ensure maximum processing efficiency. The update operation of the dirty page counter quota management data structure in the lower virtualization layer is set within the dirty page bitmap marking process in the original hot migration process, which is essentially an extension of the original process. The original mechanism is utilized instead of a separate new process, mainly to ensure processing efficiency and avoid the additional overhead of a new process.
[0048] In step S203, controlling the virtual machine's vCPU to hibernate can be implemented using the desired method, including continuous hibernation and intermittent hibernation. For example, as an optional implementation, in this embodiment, controlling the virtual machine's vCPU to hibernate in step S203 means controlling the virtual machine's vCPU to immediately hibernate from the current moment until the end of the current control cycle T, i.e., hibernation time = the start time of the next control cycle T - the current time. This method makes the hibernation operation simple and controllable, achieving the goal that the performance loss or actual speed reduction ratio of the virtual machine during hot migration changes with the size of the memory write load in units of control cycle T. After hibernation, it checks whether the quota for the next cycle has been allocated. If not, it enters a busy polling wait for a certain period; after confirming allocation, it re-enters the virtualization lower layer for execution. It is evident that by having the vCPU consume the current cycle's dirty page quota and then hibernate until the next cycle's time point, and confirming that the next cycle's quota has been allocated, the method achieves the goal of controlling the number of dirty pages per unit time.
[0049] In this embodiment, S203 is handled by an event response processing function pre-set in the user-space virtualization layer. This event response processing function is executed using a callback function. A new VCPU exit event callback function is set in the lower virtualization layer to handle the VCPU pause operation when its quota is exhausted. The exit event timing is set when the current VCPU's dirty page count reaches or equals the currently set quota. That is, once the VCPU exhausts its currently set quota, it will "actively" exit.
[0050] In this embodiment, when allocating reserved quotas to virtual machines and window quotas pgs_quota for each vCPU in the next control cycle T at the end of each control cycle T, allocating reserved quotas to virtual machines includes: calculating the difference between the window quota pgs_quota of the current control cycle T and the total number of dirty page quotas consumed by each vCPU in the current control cycle T; if the difference between the window quota pgs_quota of the current control cycle T and the total number of dirty page quotas consumed by each vCPU in the current control cycle T is greater than or equal to 1, then the difference between the window quota pgs_quota of the current control cycle T and the total number of dirty page quotas consumed by each vCPU in the current control cycle T is added to the reserved quota.
[0051] In this embodiment, when allocating reserved quotas to virtual machines and window quotas pgs_quota for each vCPU in the next control cycle T at the end of each control cycle T, the function expression for the window quota pgs_quota allocated to each vCPU in the next control cycle T is as follows:
[0052] pgs_quota = pgs_limit / N
[0053] In the above formula, pgs_limit is the preset dirty page quota, and N is the number of virtual machine vCPUs.
[0054] In this embodiment, step S202, marking dirty pages to obtain the number of marked dirty pages pgs_counted, includes: using a dirty page counter located in the lower layer of virtualization with a monotonically increasing value to count the dirty pages of the virtual machine to obtain the number of marked dirty pages pgs_counted.
[0055] As an optional approach, in this embodiment, within each dirty page quota allocation cycle, the allowed dirty page generation rate, i.e., the current dirty page rate limit, is determined in some way based on the current rate limiting conditions. Specifically, this embodiment further includes a step of determining a preset dirty page quota pgs_limit before step S102:
[0056] S301, Determine the upper limit V for the dirty page rate.page ;
[0057] S302, determining the upper limit value V of the dirty page rate. page Based on this, the preset dirty page quota pgs_limit is calculated according to the following formula:
[0058] pgs_limit = V page *1000 / T
[0059] In the above formula, V page The upper limit of the dirty page rate is denoted by T, which represents the control period in milliseconds. This calculation result is called the theoretical window quota, serving as a basis for actual VCPU allocation. Actual quota allocation also needs to consider handling load imbalance between VCPUs. Load imbalance refers to the fact that the initial quota calculation assumes an even distribution across all VCPUs, but in reality, the workload borne by each VCPU is inconsistent. Therefore, some VCPUs may not fully utilize their quotas (quota redundancy, "overloaded"), while others may have insufficient quotas ("underutilized"). Thus, it is necessary to address the balance issue. In this embodiment, load imbalance between VCPUs is addressed using two types of quotas: window quotas and reserved quotas. Window quotas are allocated to a specific VCPU within a period; reserved quotas are the accumulation of window quotas not allocated to any VCPU within a period. The calculation methods for actual window quotas and reserved quotas are as follows: Each vCPU only allocates window quotas when its current available quota is less than one window quota. That is, if the current available quota exceeds one window quota, no allocation is made. The final calculated window quota result is the actual window quota. When a vCPU's available quota exceeds one window quota, no actual window quota allocation is performed; this portion of the window quota is added to the reserved quota. The specific use of the reserved quota is as follows: when a vCPU exits due to quota exceeding the limit, it can first attempt to allocate from the reserved quota. If it successfully obtains a quota from the reserved quota, it can avoid pausing the current run and directly return to the virtual machine running state; only when obtaining a reserved quota fails will the run pause operation begin. In each quota cycle, quota settings for each vCPU are completed based on the actual window quota. Moreover, based on the data sharing method mentioned above, quota settings from the upper virtualization layer can be directly accessed by the lower virtualization layer without a synchronization process. Therefore, there is no loss of efficiency in the interaction between the upper and lower layers of virtualization regarding quota settings. For example... Figure 5The diagram shows the dirty page quota allocation flowchart during hot migration rate limiting. The steps include: S401, determining the upper limit of the dirty page rate within time T based on the current rate limiting conditions. S402, calculating the theoretical window quota within time T based on the upper limit value mentioned in the previous step. S403, calculating the actual window quota value based on the theoretical window quota and according to the window quota and reserved quota allocation strategy. S404, setting the quota value per vCPU of the virtual machine according to the actual window quota value. It should be noted that this setting method is a direct method based on shared data structures, and there is no overhead from data synchronization processes.
[0060] In summary, the rate-limiting method based on dirty page quotas in virtual machine hot migration of this invention includes setting an upper limit on the amount of dirty pages that a virtual machine can generate per unit time, ensuring that the actual amount of dirty pages generated by the virtual machine per unit time does not exceed the set value. To achieve this objective, a method for controlling VCPU operation pause (sleep) based on dirty page quotas is provided. This method utilizes the system's existing dirty page marking process to implement virtual machine exit events, and the VCPU's own thread completes the operation pause, avoiding the need for interaction and signal notification between other threads and the VCPU thread. Simultaneously, a dirty page quota management method is provided, including the calculation and setting of two types of quotas: window quota and reserved quota. In this embodiment of the rate-limiting method based on dirty page quotas in virtual machine hot migration, after the VCPU triggers the exit timing and exits to user mode, it directly completes the sleep delay operation by itself, i.e., the VCPU thread, without needing interaction with other threads or signal notification. The entire process can be understood as a "synchronous" or "active sleep" method. The existing mechanism is an "asynchronous" way to pause VCPU operation. The VCPU thread's hibernation depends on the virtualization layer sending a signal to the VCPU thread during each rate-limiting cycle, causing the VCPU to exit the virtual machine, essentially "removing" the VCPU – a form of "passive pause." This process incurs system overhead due to signal transmission and the resulting new virtual machine exit events. In practice, because the rate-limiting cycle is short and frequent, this overhead accumulates over time, becoming significant. The method in this application, however, only performs quota setting at the virtualization layer without sending signals to the VCPU; the virtual machine's VCPU automatically hibernates. Furthermore, the VCPU exits the virtual machine within the existing dirty page marking process, avoiding new VCPU exit events. This avoids the system performance overhead caused by frequent signal transmission and unnecessary virtual machine exit events during rate-limiting operations.
[0061] Furthermore, this embodiment also provides a rate limiting system based on dirty page quotas during virtual machine hot migration, including a microprocessor and a memory interconnected, wherein the microprocessor is programmed or configured to execute the steps of the aforementioned rate limiting method based on dirty page quotas during virtual machine hot migration. Additionally, this embodiment also provides a computer-readable storage medium storing a computer program for being programmed or configured by a microprocessor to execute the steps of the aforementioned rate limiting method based on dirty page quotas during virtual machine hot migration.
[0062] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create an implementation for the process. Figure 1 One or more processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable apparatus for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0063] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A rate-limiting method based on dirty page quotas during virtual machine hot migration, characterized in that, include: S101, determine the control period T; S102, During the hot migration of a virtual machine, the virtual machine is rate-limited to ensure that the actual number of dirty pages generated by the virtual machine in each control cycle T is less than the preset dirty page quota. pgs_limit This causes the performance loss or actual speed reduction of the virtual machine during the hot migration process to change in terms of the size of the memory write load, with the control cycle T as the unit. In step S102, the rate limiting of the virtual machine is specifically achieved by putting the virtual machine's vCPU to sleep. This includes allocating reserved quotas to the virtual machine and window quotas for each vCPU in the next control cycle T at the end of each control cycle T through the dirty page quota allocation thread corresponding to each virtual machine and operating in user mode. pgs_quota The reserved quota refers to the dirty page quota reserved for all vCPUs; The method of limiting speed by putting the virtual machine's vCPU to sleep includes: S201, When the virtual machine's vCPU is in the running state, and a memory write operation performed during the virtual machine's hot migration causes the virtual machine's vCPU to exit from the virtual machine's running state to the kernel state, the process jumps to step S202. S202, using the virtual machine's vCPU switched to kernel mode, first performs dirty page marking to obtain the number of marked dirty pages. pgs_counted Then determine the number of dirty pages. pgs_counted Does it exceed the window quota for this control period T? pgs_ quota If it does not exceed the window quota pgs_quota If the condition is met, return to the virtual machine running state and proceed to step S201; otherwise, determine that a dirty page quota has been consumed and generate a dirty page quota exceedance event. event This is due to the dirty page quota exceeding event. event This triggers an exit operation to the upper layer of virtualization, returning to the user mode of the upper layer of virtualization, and jumps to step S203; S203, the event response handling function pre-set in the upper layer of user-mode virtualization performs the response processing: determine whether a reserved quota can be obtained; if a reserved quota cannot be obtained, control the virtual machine's vCPU to hibernate, and then jump to step S201; if a reserved quota can be obtained, determine that hibernation is not required, consume one reserved quota and jump to step S201.
2. The method of claim 1, wherein the dirty page quota is determined based on a dirty page rate of the virtual machine. In step S203, controlling the virtual machine's vCPU to hibernate means controlling the virtual machine's vCPU to immediately hibernate from the current moment until the end of this control cycle T.
3. The method of claim 1, wherein the dirty page quota is determined based on a dirty page rate of the virtual machine. The process involves allocating reserved quotas to virtual machines and window quotas for each vCPU in the next control cycle T at the end of each control cycle T. pgs_quota When allocating reserved quotas to virtual machines, the process includes: calculating the window quota for the current control period T. pgs_quota The difference in the total number of dirty page quotas consumed by each vCPU within this control period T, if the window quota of this control period T pgs_ quota If the difference in the total number of dirty page quotas consumed by each vCPU within this control period T is greater than or equal to 1, then the window quota for this control period T will be adjusted. pgs_quota The difference between the total number of dirty page quotas consumed by each vCPU within this control cycle T is added to the reserved quota.
4. The method of claim 1, wherein the dirty page quota is determined based on a dirty page rate of the virtual machine. The process involves allocating reserved quotas to virtual machines and window quotas for each vCPU in the next control cycle T at the end of each control cycle T. pgs_quota At that time, the window quota allocated to each vCPU for the virtual machine in the next control cycle T. pgs_quota The function expression is: pgs_quota = pgs_limit / N In the above formula, pgs_limit is the preset dirty page quota in the control period T, N is the number of vcpus of the virtual machine.
5. The method of claim 1, wherein the dirty page quota is determined based on a dirty page rate of the virtual machine. In step S202, dirty pages are marked to obtain the number of marked dirty pages. pgs_counted This includes: using a monotonically increasing dirty page counter located in the lower layer of virtualization to count the dirty pages of the virtual machine to obtain the number of marked dirty pages. pgs_ counted .
6. The method of claim 1, wherein the dirty page quota is determined based on a dirty page rate of the virtual machine. The step S102 further comprises the step of determining a preset dirty page quota pgs_limit of the step: S301, determine the upper limit value of the dirty page rate V page ; S302, determine the upper limit value of the dirty page rate V page On the basis of the upper limit value of the dirty page rate pgs_ limit : pgs_limit = V page *1000 / T In the above formula, V page is the upper limit value of the dirty page rate; T is the control period, in milliseconds.
7. A system for rate limiting based on dirty page quota in virtual machine live migration, comprising a microprocessor and a memory connected to each other, characterized in that, The microprocessor is programmed or configured to perform the steps of the rate-limiting method based on dirty page quotas in virtual machine hot migration as described in any one of claims 1 to 6.
8. A computer-readable storage medium storing a computer program, characterized in that, The computer program is used to be programmed or configured by a microprocessor to perform the steps of the rate limiting method based on dirty page quotas in virtual machine hot migration as described in any one of claims 1 to 6.