Virtual machine CPU binding method and device, electronic equipment, storage medium and product
By disassembling the number of CPUs of the virtual machine and screening suitable CPU packets, the problem of unreasonable problems with the virtual machine CPU and memory binding is solved, and the processing performance of the virtual machine on the NUMA node is improved.
Patent Information
- Application Number
- CN202411400204.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-01-24
AI Technical Summary
In the prior art, the CPU and memory binding of the virtual machine is unreasonable, resulting in low processing performance of virtual machines running on NUMA nodes.
By disassembling the CPU quantity requirements of the virtual machines to be bound, multiple CPU groups that can meet the CPU quantity requirements are selected to ensure that the CPUs of the virtual machines can be bound to the same NUMA node.
By grouping a smaller number of CPUs in the same NUMA node to meet the CPU number requirements of the virtual machine, the impact of different L3 caches on system performance is reduced, and the processing performance of the virtual machine is improved.
Smart Images

Figure CN119356797A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a virtual machine CPU binding method, device, electronic device, storage medium and product. Background Art
[0002] In the related art, the central processing unit (CPU) and memory of a virtual machine are usually bound based on the NUMA node in the non-uniform memory access (NUMA) architecture. However, in the related art, due to the unreasonable binding of the CPU and memory of the virtual machine, the processing performance of the virtual machine running on the NUMA node is low. Summary of the invention
[0003] The present disclosure provides a virtual machine CPU binding method, device, electronic device, storage medium and product to solve the problem in the related art that the CPU of the virtual machine to be bound cannot be bound to the same NUMA node in the NUMA architecture.
[0004] A first aspect of the present disclosure provides a method for binding a virtual machine CPU, the method comprising:
[0005] In response to the absence of a second NUMA node in the first NUMA node, decomposing the CPU quantity requirement of the to-be-bound virtual machine into a first number of first CPU quantity sub-requirements; each NUMA node includes at least one CPU group, and the second NUMA node refers to a first NUMA node that has at least one CPU group and can meet the CPU quantity requirement of the to-be-bound virtual machine;
[0006] Determine whether there is a third NUMA node; the third NUMA node refers to a first NUMA node where at least a first number of CPU groups can meet the first CPU number sub-requirement;
[0007] If the judgment result is no, continue to disassemble the first CPU quantity sub-requirement until a third NUMA node exists in the first NUMA node;
[0008] The virtual machine to be bound is bound to the corresponding third NUMA node with the least number of disassembly times.
[0009] In one embodiment, the first aspect of the present disclosure provides a virtual machine CPU binding method further comprising:
[0010] At least one first NUMA node whose allocatable memory meets the memory requirement of the virtual machine to be bound is selected from the NUMA nodes of the NUMA architecture.
[0011] In one embodiment, selecting at least one first NUMA node that can meet the memory requirement of the virtual machine to be bound from the NUMA nodes of the NUMA architecture includes:
[0012] Acquire allocatable information of each NUMA node in the NUMA architecture; the allocatable information includes allocatable memory of the corresponding NUMA node;
[0013] Based on the memory requirement in the resource requirement of the virtual machine to be bound, at least one first NUMA node whose allocatable memory meets the memory requirement of the virtual machine to be bound is screened out from the NUMA nodes in the NUMA architecture.
[0014] In one embodiment, the allocatable information further includes the number of allocatable CPUs in each CPU group of the corresponding NUMA node;
[0015] The determining whether a third NUMA node exists includes:
[0016] Each of the first NUMA nodes is traversed to determine whether there is a first NUMA node in the first NUMA nodes where the number of allocatable CPUs of at least a first number of CPU groups meets the first CPU number sub-requirement.
[0017] In one embodiment, if the judgment result is no, after continuing to decompose the first CPU quantity sub-requirement, the method further includes:
[0018] If, after the first CPU quantity sub-requirement is decomposed into the first minimum unit, there is no third NUMA node in the first NUMA node, decompose the memory requirement and the CPU quantity requirement of the virtual machine to be bound into a second number of memory sub-requirements and a second number of second CPU quantity sub-requirements; the memory capacity corresponding to each of the memory sub-requirements is the same, and the number of CPUs corresponding to each of the second CPU quantity sub-requirements is the same;
[0019] Determine whether there are at least a second number of fourth NUMA nodes in the NUMA architecture, where the fourth NUMA node refers to a NUMA node whose allocatable memory meets the memory sub-requirement and whose allocatable number of CPUs in the CPU grouping meets the second CPU number sub-requirement;
[0020] If the judgment result is no, continue to disassemble the memory sub-requirement and the second CPU quantity sub-requirement until there are at least a third number of fourth NUMA nodes in the first NUMA node; the third number refers to the number of the disassembled memory sub-requirement or the second CPU quantity sub-requirement;
[0021] Filtering at least a third number of fifth NUMA nodes whose distances between NUMA nodes are less than a preset distance threshold from the fourth NUMA nodes;
[0022] Bind the to-be-bound virtual machine to a third number of the nearest fifth NUMA nodes.
[0023] In one embodiment, if there are no at least a third number of fifth NUMA nodes among the fourth NUMA nodes whose distances between NUMA nodes are less than a preset distance threshold, then after decomposing the memory requirement and the CPU quantity requirement of the to-be-bound virtual machine into a second number of memory sub-requirements and a second number of second CPU quantity sub-requirements, the method further includes:
[0024] Filter out a second number of sixth NUMA nodes from the NUMA architecture, the distance between NUMA nodes being not less than a preset distance threshold, the sixth NUMA node being a NUMA node whose allocatable memory satisfies the memory sub-requirement and whose allocatable number of CPUs in a CPU group satisfies the second CPU number sub-requirement;
[0025] Bind the to-be-bound virtual machine to a second number of sixth NUMA nodes.
[0026] In one embodiment, if there is no second number of sixth NUMA nodes in the NUMA architecture whose distances between NUMA nodes are not less than a preset distance threshold, the method further includes:
[0027] The virtual machine to be bound is randomly bound to a NUMA node in the NUMA architecture.
[0028] A second aspect of the present disclosure provides a virtual machine CPU binding device, the device comprising:
[0029] A disassembling unit, configured to, in response to the absence of a second NUMA node, disassemble the CPU quantity requirement of the to-be-bound virtual machine into a first number of first CPU quantity sub-requirements; each of the NUMA nodes includes at least one CPU group, and the second NUMA node refers to a first NUMA node that has at least one CPU group and can meet the CPU quantity requirement of the to-be-bound virtual machine;
[0030] A determination unit, configured to determine whether there is a third NUMA node; the third NUMA node refers to a first NUMA node having at least a first number of CPU groups that can meet the first CPU number sub-requirement;
[0031] a re-disassembly unit, configured to, if the judgment result is no, continue to disassemble the first CPU quantity sub-requirement until a third NUMA node exists in the first NUMA node;
[0032] The binding unit is used to bind the virtual machine to be bound to the corresponding third NUMA node with the least number of disassembly times.
[0033] A third aspect of the present disclosure provides an electronic device, including:
[0034] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the embodiment of the first aspect of the present disclosure.
[0035] The fourth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in the first aspect embodiment of the present disclosure.
[0036] A fifth aspect embodiment of the present disclosure provides a computer program product, including a computer program, which implements the method described in the first aspect embodiment of the present disclosure when executed by a processor.
[0037] In summary, the present disclosure proposes a virtual machine CPU binding method, device, electronic device, storage medium and product, wherein the virtual machine CPU binding method includes: in response to the absence of a second NUMA node, decomposing the CPU quantity requirement of the virtual machine to be bound into a first number of first CPU quantity sub-requirements; each of the NUMA nodes includes at least one CPU group, and the second NUMA node refers to a first NUMA node with at least one CPU group that can meet the CPU quantity requirement of the virtual machine to be bound; judging whether there is a third NUMA node; the third NUMA node refers to a first NUMA node with at least a first number of CPU groups that can meet the first CPU quantity sub-requirement; if the judgment result is no, continuing to decompose the first CPU quantity sub-requirement until the third NUMA node exists in the first NUMA node; binding the virtual machine to be bound to the corresponding third NUMA node with the least number of decompositions.
[0038] The solution provided by the present disclosure screens out multiple CPU groups that can meet the CPU quantity requirements in the first NUMA node by disassembling the CPU quantity requirements of the virtual machine to be bound, thereby ensuring that the CPUs of the virtual machine to be bound can be bound to the same NUMA node in the NUMA architecture; thereby, the CPU quantity requirements of the virtual machine to be bound are met by a smaller number of CPU groups in the same NUMA node of the NUMA architecture, thereby minimizing the impact of different L3 caches on system performance, thereby effectively improving the processing performance of the virtual machines running on the NUMA nodes.
[0039] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0041] Figure 1 A flowchart of a virtual machine CPU binding method provided in an embodiment of the present disclosure;
[0042] Figure 2 A schematic diagram of a NUMA architecture provided for an embodiment of the present disclosure;
[0043] Figure 3 A flowchart of a method for screening a first NUMA node provided by an embodiment of the present disclosure;
[0044] Figure 4 A flowchart of a method for selecting a fifth NUMA node provided by an embodiment of the present disclosure;
[0045] Figure 5 A flowchart of a method for selecting a sixth NUMA node provided by an embodiment of the present disclosure;
[0046] Figure 6 A schematic diagram of the structure of a virtual machine CPU binding device provided in an embodiment of the present disclosure;
[0047] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0048] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.
[0049] In the relevant NUMA architecture, the CPU and memory are divided into multiple NUMA nodes. Each NUMA node corresponds to an independent memory space and a Peripheral Component Interconnect Express (PCI-E) bus system. The speed at which the CPU accesses the memory of its own NUMA node is much higher than the speed at which it accesses the memory of other NUMA nodes. Therefore, binding a process or thread to a specified CPU can effectively improve the operating efficiency of the virtual machine and the NUMA architecture.
[0050] However, in the related art, due to unreasonable CPU and memory binding of the virtual machine, the processing performance of the virtual machine running on the NUMA node is low.
[0051] In order to solve the defects in the related art, the present invention disassembles the CPU quantity requirement of the virtual machine to be bound, screens out multiple CPU groups that can meet the CPU quantity requirement in the first NUMA node, and ensures that the CPU of the virtual machine to be bound can be bound to the same NUMA node in the NUMA architecture; thereby, the CPU quantity requirement of the virtual machine to be bound is met by a smaller number of CPU groups in the same NUMA node of the NUMA architecture, thereby minimizing the impact of different L3 caches on system performance, thereby effectively improving the processing performance of the virtual machine running on the NUMA node.
[0052] The present disclosure is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0053] like Figure 1 As shown, Figure 1 A flowchart of a virtual machine CPU binding method provided in an embodiment of the present disclosure. The virtual machine CPU binding method provided in an embodiment of the present disclosure comprises the following steps:
[0054] Step 101, in response to the absence of a second NUMA node, decomposing the CPU quantity requirement of the to-be-bound virtual machine into a first number of first CPU quantity sub-requirements;
[0055] In one embodiment, each NUMA node includes at least one CPU grouping.
[0056] In one embodiment, the second NUMA node refers to a first NUMA node having at least one CPU grouping that can meet the CPU quantity requirement of the virtual machine to be bound; the first NUMA node is a NUMA node in a NUMA architecture. The CPU grouping meeting the CPU quantity requirement of the virtual machine to be bound means that the allocatable CPU quantity of the CPU grouping meets the CPU quantity requirement of the virtual machine to be bound.
[0057] In one embodiment, the number of allocatable CPUs of a CPU group refers to the number of CPUs in the corresponding CPU group whose CPU usage is lower than a preset CPU usage threshold.
[0058] In one embodiment, the NUMA architecture in the related art is as follows: Figure 2 As shown; Figure 2 The NUMA architecture in the system has four NUMA nodes: NUMA0, NUMA1, NUMA3, and NUMA4. The NUMA0 node corresponds to Memory0, the NUMA1 node corresponds to Memory1, the NUMA3 node corresponds to Memory2, and the NUMA4 node corresponds to Memory3. There are two CPU groups in each of the four NUMA nodes: NUMA0, NUMA1, NUMA3, and NUMA4. For example, the first CPU group in NUMA0 includes CPU0-CPU7, which share the same L3 cache, and the second CPU group in NUMA0 includes CPU8-CPU15, which share the same L3 cache.
[0059] by Figure 2 For example, if the memory that can be allocated by NUMA0 node and NUMA1 node meets the memory requirements of the virtual machine to be bound, the first NUMA node. For example, the number of allocatable CPUs in the first CPU group in NUMA0 node is 2, namely CPU0 and CPU1, and the number of allocatable CPUs in the second CPU group in NUMA0 node is 3, namely CPU8, CPU9 and CPU10. The number of CPUs required for the virtual machine to be bound is 4. Then NUMA0 node cannot be used as the second NUMA node. Similarly, if the number of allocatable CPUs in the first CPU group or / and the second CPU group in NUMA1 node is not less than 4, then NUMA1 node can be used as the second NUMA node; conversely, if the number of allocatable CPUs in the first CPU group or the second CPU group in NUMA1 node is less than 4, then NUMA1 node cannot be used as the second NUMA node.
[0060] In one embodiment, if there is at least one second NUMA node in the first NUMA node, the CPU of the virtual machine to be bound can be bound to a CPU group of any second NUMA node that meets the CPU quantity requirement of the virtual machine to be bound, so as to ensure that the CPUs of the virtual machine to be bound share the same L3 cache and improve the running performance of the virtual machine to be bound. If there is no second NUMA node in the first NUMA node, it means that the CPU of the virtual machine to be bound cannot be bound to the same CPU group of the same NUMA node. At this time, in order to improve the running performance of the virtual machine to be bound, consider binding the CPU of the virtual machine to be bound to different CPU groups of the same NUMA node.
[0061] In one embodiment, in order to bind the CPU of a bound virtual machine to different CPU groups of the same NUMA node, it is necessary to decompose the CPU quantity requirement of the virtual machine to be bound into multiple first CPU quantity sub-requirements, and each first CPU quantity sub-requirement corresponds to a CPU group. Among them, the number of first CPU quantity sub-requirements is the first quantity. For example, if the CPU quantity requirement of the virtual machine to be bound is split in half, the first quantity is 2. If the CPU quantity requirement of the virtual machine to be bound is split according to other rules, the first quantity changes accordingly. Among them, when the CPU quantity requirement of the virtual machine to be bound is split in half, the number of CPUs corresponding to each of the first CPU quantity sub-requirements is the same. For example, if the CPU quantity requirement of the virtual machine to be bound is 32, then when the CPU quantity requirement of the virtual machine to be bound is split in half, the number of CPUs corresponding to each of the first CPU quantity sub-requirements is 16.
[0062] Step 102, determining whether there is a third NUMA node;
[0063] In one embodiment, the third NUMA node refers to a first NUMA node having at least a first number of CPU groups that can satisfy the first CPU number sub-requirement;
[0064] In one embodiment, the CPU quantity requirement of the virtual machine to be bound is decomposed into a first number of first CPU quantity sub-requirements, and each first NUMA node needs to be traversed to determine whether there is a third NUMA node in the first NUMA node.
[0065] Step 103: if the judgment result is no, continue to disassemble the first CPU quantity sub-requirement until a third NUMA node exists in the first NUMA node;
[0066] In one embodiment, if the judgment result is yes, that is, after decomposing the CPU quantity requirement of the virtual machine to be bound into a first number of first CPU quantity sub-requirements, if there is a third NUMA node in the first NUMA node, the CPU of the virtual machine to be bound can be directly bound to any third NUMA node.
[0067] In one embodiment, if after the first decomposition, that is, after the CPU quantity requirement of the virtual machine to be bound is decomposed into the first number of first CPU quantity sub-requirements, there is no third NUMA node in the first NUMA node, it means that in each CPU group in the first NUMA node, there is no allocatable CPU quantity in the first number of CPU groups that can meet the CPU quantity requirement corresponding to the first CPU quantity sub-requirement; at this time, in order to bind the CPU of the virtual machine to be bound to different CPU groups of the same NUMA node, consider continuing to decompose the first CPU quantity sub-requirement, and its decomposition rule can be the same as the first decomposition, for example, the first CPU quantity sub-requirement is decomposed in half, at this time, each first CPU quantity sub-requirement is decomposed into 2 first CPU quantity sub-requirements, and the number of CPUs corresponding to the decomposed first CPU quantity sub-requirement is 8. Then according to step 103, it is determined whether there is a third NUMA node in the first NUMA node; if the determination result is still no, iterate the above decomposition and determination process until there is a third NUMA node in the first NUMA node.
[0068] Step 104: bind the virtual machine to be bound to the corresponding third NUMA node with the least number of disassembly times.
[0069] The present invention proposes a virtual machine CPU binding method.
[0070] The virtual machine CPU binding method includes: in response to the absence of a second NUMA node in the first NUMA node, decomposing the CPU quantity requirement of the virtual machine to be bound into a first number of first CPU quantity sub-requirements; each of the NUMA nodes includes at least one CPU group, and the second NUMA node refers to a first NUMA node with at least one CPU group that can meet the CPU quantity requirement of the virtual machine to be bound; judging whether there is a third NUMA node; the third NUMA node refers to a first NUMA node with at least a first number of CPU groups that can meet the first CPU quantity sub-requirement; if the judgment result is no, continuing to decompose the first CPU quantity sub-requirement until the third NUMA node exists in the first NUMA node; binding the virtual machine to be bound to the corresponding third NUMA node with the least number of decompositions.
[0071] The solution provided by the present disclosure screens out multiple CPU groups that can meet the CPU quantity requirements in the first NUMA node by disassembling the CPU quantity requirements of the virtual machine to be bound, thereby ensuring that the CPUs of the virtual machine to be bound can be bound to the same NUMA node in the NUMA architecture; thereby, the CPU quantity requirements of the virtual machine to be bound are met by a smaller number of CPU groups in the same NUMA node of the NUMA architecture, thereby minimizing the impact of different L3 caches on system performance, thereby effectively improving the processing performance of the virtual machines running on the NUMA nodes.
[0072] In one embodiment, before step 101, the virtual machine CPU binding method provided by the embodiment of the present disclosure further includes:
[0073] Filter out at least one first NUMA node that can meet the memory requirement of the virtual machine to be bound from the NUMA nodes of the NUMA architecture;
[0074] In one embodiment, the resource requirements of the virtual machine to be bound include memory requirements and CPU quantity requirements; the memory requirement is used to indicate the memory capacity required by the virtual machine to be bound, and the CPU quantity requirement is used to indicate the number of CPUs required to maintain the operating efficiency of the virtual machine.
[0075] In one embodiment, the allocatable memory of a NUMA node of a NUMA architecture can be obtained by a resource manager of the NUMA architecture; generally, the allocatable memory of a NUMA node includes pre-applied large page memory and ordinary memory. The allocatable memory of a NUMA node refers to the capacity of the allocatable memory of the corresponding NUMA node. For example, the remaining memory of a NUMA node can be used as the allocatable memory of the NUMA node; for the operation efficiency of the NUMA node, the difference between eighty percent of the total memory of the NUMA node and the used memory can also be used as the allocatable memory of the NUMA node.
[0076] In one embodiment, the ability of a NUMA node to satisfy the memory requirement of the to-be-bound virtual machine means that the capacity of the allocatable memory of the NUMA node is greater than the memory capacity required by the to-be-bound virtual machine.
[0077] In one embodiment, if Figure 3 As shown, the step of selecting at least one first NUMA node that can meet the memory requirement of the virtual machine to be bound from the NUMA nodes of the NUMA architecture includes:
[0078] Step 301, obtaining allocatable information of each NUMA node in the NUMA architecture;
[0079] In one embodiment, the allocatable information includes allocatable memory of the corresponding NUMA node.
[0080] In one embodiment, the allocatable memory of the NUMA node may be obtained by a resource manager of the NUMA architecture.
[0081] Step 302: based on the memory requirement in the resource requirement of the virtual machine to be bound, select from the NUMA nodes in the NUMA architecture at least one first NUMA node whose allocatable memory satisfies the memory requirement of the virtual machine to be bound.
[0082] In one embodiment, based on the memory requirements in the resource requirements of the virtual machine to be bound, each NUMA node in the NUMA architecture can be traversed, and then at least one first NUMA node that can allocate memory to meet the memory requirements of the virtual machine to be bound can be screened out from the NUMA nodes in the NUMA architecture.
[0083] In one embodiment, if the first NUMA node does not exist in the NUMA architecture, it indicates that the corresponding NUMA architecture does not meet the binding condition of the virtual machine to be bound and cannot be bound to the virtual machine to be bound.
[0084] In one embodiment, the allocatable information further includes the number of allocatable CPUs in each CPU group of the corresponding NUMA node;
[0085] Accordingly, step 102 includes:
[0086] Each of the first NUMA nodes is traversed to determine whether there is a first NUMA node in the first NUMA nodes where the number of allocatable CPUs of at least a first number of CPU groups meets the first CPU number sub-requirement.
[0087] In one embodiment, if there are at most 4 CPU groups in the first NUMA node of the NUMA architecture ( Figure 3 In the example, each NUMA node has only 2 CPU groups. When the CPU quantity requirement of the virtual machine to be bound is split in half, the first split will split the CPU quantity requirement into 2 first CPU quantity sub-requirements. In the second split, the 2 first CPU quantity sub-requirements are split respectively. The result of the split is 4 split first CPU quantity sub-requirements. After the second split, if there is no third NUMA node in the first NUMA node, there is no need to perform the third split, because the number of first CPU quantity sub-requirements after the third split has exceeded the maximum number of CPU groups in the first NUMA node. At this time, in order to improve the operating performance of the virtual machine to be bound, consider binding the CPU of the virtual machine to be bound to different close NUMA nodes.
[0088] Based on this, in one embodiment, if Figure 4As shown, if the judgment result in step 103 is no, after continuing to disassemble the first CPU quantity sub-requirement, the virtual machine CPU binding method provided by the embodiment of the present disclosure further includes the following steps:
[0089] Step 401: if there is no third NUMA node in the first NUMA node after the first CPU quantity sub-requirement is decomposed into a first minimum unit, decompose the memory requirement and the CPU quantity requirement of the virtual machine to be bound into a second number of memory sub-requirements and a second number of second CPU quantity sub-requirements;
[0090] In one embodiment, as described above, the first minimum unit refers to the minimum number of CPUs included in each CPU number sub-requirement during the last disassembly.
[0091] In one embodiment, since the memory sub-requirements and the second CPU quantity sub-requirements obtained after decomposing the memory requirement need to be allocated to different NUMA nodes, in order to ensure load balancing between each NUMA node, the memory capacity corresponding to each of the memory sub-requirements is the same, and the number of CPUs corresponding to each of the second CPU quantity sub-requirements is the same.
[0092] Step 402, determining whether there are at least a second number of fourth NUMA nodes in the NUMA architecture;
[0093] In one embodiment, the fourth NUMA node refers to a NUMA node whose allocatable memory satisfies the memory sub-requirement and whose allocatable number of CPUs in the CPU grouping satisfies the second CPU number sub-requirement;
[0094] In one embodiment, each NUMA node in the NUMA architecture may be traversed to determine whether the allocatable memory of each NUMA node meets the memory sub-requirement and whether the allocatable number of CPUs in the CPU grouping meets the second CPU number sub-requirement.
[0095] Step 403: If the judgment result is no, continue to disassemble the memory sub-requirement and the second CPU quantity sub-requirement until there are at least a third number of fourth NUMA nodes in the first NUMA node;
[0096] In one embodiment, the third quantity refers to the quantity of the disassembled memory sub-requirement or the second CPU quantity sub-requirement;
[0097] In one embodiment, if the judgment result is yes, and there are at least a second number of NUMA nodes in the fourth NUMA node whose distances are less than the preset distance threshold, the virtual machine to be bound is directly bound to the second number of fourth NUMA nodes. If the judgment result is no, proceed to step 404.
[0098] In one embodiment, as shown in step 401, the memory sub-requirement and the second CPU quantity sub-requirement also have a limit on the number of times they can be disassembled, and the minimum unit of the disassembly, such as the minimum unit of the memory sub-requirement, can be preset to 4G based on the minimum memory of the NUMA node; the number of the second CPU quantity sub-requirement can be 4.
[0099] Step 404, selecting at least a third number of fifth NUMA nodes whose distances between NUMA nodes are less than a preset distance threshold from the fourth NUMA node;
[0100] In one embodiment, the distance between NUMA nodes is used to indicate the delay when a CPU in a NUMA node accesses the memory of another NUMA node. The distance between NUMA nodes can be obtained through the System Locality Information Table (SLIT) or the numactl command.
[0101] Step 405: bind the virtual machine to be bound to a third number of the nearest fifth NUMA nodes.
[0102] In one embodiment, if there are no at least a third number of fifth NUMA nodes in the fourth NUMA node whose distance between NUMA nodes is less than a preset distance threshold, then in order to improve the running performance of the virtual machine to be bound, consider binding the CPU of the virtual machine to be bound to different distant NUMA nodes; the distant distance refers to the distance between NUMA nodes being not less than the preset distance threshold.
[0103] Based on this, in one embodiment, if Figure 5 As shown, if there are no at least a third number of fifth NUMA nodes in the fourth NUMA node whose distances between NUMA nodes are less than the preset distance threshold, after decomposing the memory requirement and the CPU quantity requirement of the virtual machine to be bound into a second number of memory sub-requirements and a second number of second CPU quantity sub-requirements in step 403, the virtual machine CPU binding method provided by the embodiment of the present disclosure further includes the following steps:
[0104] Step 501, screening out a second number of sixth NUMA nodes from the NUMA architecture, the distances between NUMA nodes being not less than a preset distance threshold;
[0105] In one embodiment, the sixth NUMA node refers to a NUMA node whose allocatable memory satisfies the memory sub-requirement and whose allocatable number of CPUs in the CPU grouping satisfies the second CPU number sub-requirement;
[0106] In one embodiment, the method for selecting the second number of sixth NUMA nodes whose distances between NUMA nodes are not less than a preset distance threshold from the NUMA architecture may refer to the screening method in step 404, which will not be described in detail here.
[0107] Step 502: Bind the virtual machine to be bound to a second number of sixth NUMA nodes.
[0108] In one embodiment, if there are no second number of sixth NUMA nodes in the NUMA architecture whose distances between NUMA nodes are not less than a preset distance threshold, it means that the memory resources and CPU resources of the NUMA nodes in the NUMA architecture are insufficient to deploy the virtual machine to be bound. At this time, in order for the virtual machine to be bound to run normally, a random binding method can be adopted.
[0109] Based on this, in one embodiment, if there are no sixth NUMA nodes whose distances between NUMA nodes are not less than a preset distance threshold in the NUMA architecture, the virtual machine CPU binding method provided by the embodiment of the present disclosure further includes the following steps:
[0110] The virtual machine to be bound is randomly bound to a NUMA node in the NUMA architecture.
[0111] In summary, the virtual machine CPU binding method provided by the embodiment of the present disclosure has the following beneficial effects:
[0112] 1. In the NUMA architecture, if there is a single NUMA node that meets the resource requirements of the virtual machine to be bound, the virtual machine to be bound is preferentially selected to be bound to the single NUMA node; if there is no single NUMA node that meets the resource requirements of the virtual machine to be bound, a NUMA node close to the virtual machine is second-best selected to be bound to the virtual machine; if there is no NUMA node close to the virtual machine that meets the resource requirements of the virtual machine to be bound, a NUMA node far away is third-best selected to be bound to the virtual machine to be bound. The binding method with different priorities of different NUMA nodes is used to ensure the operating efficiency of the virtual machine to be bound.
[0113] 2. The virtual machine CPU binding method provided by the embodiment of the present invention not only takes into account the distance between NUMA nodes in the NUMA architecture when selecting the NUMA node to be bound to the virtual machine, but also takes into account the difference in the allocatable CPUs of different CPU groups in the same NUMA node, thereby optimizing the existing virtual machine CPU binding method to be bound.
[0114] 3. Combining the above beneficial effects 1 and 2, the virtual machine CPU binding method provided by the embodiment of the present disclosure can perform universal CPU binding of the virtual machine to be bound for different NUMA nodes in the NUMA architecture and different CPU groups in the NUMA node, and can improve the operating performance and service quality (Quality of Service, QoS) of the virtual machine to be bound as much as possible under the premise that the NUMA architecture resources are limited.
[0115] In order to implement the virtual machine CPU binding method provided by the embodiment of the present disclosure, the embodiment of the present disclosure also provides a virtual machine CPU binding device, such as Figure 6 shown. Figure 6 This is a structural diagram of a virtual machine CPU binding device provided in an embodiment of the present disclosure, wherein the virtual machine CPU binding device 600 includes:
[0116] The disassembling unit 601 is configured to, in response to the absence of a second NUMA node, disassemble the CPU quantity requirement of the to-be-bound virtual machine into a first number of first CPU quantity sub-requirements; each of the NUMA nodes includes at least one CPU group, and the second NUMA node refers to a first NUMA node having at least one CPU group that can meet the CPU quantity requirement of the to-be-bound virtual machine;
[0117] A determination unit 602 is configured to determine whether there is a third NUMA node; the third NUMA node refers to a first NUMA node having at least a first number of CPU groups that can meet the first CPU number sub-requirement;
[0118] The re-disassembly unit 603 is configured to, if the judgment result is no, continue to disassemble the first CPU quantity sub-requirement until a third NUMA node exists in the first NUMA node;
[0119] The binding unit 604 is configured to bind the virtual machine to be bound to a corresponding third NUMA node with the least number of disassembly times.
[0120] In one embodiment, the virtual machine CPU binding device 600 provided by the embodiment of the present disclosure further includes a screening unit, which is used to: screen out at least one first NUMA node that can meet the memory requirements of the virtual machine to be bound from the NUMA nodes of the NUMA architecture;
[0121] In one embodiment, the screening unit is specifically used for:
[0122] Acquire allocatable information of each NUMA node in the NUMA architecture; the allocatable information includes allocatable memory of the corresponding NUMA node;
[0123] Based on the memory requirement in the resource requirement of the virtual machine to be bound, at least one first NUMA node whose allocatable memory meets the memory requirement of the virtual machine to be bound is screened out from the NUMA nodes in the NUMA architecture.
[0124] In one embodiment, the allocatable information further includes the number of allocatable CPUs in each CPU group of the corresponding NUMA node;
[0125] Accordingly, the judging unit 602 is specifically configured to:
[0126] Each of the first NUMA nodes is traversed to determine whether there is a first NUMA node in the first NUMA nodes where the number of allocatable CPUs of at least a first number of CPU groups meets the first CPU number sub-requirement.
[0127] In one embodiment, the virtual machine CPU binding device 600 provided by the embodiment of the present disclosure further includes an adjacent NUMA node binding unit, and the adjacent NUMA node binding unit is used to:
[0128] If, after the first CPU quantity sub-requirement is decomposed into the first minimum unit, there is no third NUMA node in the first NUMA node, decompose the memory requirement and the CPU quantity requirement of the virtual machine to be bound into a second number of memory sub-requirements and a second number of second CPU quantity sub-requirements; the memory capacity corresponding to each of the memory sub-requirements is the same, and the number of CPUs corresponding to each of the second CPU quantity sub-requirements is the same;
[0129] Determine whether there are at least a second number of fourth NUMA nodes in the NUMA architecture, where the fourth NUMA node refers to a NUMA node whose allocatable memory meets the memory sub-requirement and whose allocatable number of CPUs in the CPU grouping meets the second CPU number sub-requirement;
[0130] If the judgment result is no, continue to disassemble the memory sub-requirement and the second CPU quantity sub-requirement until there are at least a third number of fourth NUMA nodes in the first NUMA node; the third number refers to the number of the disassembled memory sub-requirement or the second CPU quantity sub-requirement;
[0131] Filtering at least a third number of fifth NUMA nodes whose distances between NUMA nodes are less than a preset distance threshold from the fourth NUMA nodes;
[0132] Bind the to-be-bound virtual machine to a third number of the nearest fifth NUMA nodes.
[0133] In one embodiment, the virtual machine CPU binding device 600 provided in the embodiment of the present disclosure further includes a more distant NUMA node binding unit, and the more distant NUMA node binding unit is used to:
[0134] Filter out a second number of sixth NUMA nodes from the NUMA architecture, the distance between NUMA nodes being not less than a preset distance threshold, the sixth NUMA node being a NUMA node whose allocatable memory satisfies the memory sub-requirement and whose allocatable number of CPUs in a CPU group satisfies the second CPU number sub-requirement;
[0135] Bind the to-be-bound virtual machine to a second number of sixth NUMA nodes.
[0136] In one embodiment, the virtual machine CPU binding device 600 provided by the embodiment of the present disclosure further includes a random NUMA node binding unit, and the random NUMA node binding unit is used to:
[0137] The virtual machine to be bound is randomly bound to the NUMA node in the NUMA architecture. It should be noted that: the virtual machine CPU binding device provided in the above embodiment only uses the division of the above program modules as an example when performing virtual machine CPU binding. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the virtual machine CPU binding device is divided into different program modules to complete all or part of the processing described above. In addition, the virtual machine CPU binding device provided in the above embodiment and the virtual machine CPU binding method embodiment provided in the embodiment of the present disclosure belong to the same concept. The specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0138] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure is shown in FIG. Figure 7 As shown, the electronic device 700 includes at least one processor 702; and a memory 701 that is communicatively connected to the at least one processor 702; wherein the memory 701 stores instructions that can be executed by the at least one processor 702, and the instructions are executed by the at least one processor 702 to implement the steps of the virtual machine CPU binding method described in the embodiment of the present disclosure.
[0139] Optionally, the electronic device may specifically be a virtual machine CPU binding device in an embodiment of the present application, and the electronic device may implement the corresponding processes implemented by the virtual machine CPU binding device in each method of the embodiment of the present application, which will not be described in detail here for the sake of brevity.
[0140] It is understood that the electronic device also includes a communication interface 703. The various components in the electronic device are coupled together through a bus system 704. It is understood that the bus system 704 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 704 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 7 Various buses are labeled as bus system 704 .
[0141] It can be understood that the memory 701 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 701 described in the embodiment of the present invention is intended to include but is not limited to these and any other suitable types of memories.
[0142] The method disclosed in the above embodiment of the present disclosure can be applied to the processor 702, or implemented by the processor 702. The processor 702 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 702 or an instruction in the form of software. The above processor 702 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 702 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present invention. A general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 701, and the processor 702 reads the information in the memory 701 and completes the steps of the above method in combination with its hardware.
[0143] In an exemplary embodiment, the electronic device may be implemented by one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), FPGAs, general purpose processors, controllers, MCUs, microprocessors, or other electronic components to execute the aforementioned method.
[0144] The embodiment of the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to implement the steps of the virtual machine CPU binding method described in the embodiment of the present disclosure when executed.
[0145] The embodiment of the present disclosure further provides a computer program product, characterized in that it includes a computer program, and when the computer program is executed by a processor, the steps of the virtual machine CPU binding method described in the embodiment of the present disclosure are implemented.
[0146] Optionally, the computer-readable storage medium can be applied to the virtual machine CPU binding device in the embodiments of the present application, and the computer instructions enable the computer to execute the corresponding processes implemented by the virtual machine CPU binding device in the various methods of the embodiments of the present application. For the sake of brevity, they will not be repeated here.
[0147] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0148] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0149] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0150] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.
[0151] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0152] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A virtual machine CPU binding method, characterized in that: include: In response to the absence of a second NUMA node, decomposing the CPU quantity requirement of the to-be-bound virtual machine into a first number of first CPU quantity sub-requirements; each of the NUMA nodes includes at least one CPU group, and the second NUMA node refers to a first NUMA node having at least one CPU group that can meet the CPU quantity requirement of the to-be-bound virtual machine; Determine whether there is a third NUMA node; the third NUMA node refers to a first NUMA node where at least a first number of CPU groups can meet the first CPU number sub-requirement; If the judgment result is no, continue to disassemble the first CPU quantity sub-requirement until a third NUMA node exists in the first NUMA node; The virtual machine to be bound is bound to the corresponding third NUMA node with the least number of disassembly times.
2. The method according to claim 1, characterized in that The method further comprises: At least one first NUMA node that can meet the memory requirement of the virtual machine to be bound is selected from the NUMA nodes of the NUMA architecture.
3. The method according to claim 2, characterized in that The step of selecting at least one first NUMA node that can meet the memory requirement of the virtual machine to be bound from the NUMA nodes of the NUMA architecture includes: Acquire allocatable information of each NUMA node in the NUMA architecture; the allocatable information includes allocatable memory of the corresponding NUMA node; Based on the memory requirement in the resource requirement of the virtual machine to be bound, at least one first NUMA node whose allocatable memory meets the memory requirement of the virtual machine to be bound is screened out from the NUMA nodes in the NUMA architecture.
4. The method according to claim 3, characterized in that The allocatable information also includes the number of allocatable CPUs in each CPU group of the corresponding NUMA node; The determining whether a third NUMA node exists includes: Each of the first NUMA nodes is traversed to determine whether there is a first NUMA node in the first NUMA nodes where the number of allocatable CPUs of at least a first number of CPU groups meets the first CPU number sub-requirement.
5. The method according to claim 1, characterized in that If the judgment result is no, then after continuing to disassemble the first CPU quantity sub-requirement, the method further includes: If, after the first CPU quantity sub-requirement is decomposed into the first minimum unit, there is no third NUMA node in the first NUMA node, decompose the memory requirement and the CPU quantity requirement of the to-be-bound virtual machine into a second number of memory sub-requirements and a second number of second CPU quantity sub-requirements; the memory capacity corresponding to each of the memory sub-requirements is the same, and the number of CPUs corresponding to each of the second CPU quantity sub-requirements is the same; Determine whether there are at least a second number of fourth NUMA nodes in the NUMA architecture, where the fourth NUMA node refers to a NUMA node whose allocatable memory meets the memory sub-requirement and whose allocatable number of CPUs in the CPU grouping meets the second CPU number sub-requirement; If the judgment result is no, continue to disassemble the memory sub-requirement and the second CPU quantity sub-requirement until there are at least a third number of fourth NUMA nodes in the first NUMA node; the third number refers to the number of the disassembled memory sub-requirement or the second CPU quantity sub-requirement; Filtering at least a third number of fifth NUMA nodes whose distances between NUMA nodes are less than a preset distance threshold from the fourth NUMA nodes; Bind the to-be-bound virtual machine to a third number of the nearest fifth NUMA nodes.
6. The method according to claim 5, characterized in that If there are no at least a third number of fifth NUMA nodes among the fourth NUMA nodes whose distances between NUMA nodes are less than a preset distance threshold, after decomposing the memory requirement and the CPU quantity requirement of the to-be-bound virtual machine into a second number of memory sub-requirements and a second number of second CPU quantity sub-requirements, the method further includes: Filter out a second number of sixth NUMA nodes from the NUMA architecture, the distance between NUMA nodes being not less than a preset distance threshold, the sixth NUMA node being a NUMA node whose allocatable memory satisfies the memory sub-requirement and whose allocatable number of CPUs in a CPU group satisfies the second CPU number sub-requirement; Bind the to-be-bound virtual machine to a second number of sixth NUMA nodes.
7. The method according to claim 6, characterized in that If there is no second number of sixth NUMA nodes in the NUMA architecture whose distances between NUMA nodes are not less than a preset distance threshold, the method further includes: The virtual machine to be bound is randomly bound to a NUMA node in the NUMA architecture.
8. A virtual machine CPU binding device, characterized in that: include: A disassembling unit is used for, in response to the absence of a second NUMA node, disassembling the CPU quantity requirement of the virtual machine to be bound into a first number of first CPU quantity sub-requirements; each of the NUMA nodes includes at least one CPU group, and the second NUMA node refers to a first NUMA node with at least one CPU group that can meet the CPU quantity requirement of the virtual machine to be bound; A determination unit, configured to determine whether there is a third NUMA node; the third NUMA node refers to a first NUMA node having at least a first number of CPU groups that can meet the first CPU number sub-requirement; a re-disassembly unit, configured to, if the judgment result is no, continue to disassemble the first CPU quantity sub-requirement until a third NUMA node exists in the first NUMA node; The binding unit is used to bind the virtual machine to be bound to the corresponding third NUMA node with the least number of disassembly times.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 7.