P
US10216530B2ActiveUtilityPatentIndex 40

Method for mapping between virtual CPU and physical CPU and electronic device

Assignee: HUAWEI TECH CO LTDPriority: Jun 12, 2014Filed: Dec 12, 2016Granted: Feb 26, 2019
Est. expiryJun 12, 2034(~7.9 yrs left)· nominal 20-yr term from priority
Inventors:LI JIANGUAN HAIBINGGU QIANG
G06F 2009/45583G06F 9/45533G06F 2009/4557G06F 9/45558G06F 13/4234
40
PatentIndex Score
0
Cited by
17
References
14
Claims

Abstract

A method for mapping between a virtual central processing unit (CPU) and a physical CPU. The method includes obtaining, by a virtual machine manager, a set of to-be-mapped first virtual CPUs in a current time period and a first physical CPU that has fewest to-be-run tasks, obtaining, by the virtual machine manager, a first characteristic value of each first virtual CPU in the set of first virtual CPUs and a second characteristic value of the first physical CPU, obtaining, by the virtual machine manager from all the first characteristic values, a target characteristic value that matches the second characteristic value, and mapping a target virtual CPU corresponding to the target characteristic value to the first physical CPU for running. By means of the foregoing technical solutions, resource contention and a decrease in overall system performance are avoided when mapping a virtual CPU to a physical CPU.

Claims

exact text as granted — not AI-modified
What is claimed is: 
     
       1. A method for mapping between a virtual central processing unit (CPU) and a physical CPU, the method being applied to a multi-core system, the multi-core system comprising at least two physical CPUs, a virtual machine manager, and at least one virtual machine, the at least one virtual machine comprising at least two virtual CPUs, and the method comprising:
 obtaining, by the virtual machine manager, a set of to-be-mapped first virtual CPUs from the at least two virtual CPUs in a current time period; 
 obtaining, from the at least two physical CPUs, a first physical CPU that has a fewest to-be-run tasks; 
 obtaining, by the virtual machine manager, a first attribute value of each first virtual CPU in the set of first virtual CPUs and a second attribute value of the first physical CPU, the first attribute value of each first virtual CPU representing an attribute of a physical CPU to which the first virtual CPU is mapped in a previous time period, and the second attribute value representing an attribute of the first physical CPU in the previous time period; 
 obtaining, by the virtual machine manager from all the first attribute values, a target attribute value that matches the second attribute value by:
 obtaining, according to the second attribute value and the first attribute value of each first virtual CPU, a similarity value between the second attribute value and the first attribute value of each first virtual CPU; 
 obtaining a first attribute value corresponding to a similarity value that is in a specified value range in all similarity values; and 
 using the first attribute value as the target attribute value that matches the second attribute value; and 
 
 mapping a target virtual CPU corresponding to the target attribute value to the first physical CPU for running. 
 
     
     
       2. The method of  claim 1 , wherein obtaining, according to the second attribute value and the first attribute value of each first virtual CPU, the similarity value between the second attribute value and the first attribute value of each first virtual CPU comprises obtaining the similarity value according to
     D   Δab =Σ( r   aj   −r   bj ) 2   ,r   aj   ∈R   a   ,R   bj   ∈R   b ,
 
 
       D Δab  indicating the similarity value, R a  indicating a first attribute value of a first virtual CPU, R b  indicating the second attribute value, r aj  and r bj  respectively being any parameter in R a  and any parameter in R b  that correspond to each other, and a first attribute value corresponding to a similarity value that is less than a specified threshold in all the similarity values being the target attribute value. 
     
     
       3. The method of  claim 1 , wherein obtaining, according to the second attribute value and the first attribute value of each first virtual CPU, the similarity value between the second attribute value and the first attribute value of each first virtual CPU comprises obtaining the similarity value according to
     D   Δab =Σ( r   ai   −r   bi ) 2 +[( r   aK   −r   bK )/ r   max ] 2   ,r   ai   ,r   aK   ∈R   a   ,r   bi   ,r   bK   ∈R   b ,
 
 
       D Δab  indicating the similarity value, R a  indicating a first attribute value of a first virtual CPU, R b  indicating the second attribute value, r aK  being the quantity of the network input/output (I/O) interrupts on the virtual machine to which the first virtual CPU belongs in R a , r bK  being the quantity of the network I/O interrupts of the physical CPU on a physical host in R b , r ai  and r bi  respectively being any parameter in R a  and any parameter in R b  that correspond to each other except r aK  and r bK , and a first attribute value corresponding to a similarity value that is less than a specified threshold in all the similarity values being the target attribute value. 
     
     
       4. The method of  claim 1 , wherein obtaining, according to the second attribute value and the first attribute value of each first virtual CPU, the similarity value between the second attribute value and the first attribute value of each first virtual CPU comprises obtaining the similarity value according to
     D   Δab =Σ½[( r   aj   +r   bj )−| r   aj   −r   bj   |],r   aj   ∈R   a   ,r   bj   ∈R   b ,
 
 
       D Δab  indicating the similarity value, R a  indicating a first attribute value of a first virtual CPU, R b  indicating the second attribute value, r aj  and r bj  respectively being any parameter in R a  and any parameter in R b  that correspond to each other, and a first attribute value corresponding to a similarity value that is greater than a specified threshold in all the similarity values being the target attribute value. 
     
     
       5. A method for mapping between a virtual central processing unit (CPU) and a physical CPU, the method being applied to a multi-core system, the multi-core system comprising at least two physical CPUs, a virtual machine manager, and at least one virtual machine, the at least one virtual machine comprising at least two virtual CPUs, and the method comprising:
 obtaining, by the virtual machine manager, a set of to-be-mapped first virtual CPUs from the at least two virtual CPUs in a current time period; 
 obtaining, from the at least two physical CPUs, a first physical CPU that has a fewest to-be-run tasks; 
 obtaining, by the virtual machine manager, a first attribute value of each first virtual CPU in the set of first virtual CPUs and a second attribute value of the first physical CPU, the first attribute value of each first virtual CPU representing an attribute of a physical CPU to which the first virtual CPU is mapped in a previous time period, the first attribute value of each first virtual CPU comprising virtual CPU utilization of each first virtual CPU, memory bus utilization of the virtual machine to which the first virtual CPU belongs, and a quantity of network input/output (I/O) interrupts on the virtual machine to which the first virtual CPU belongs in the previous time period, the second attribute value representing an attribute of the first physical CPU in the previous time period, and the second attribute value of the first physical CPU comprising physical CPU utilization of the first physical CPU, memory bus utilization of the first physical CPU on a physical host, and a quantity of network I/O interrupts of the first physical CPU on the physical host in the previous time period; 
 obtaining, by the virtual machine manager from all the first attribute values, a target attribute value that matches the second attribute value; and 
 mapping a target virtual CPU corresponding to the target attribute value to the first physical CPU for running. 
 
     
     
       6. The method of  claim 1 , further comprising:
 obtaining a maximum frequency and a minimum frequency of a physical CPU of the at least two physical CPUs when the physical CPU runs; 
 obtaining a maximum memory bus utilization and a minimum memory bus utilization of the physical CPU when running on the physical CPU; 
 obtaining, according to physical CPU utilization, the maximum frequency, the minimum frequency, the maximum memory bus utilization, and the minimum memory bus utilization, a target frequency; and 
 adjusting a current working frequency of the physical CPU to the target frequency. 
 
     
     
       7. The method of  claim 6 , wherein the target frequency is obtained) according to 
       
         
           
             
               
                 
                   s 
                   ⁡ 
                   
                     ( 
                     
                       R 
                       cpu 
                     
                     ) 
                   
                 
                 = 
                 
                   
                     
                       
                         R 
                         cpu 
                       
                       
                         
                           R 
                           busmax 
                         
                         - 
                         
                           R 
                           busmin 
                         
                       
                     
                     ⁢ 
                     
                       ( 
                       
                         
                           f 
                           max 
                         
                         - 
                         
                           f 
                           min 
                         
                       
                       ) 
                     
                     ⁢ 
                     
                       ( 
                       
                         
                           R 
                           busmax 
                         
                         - 
                         
                           R 
                           bus 
                         
                       
                       ) 
                     
                   
                   + 
                   
                     f 
                     min 
                   
                 
               
               , 
             
           
         
       
       s(R cpu ) being the target frequency, R cpu  being the physical CPU utilization, f max  being the maximum frequency of the physical CPU, f min  being the minimum frequency of the physical CPU, R busmax  being the maximum memory bus utilization, and R busmin  being the minimum memory bus utilization. 
     
     
       8. A device comprising:
 a memory configured to store instructions; and 
 a processor coupled to the memory and configured to execute the instructions to:
 obtain a set of to-be-mapped first virtual central processing units (CPUs) from at least two virtual CPUs in a current time period; 
 obtain, from at least two physical CPUs, a first physical CPU that has a fewest to-be-run tasks; 
 obtain a first attribute value of each first virtual CPU in the set of first virtual CPUs and a second attribute value of the first physical CPU, the first attribute value of each first virtual CPU representing an attribute of a physical CPU to which the first virtual CPU is mapped in a previous time period, and the second attribute value representing an attribute of the first physical CPU in the previous time period; 
 
 obtain a target attribute value that matches the second attribute value from all the first attribute values by:
 obtaining a similarity value between the second attribute value and the first attribute value of each first virtual CPU according to the second attribute value and the first attribute value of each first virtual CPU; 
 obtaining a first attribute value corresponding to a similarity value that is in a specified value range in all similarity values; and 
 using the first attribute value as the target attribute value that matches the second attribute value; and 
 
 map a target virtual CPU corresponding to the target attribute value to the first physical CPU for running. 
 
     
     
       9. The device of  claim 8 , wherein the processor is further configured to obtain the similarity value according to
     D   Δab =Σ( r   aj   −r   bj ) 2   ,r   aj   ∈R   a   ,r   bj   ∈R   b ,
 
 
       D Δab  indicating the similarity value, R a  indicating a first attribute value of a first virtual CPU, R b  indicating the second attribute value, r aj  and r bj  respectively being any parameter in R a  and any parameter in R b  that correspond to each other, and a first attribute value corresponding to a similarity value that is less than a specified threshold in all the similarity values being the target attribute value. 
     
     
       10. The device of  claim 8 , wherein the processor is further configured to obtain the similarity value according to
     D   Δab =Σ( r   ai   −r   bi ) 2 +[( r   aK   −r   bK )/ r   max ] 2   ,r   ai   ,r   aK   ∈R   a   ,r   bi   ,r   bK   ∈R   b ,
 
 
       D Δab  indicating the similarity value, R a  indicating a first attribute value of a first virtual CPU, R b  indicating the second attribute value, r aK  being the quantity of the network input/output (I/O) interrupts on a virtual machine to which the first virtual CPU belongs in R a , r bK  being the quantity of the network I/O interrupts of the physical CPU on a physical host in R b , r ai  and r bi  respectively being any parameter in R a  and any parameter in R b  that correspond to each other except r aK  and r bK , and a first attribute value corresponding to a similarity value that is less than a specified threshold in all the similarity values being the target attribute value. 
     
     
       11. The device of  claim 8 , wherein the processor is further configured to obtain the similarity value according to
     D   Δab =Σ½[( r   aj   +r   bj )−| r   aj   −r   bj   |],r   aj   ∈R   a   ,r   bj   ∈R   b ,
 
 
       D Δab  indicating the similarity value, R a  indicating a first attribute value of a first virtual CPU, R b  indicating the second attribute value, r aj  and r bj  respectively being any parameter in R a  and any parameter in R b  that correspond to each other, and a first attribute value corresponding to a similarity value that is greater than a specified threshold in all the similarity values being the target attribute value. 
     
     
       12. The device of  claim 8 , wherein the first attribute value of each first virtual CPU comprises virtual CPU utilization of each first virtual CPU, memory bus utilization of a virtual machine to which the first virtual CPU belongs, and a quantity of network input/output (I/O) interrupts on the virtual machine to which the first virtual CPU belongs in the previous time period, and the second attribute value of the first physical CPU comprising physical CPU utilization of the first physical CPU, memory bus utilization of the first physical CPU on a physical host, and a quantity of network I/O interrupts of the first physical CPU on the physical host in the previous time period. 
     
     
       13. The device of  claim 8 , wherein the processor is further configured to:
 obtain a maximum frequency and a minimum frequency of a physical CPU of the at least two physical CPUs when the physical CPU runs; 
 obtain a maximum memory bus utilization and a minimum memory bus utilization of the physical CPU when running on the physical CPU; 
 obtain a target frequency according to physical CPU utilization, the maximum frequency, the minimum frequency, the maximum memory bus utilization, and the minimum memory bus utilization; and 
 adjust a current working frequency of the physical CPU to the target frequency. 
 
     
     
       14. The device of  claim 13 , wherein the target frequency is obtained according to 
       
         
           
             
               
                 
                   s 
                   ⁡ 
                   
                     ( 
                     
                       R 
                       cpu 
                     
                     ) 
                   
                 
                 = 
                 
                   
                     
                       
                         R 
                         cpu 
                       
                       
                         
                           R 
                           busmax 
                         
                         - 
                         
                           R 
                           busmin 
                         
                       
                     
                     ⁢ 
                     
                       ( 
                       
                         
                           f 
                           max 
                         
                         - 
                         
                           f 
                           min 
                         
                       
                       ) 
                     
                     ⁢ 
                     
                       ( 
                       
                         
                           R 
                           busmax 
                         
                         - 
                         
                           R 
                           bus 
                         
                       
                       ) 
                     
                   
                   + 
                   
                     f 
                     min 
                   
                 
               
               , 
             
           
         
       
       s(R cpu ) is the target frequency, R cpu  is the physical CPU utilization, f max  is the maximum frequency of the physical CPU, f min  is the minimum frequency of the physical CPU, R busmax  is the maximum memory bus utilization, and R busmin  is the minimum memory bus utilization.

Cited by (0)

No later patents cite this yet.

References (0)

No backward citations on record.