CN116795554A - Virtual network card queue allocation method and readable storage medium - Google Patents
Virtual network card queue allocation method and readable storage medium Download PDFInfo
- Publication number
- CN116795554A CN116795554A CN202311054259.XA CN202311054259A CN116795554A CN 116795554 A CN116795554 A CN 116795554A CN 202311054259 A CN202311054259 A CN 202311054259A CN 116795554 A CN116795554 A CN 116795554A
- Authority
- CN
- China
- Prior art keywords
- queue
- virtual network
- allocation
- pci
- equipment
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 64
- 238000013439 planning Methods 0.000 claims abstract description 53
- 230000008569 process Effects 0.000 claims abstract description 18
- 238000005457 optimization Methods 0.000 claims description 9
- 238000012163 sequencing technique Methods 0.000 claims description 4
- 238000013468 resource allocation Methods 0.000 abstract description 5
- 239000011159 matrix material Substances 0.000 description 20
- 238000013146 percutaneous coronary intervention Methods 0.000 description 8
- 239000000523 sample Substances 0.000 description 8
- 230000008859 change Effects 0.000 description 5
- 238000010586 diagram Methods 0.000 description 5
- 230000000694 effects Effects 0.000 description 4
- 238000007726 management method Methods 0.000 description 4
- 208000035217 Ring chromosome 1 syndrome Diseases 0.000 description 3
- 208000032825 Ring chromosome 2 syndrome Diseases 0.000 description 3
- 208000032826 Ring chromosome 3 syndrome Diseases 0.000 description 3
- 208000002991 Ring chromosome 4 syndrome Diseases 0.000 description 3
- 208000033641 Ring chromosome 5 syndrome Diseases 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000002093 peripheral effect Effects 0.000 description 3
- 239000011800 void material Substances 0.000 description 3
- 238000013459 approach Methods 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 230000008878 coupling Effects 0.000 description 2
- 238000010168 coupling process Methods 0.000 description 2
- 238000005859 coupling reaction Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000004458 analytical method Methods 0.000 description 1
- 238000013528 artificial neural network Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000006185 dispersion Substances 0.000 description 1
- 230000002068 genetic effect Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000013138 pruning Methods 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention provides a virtual network card queue allocation method and a readable storage medium. The virtual network card queue allocation method comprises the following steps: before the execution of the business logic, the following steps are performed: acquiring global queue information of a queue which can be provided by PCI equipment; acquiring planning information of a queue required by virtual network equipment; matching based on the global queue information and the planning information, and obtaining a queue allocation result, wherein in the queue allocation result, at least one queue allocated to the virtual network device is from at least two PCI devices; and performing queue allocation based on the queue allocation result. By the configuration, decision information of queue allocation is expanded, so that the queue allocation process is more flexible, and the virtual network equipment can acquire related queues according to own requirements, so that the problems that in the prior art, the queue resource allocation flexibility is poor, and the number of the queues is insufficient under specific conditions are solved.
Description
Technical Field
The invention belongs to the technical field of communication, and particularly relates to a virtual network card queue allocation method and a readable storage medium.
Background
Currently, cloud computing can provide a user-defined service with reliability, maximized resource utilization, and is a brand-new distributed computing mode. Cloud computing platforms are mostly based on client VM (Virtual Machine) technology, and application performance running on cloud computing platforms is quite dependent on performance between platform client VMs. Thus, high performance network connections, such as ethernet, have begun to be deployed in cloud computing platforms. While building a high performance and highly scalable virtualization framework is one of the important challenges for virtual cloud computing platforms. SR-IOV (Single Root I/O Virtualization) is a Virtualization standard formulated by PCI-SIG (Peripheral Component Interconnect Special Interest Group, a special interest group for peripheral component interconnect, an association dedicated to development and enhancement of PCI standards), and is suitable for a high-performance network environment. By utilizing the direct I/O technology, the performance overhead caused by the duplication of additional data packets and the virtual network switch is eliminated, and the performance approaching to the physical machine is realized, so that the virtual cloud platform is becoming popular.
An SR-IOV device has one or more physical devices (Physical Function, PF) which is a standard PCI (Peripheral Component Interconnect ) device. Each PF may create multiple Virtual Functions (VFs), which are "lightweight" PCI devices. Each VF has key resources for receiving and transmitting data packets, such as a receiving and transmitting queue, a DMA channel and the like; while sharing most of the other non-critical device resources with other VFs. Each VF has the ability to send and receive packets independently. If a VF is assigned to a client VM, the client has the ability to send and receive packets directly using the VF. Most importantly, the client I/O operations via VF do not require intervention by the client VM monitor, which is one of the advantages of direct I/O technology.
In practice, the SR-IOV network card will evenly allocate the same number of queue resources to the client VM according to its own performance while supporting the maximum number of clients. For example, a PCIe physical network card supports a maximum of 128 queue pairs (RX/TX ring) and a maximum of 64 VFs, then 2 queue pairs are allocated per VF on average, i.e., a maximum of 2 queue pairs are used per client.
The allocation and management mode of the queue resources is simple and feasible, and can meet the use requirements in many cases. However, this approach also suffers from poor flexibility and limited number of queues supported by each client. For some special scenarios, there may be an insufficient number of client queues.
Disclosure of Invention
The invention aims to provide a virtual network card queue allocation method and a readable storage medium, which are used for solving the problems of poor queue resource allocation flexibility and insufficient number of queues under specific conditions in the prior art.
In order to solve the technical problems, the invention provides a virtual network card queue allocation method, which comprises the following steps: before the execution of the business logic, the following steps are performed: acquiring global queue information of a queue which can be provided by PCI equipment; acquiring planning information of a queue required by virtual network equipment; wherein the planning information includes: the number of queues required by the virtual network device; matching based on the global queue information and the planning information, and obtaining a queue allocation result, wherein in the queue allocation result, at least one queue allocated to the virtual network device is from at least two PCI devices; and performing queue allocation based on the queue allocation result; the step of matching based on the global queue information and the planning information includes: and allocating the idle queues of the PCI equipment according to the number of the queues required by the virtual network equipment.
Optionally, the planning information further includes: the priority corresponding to the virtual network device and whether the virtual network device supports cross PCI device allocation.
The step of matching based on the global queue information and the planning information includes:
and numbering the PCI equipment.
And sequencing the virtual network devices, wherein the virtual network devices with higher priorities are more advanced, and the virtual network devices which do not support cross PCI device allocation are more advanced in the same priority.
According to the sequencing result of the virtual network device, sequentially executing: if the current virtual network equipment supports cross PCI equipment allocation, selecting the idle queue of the PCI equipment with the minimum number of idle queues to be allocated to the virtual network equipment, and circularly executing the process until the number of the queues allocated to the virtual network equipment is the same as the number of the queues required by the virtual network equipment, and switching to the next virtual network equipment; and if the current virtual network equipment does not support cross PCI equipment allocation, selecting the idle queue of the PCI equipment with the minimum number, which still has idle queues and the number of which is greater than or equal to the number of the queues required by the virtual network equipment, to allocate the virtual network equipment, and switching to the next virtual network equipment.
And if all the virtual network devices are allocated, or the idle queues of the PCI devices cannot meet any virtual network device which is not allocated yet, ending allocation.
Optionally, the planning information further includes: whether the virtual network device supports cross PCI device allocation.
The step of matching based on the global queue information and the planning information includes:
and distributing the queues according to a preset sequence.
If the virtual network equipment is completely allocated, or the idle queues of the PCI equipment are completely allocated, the allocation is finished; otherwise, backtracking the allocation result of the previous queue and modifying the allocation result to be a result which is not backtracked, and backtracking to the previous queue if all possible allocation results of the previous queue are backtracked.
And if all possible allocation results of all queues are traced back, interrupting the allocation process and alarming.
Optionally, the planning information further includes: the virtual network device assigns weights.
The step of matching based on the global queue information and the planning information includes: and taking the total allocation weight corresponding to the queue allocation result as an optimization target, and acquiring the queue allocation result based on an optimization algorithm.
Optionally, the step of matching based on the global queue information and the planning information includes: the number of the virtual network devices is regarded as the number of articles, the total number of the queues which can be provided by the PCI devices is regarded as knapsack capacity, the number of the queues which are needed by each virtual network device is regarded as the weight corresponding to the articles, the allocation weight of each virtual network device is regarded as the value, the 0/1 knapsack problem is solved based on a dynamic programming algorithm, and the result is converted into the queue allocation result.
Optionally, the virtual network card queue allocation method further includes:
the use state of each queue is recorded, wherein the use state comprises allocated and unallocated.
In the execution process of the business logic, the following steps are executed: when the virtual network device exits, the use state of the corresponding queue is set to be unassigned; and selecting an unassigned queue to be assigned to the new virtual network device when the new virtual network device is accessed.
Optionally, the virtual network card queue allocation method further includes: and in the execution process of the service logic, periodically transferring the queue of the PCI device with the least common queue in the different PCI devices corresponding to the same virtual network device to other PCI devices in the corresponding different PCI devices.
Optionally, the virtual network card queue allocation method further includes: during execution of the business logic, the following steps are periodically executed:
and acquiring global queue information of a queue which can be provided by the PCI equipment.
And acquiring planning information of a queue required by the virtual network equipment.
And matching based on the global queue information and the planning information to obtain the queue allocation result.
And comparing the new queue allocation result with the actual queue allocation situation, calculating a reset value, and if the reset value is larger than a preset threshold, setting a planning task to re-register the virtual network equipment according to the new queue allocation result at a preset time point.
In order to solve the technical problem, the invention also provides a readable storage medium, wherein the readable storage medium stores a program, and the virtual network card queue allocation method is executed when the program runs.
Compared with the prior art, the virtual network card queue allocation method and the readable storage medium provided by the invention comprise the following steps: before the execution of the business logic, the following steps are performed: acquiring global queue information of a queue which can be provided by PCI equipment; acquiring planning information of a queue required by virtual network equipment; matching based on the global queue information and the planning information, and obtaining a queue allocation result, wherein in the queue allocation result, at least one queue allocated to the virtual network device is from at least two PCI devices; and performing queue allocation based on the queue allocation result. By the configuration, decision information of queue allocation is expanded, so that the queue allocation process is more flexible, and the virtual network equipment can acquire related queues according to own requirements, so that the problems that in the prior art, the queue resource allocation flexibility is poor, and the number of the queues is insufficient under specific conditions are solved.
Drawings
Those of ordinary skill in the art will appreciate that the figures are provided for a better understanding of the present invention and do not constitute any limitation on the scope of the present invention. Wherein:
FIG. 1 is a flow chart of a virtual network card queue allocation method according to an embodiment of the invention;
FIG. 2a is a prior art registration process for PCI devices;
FIG. 2b is a graphical illustration of a prior art queue allocation result under one operating condition;
FIG. 2c is a registration flow of a PCI device according to an embodiment of the present invention;
FIG. 2d is a graph showing queue allocation results under the same conditions as FIG. 2 b;
FIG. 3a is a diagram illustrating an allocation result of a virtual network card queue allocation method according to an embodiment of the present invention;
FIG. 3b is a diagram illustrating a virtual network card queue allocation method according to another embodiment of the present invention;
fig. 4a is a schematic diagram of an allocation result of a virtual network card queue allocation method according to an embodiment of the present invention at a time one;
fig. 4b is a schematic diagram of an allocation result of a virtual network card queue allocation method according to an embodiment of the present invention at a time two;
fig. 4c is a schematic diagram of an allocation result of a virtual network card queue allocation method at a time three according to an embodiment of the present invention.
Detailed Description
The invention will be described in further detail with reference to the drawings and the specific embodiments thereof in order to make the objects, advantages and features of the invention more apparent. It should be noted that the drawings are in a very simplified form and are not drawn to scale, merely for convenience and clarity in aiding in the description of embodiments of the invention. Furthermore, the structures shown in the drawings are often part of actual structures. In particular, the drawings are shown with different emphasis instead being placed upon illustrating the various embodiments.
As used in this disclosure, the singular forms "a," "an," and "the" include plural referents, the term "or" are generally used in the sense of comprising "and/or" and the term "several" are generally used in the sense of comprising "at least one," the term "at least two" are generally used in the sense of comprising "two or more," and the term "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying any relative importance or number of features indicated. Thus, a feature defining "first," "second," "third," or "third" may explicitly or implicitly include one or at least two such features, with "one end" and "another end" and "proximal end" and "distal end" generally referring to the respective two portions, including not only the endpoints, but also the terms "mounted," "connected," "coupled," and "connected" are to be construed broadly, e.g., as being either a fixed connection, a removable connection, or as being integral therewith; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communicated with the inside of two elements or the interaction relationship of the two elements. Furthermore, as used in this disclosure, an element disposed on another element generally only refers to a connection, coupling, cooperation or transmission between two elements, and the connection, coupling, cooperation or transmission between two elements may be direct or indirect through intermediate elements, and should not be construed as indicating or implying any spatial positional relationship between the two elements, i.e., an element may be in any orientation, such as inside, outside, above, below, or on one side, of the other element unless the context clearly indicates otherwise. The specific meaning of the above terms in the present invention can be understood by those of ordinary skill in the art according to the specific circumstances.
The invention provides a virtual network card queue allocation method and a readable storage medium, which are used for solving the problems of poor queue resource allocation flexibility and insufficient number of queues under specific conditions in the prior art.
The following description refers to the accompanying drawings.
Referring to fig. 1, the present invention provides a virtual network card queue allocation method, which includes:
before the execution of the business logic, the following steps are performed: s11, obtaining global queue information of a queue which can be provided by the PCI equipment. S12, acquiring planning information of a queue required by the virtual network equipment. And S13, matching is carried out based on the global queue information and the planning information, and a queue allocation result is obtained, wherein the queues allocated to at least one virtual network device in the queue allocation result come from at least two PCI devices. And S14, performing queue allocation based on the queue allocation result.
Business logic refers to the problem that the system is to solve, e.g., the system is to handle accounting, then business logic refers to accounting logic and related programs and algorithms. Since the concrete scheme of the business logic does not affect the practical effect of the invention, the related content describing the business logic is not developed.
The technical effects mentioned in step S13 can be understood with reference to fig. 2a to 2 d.
In the prior art, the code of the network driver is as follows:
ixgbe_init_module(void) {
……
ret=pci_register_driver (& ixgbe_driver);// registration pci network
……
}
static struct pci_driver ixgbe_driver = {
//……
The probe function performed when matching the pc i device,
the register_netdev is executed in the probe to register the network device
.probe = ixgbe_probe,
//……
};
The logic of the code is shown in fig. 2a, and in the prior art, each time a PCI device is found, a new network device (net-dev) is registered. Thus, according to a prior plan, there can be only two ring pairs per PCI device, resulting in a maximum of two ring pairs per net-dev. Thus, in some cases, the number of ring pairs cannot be satisfied.
FIG. 2b shows the result of the code operation under one operating condition. As can be seen from fig. 2b, although there are two PCI devices, corresponding to two ring pairs respectively, there may be a total of 4 ring pairs. However, since one net-dev is registered more, the number of ring pairs of a single net-dev can only be 2, and more requirements cannot be satisfied.
For example, in one common practical scenario: one virtual machine VM of the system has 4 CPU cores. Typically, binding a ring pair by a CPU core is the most efficient solution to use. However, there is a limitation here that there are only at most two ring pairs of one net-dev. This results in a virtual machine VM with 4 CPU cores, at most only two CPU cores operating simultaneously. The other two because of the lack of binding rings cannot work. At this time, the problem of insufficient ring pairs of a net-dev virtual portal needs to be solved.
In one embodiment of the present invention, the code of the network driver is as follows:
tsrn10_init_module(void) {
//……
ret=pci_register_driver (& tsrn10_driver);// registration PCI network
//……
generating_net_adapter_list ()// registering network device according to all PCI cards scanned
}
static struct pci_driver tsrn10_pci_driver = {
//……
The probe function performed when matching the pc i device,
only adding the pi device into the same global pi device list in the// probe;
the/(probe) function does not register with the network device
.probe = pci_probe_one,
//……
};
The code run logic is shown in FIG. 2c, and the modified code flow is realized by firstly storing and collecting the scanned PCI devices. And when the initialization program is required to be ended, registering PCI equipment meeting the conditions into one or more net-devs according to the required ring pair number. The two groups of codes are the biggest difference that the former is directly registered, the latter firstly counts PCI equipment and stores the PCI equipment as a global list, and then carries out global planning according to the list to finally obtain a queue allocation result.
It will be appreciated that, based on the design concept of the present embodiment, it is not necessary whether the PCI device needs to be stored as a global list, and the problem can be solved as long as the relevant information can be stored using a suitable data structure.
FIG. 2d shows the result of the code operation of the present embodiment under the same operating conditions as FIG. 2b, and as can be seen from FIG. 2d, one net-dev network device corresponds to two PCI devices. Thus enabling a single net-dev network device to use 4 ring pairs simultaneously. The number of ring pairs which can be used by increasing a single net-dev is satisfied. The configuration and the use of the whole system are more flexible.
For the example of the four-core CPU mentioned earlier, it is obvious that the allocation result of this embodiment can meet the working requirement, but the scheme of the prior art cannot meet the working requirement, and this embodiment has a better effect. As can be appreciated based on the content of fig. 2 d: the technical effects of the present embodiment include: and in the queue allocation result, at least one queue allocated to the virtual network device is from at least two PCI devices.
The above procedure may also be understood as that the planning information includes: the number of queues required by the virtual network device.
The step of matching based on the global queue information and the planning information includes: and sequentially distributing the idle queues of the PCI equipment according to the number of the queues required by the virtual network equipment.
This is a simpler case, and more complex case is analyzed as follows.
In order to improve the effectiveness of the allocation, the content of the planning information needs to be expanded.
In an embodiment, the planning information includes: the method comprises the steps of determining the number of queues required by the virtual network device, the priority corresponding to the virtual network device and whether the virtual network device supports cross PCI device allocation.
The step of matching based on the global queue information and the planning information includes:
s101, numbering the PCI equipment.
And S102, sorting the virtual network devices, wherein the virtual network devices with higher priorities are more advanced, and the virtual network devices which do not support cross PCI device allocation are more advanced in the same priority.
S103, according to the sorting result of the virtual network equipment, sequentially executing: if the current virtual network equipment supports cross PCI equipment allocation, selecting the idle queue of the PCI equipment with the minimum number of idle queues to be allocated to the virtual network equipment, and circularly executing the process until the number of the queues allocated to the virtual network equipment is the same as the number of the queues required by the virtual network equipment, and switching to the next virtual network equipment; and if the current virtual network equipment does not support cross PCI equipment allocation, selecting the idle queue of the PCI equipment with the minimum number, which still has idle queues and the number of which is greater than or equal to the number of the queues required by the virtual network equipment, to allocate the virtual network equipment, and switching to the next virtual network equipment.
And S104, if all the virtual network devices are allocated, or all the idle queues of the PCI devices are allocated, or the idle queues of the PCI devices cannot meet any one of the virtual network devices which are not allocated yet, ending allocation.
Regarding the case where "the free queue of the PCI device cannot satisfy any one of the virtual network devices that have not been allocated yet", it is exemplified that there is currently one free queue for each of PCI-device-5 and PCI-device-6 remaining, and there is one net-dev requiring two queues remaining. However, this net-dev does not support cross PCI device allocation, so there is no match between the two, and the allocation is considered to be ended.
The following logic can also be added on the basis of the scheme: s105, periodically updating the numbers of the PCI devices, so that the numbers of the PCI devices with smaller number of remaining idle queues are arranged earlier, as shown in table 1.
Table 1 PCI device idle queue table
In the case shown in table 1, under the logic of S105, the number of the B device needs to be advanced (for example, the number of the B device is changed to 1), so that the subsequent allocation work preferentially runs out of the free queue of the B device to reserve the complete PCI device as much as possible.
With respect to the above logic, the following is illustrated by way of example:
the current planning information is shown in table 2.
TABLE 2 demand matrix
The above-described table, which may also be referred to as a demand matrix, may be stored in the VF driver.
The key field meanings are introduced as follows:
net-dev numbering: each row corresponds to a network device that needs to be registered. The first column is the number of the network device.
The number of queues required: the net-dev requires the number of queues allocated.
Assigning priorities: in the VF driver, queues are allocated in sequence according to the size of the priority. Wherein a larger number indicates a higher priority.
Whether cross-PCI device allocation is supported: if so, then the physical PCI network devices across the floor may be considered when allocating queues; if not, then no queues can be allocated across PCI network devices.
Another data table, called resource matrix, i.e. the global queue information mentioned above, is established for the scanned PCI-device and its own ring pairs, as shown in table 3.
TABLE 3 resource matrix
The conditions shown in tables 2 and 3 were performed as follows.
PCI equipment numbers are obtained according to the default numbers of the system.
2. The virtual network devices are ranked, and the ranked results are shown in table 4.
TABLE 4 ordered demand matrix
3. Consider first net-dev-0, since its priority is 3, the level is highest. Scanning the PCI-device list from beginning to end, and preferentially distributing ring-0 of PCI-device-0 to meet the requirements.
4. Net-dev-1 is then processed because its priority is 2. And scanning the PCI-device list from beginning to end, and preferentially distributing ring-1 of PCI-device-0 and ring-2 of PCI-device-1 to meet the requirements. Note that there is a detail here, because net-dev-1 supports "cross PCI device allocation", only 1 ring pair of PCI-device-0 and PCI-device-1, respectively, will be allocated.
5. Net-dev-2 is processed last because of its lowest priority. And scanning the PCI-device list from beginning to end, and finally distributing the PCI-device list to ring-3 of PCI-device-1 and ring-4 and ring-5 of PCI-device-2 to meet the requirements.
After allocation, the allocation matrix is obtained as shown in table 5.
Table 5 allocation matrix
By looking at the allocation matrix, it can be known that: line 1 (without a header) indicates that ring-0 is assigned to net-dev-2. Lines 2, 3, represent: ring-1, ring-2 are assigned to net-dev-1. Lines 4, 5, 6, represent: ring-3, ring-4, ring-5 are assigned to net-dev-0.
A schematic of the final scheme of the allocation is shown in figure 3 a.
Suppose that changing the contents of table 2 gives table 6: net-dev-1 becomes not supporting "cross PCI device allocation", the allocation result obtained will also change.
TABLE 6 another demand matrix
The allocation algorithm is re-executed, and since net-dev-1 no longer supports cross PCI device allocation, the ring pairs that cause its allocation will change.
After allocation according to the new results, the allocation matrix is obtained as shown in table 7.
TABLE 7 another allocation matrix
By looking at the allocation matrix, it can be known that: line 1 (no header) represents: ring-0 is assigned to net-dev-2; lines 3, 4, represent: ring-2 and ring-3 are distributed to net-dev-1; lines 2, 5, 6, represent: ring-1, ring-4, ring-5 are assigned to net-dev-0.
A specific allocation schematic is shown in fig. 3 b.
The allocation priority may be calculated by an external input or by a related formula, which is not described herein.
The core idea of the above scheme is to use a greedy algorithm in combination with specific planning information to solve the problem, where the greedy algorithm has a time complexity mainly concentrated on the previous ranking, O (n×log N), and a subsequent allocation complexity O (n×m), so that the overall time complexity is O (n×log n+n×m). Wherein N is the number of net-dev, and M is the number of ring pairs.
In certain cases the calculation time requirements for the allocation scheme are low, but the validity requirements for the final allocation result are high, in which case the backtracking algorithm may alternatively be used.
At this time, adjustment is required for the planning information including: the number of queues required by the virtual network device and whether the virtual network device supports cross-PCI device allocation.
The step of matching based on the global queue information and the planning information includes:
and distributing the queues according to a preset sequence.
If the virtual network equipment is completely allocated, or the idle queues of the PCI equipment are completely allocated, the allocation is finished; otherwise, backtracking the allocation result of the previous queue and modifying the allocation result to be a result which is not backtracked, and backtracking to the previous queue if all possible allocation results of the previous queue are backtracked.
And if all possible allocation results of all queues are traced back, interrupting the allocation process and alarming. Specific alarm modes can be set according to actual needs, such as popup window, sending short messages to specific equipment, sounding an alarm, lighting a warning lamp and the like.
The pseudo code is as follows:
void backtracking (ring number to be assigned) {
if (all net-dev are satisfied or all ring pairs are allocated out) {
Storing the result, necessary values and distribution relations;
return;
}
for (select net-dev number i: allocation object of current ring (from 1 to N)) {
Modifying the distribution relation matrix, and distributing ring to be distributed currently to net-dev-i;
backspacing;// recursion
Backtracking, and canceling the modification of the relation matrix by the layer;
}
}
the code of the main program is as follows:
main()
{
defining related variables;
initializing a variable;
for (select net-dev number i: allocation object of current ring (from 1 to N)) {
Modifying the distribution relation matrix, and distributing ring to be distributed currently to net-dev-i;
backspacing;// recursion
Backtracking, and canceling the modification of the relation matrix by the layer;
}
carrying out subsequent treatment;
}
assume that there are N net-dev in the system and M ring pairs.
Each ring may be assigned to N net-dev, with a total of M ring pairs. Equivalently, each scheme requires allocation M times, with N choices at a time. Therefore, the time complexity of the backtracking algorithm is O (N≡M).
Of course, there may be some optimization conditions for pruning: for example,
1. a certain net-dev is allocated enough, and ring pairs are not allocated to the net-dev any more later;
2. all net-dev are already allocated to ring pairs, and the allocation is finished;
3. other constraints.
Therefore, it can solve the problem on a scale limited to the case where N and M are relatively small, for example, each less than 5.
In order to make the allocation process both efficient and effective, it is also possible to set that all net-devs support "cross PCI device allocation"; the "allocation priority" is no longer a mandatory allocation order but instead a "weight allocated" with a certain flexibility.
That is, the planning information includes: the number of queues required by the virtual network device and the assigned weights of the virtual network device. The difference between the allocation weight and the allocation priority is that the allocation weight does not limit the realization that the allocation weight is important and has priority over the realization that the weight is small, and the final selection is confirmed by comprehensively considering the total weight of each allocation scheme. However, the manner in which the weights are assigned may be similar or identical to the manner in which the priorities are assigned.
The step of matching based on the global queue information and the planning information includes: and taking the total allocation weight corresponding to the queue allocation result as an optimization target, and acquiring the queue allocation result based on an optimization algorithm. The optimization algorithm is more selected, such as genetic algorithm, neural network, gradient-based search method, etc.
In general, a dynamic programming algorithm is chosen to solve the optimization problem described above. Specifically, the step of matching based on the global queue information and the planning information includes: the number of the virtual network devices is regarded as the number of articles, the total number of the queues which can be provided by the PCI devices is regarded as knapsack capacity, the number of the queues which are needed by each virtual network device is regarded as the weight corresponding to the articles, the allocation weight of each virtual network device is regarded as the value, the 0/1 knapsack problem is solved based on a dynamic programming algorithm, and the result is converted into the queue allocation result.
The time complexity of dynamic programming is O (N.times.M), the space complexity is O (M), N is the number of net-dev, and M is the number of ring pairs.
With continued reference to fig. 1, the virtual network card queue allocation method further includes:
s20, recording the use state of each queue, wherein the use state comprises allocated and unallocated.
Step S20 occurs both before and during execution of the business logic.
In the execution process of the business logic, the following steps are executed: s31, when the virtual network equipment exits, setting the use state of the corresponding queue to be unassigned; and S32, when a new virtual network device is accessed, selecting an unallocated queue to be allocated to the new virtual network device.
Specifically, in the VF driver, a bitmap may be dynamically maintained, i.e., a bit is used to mark the state (allocated, unallocated) of a ring pair.
1. Initially, the system will distribute a large number of ring pairs to meet all net-dev requirements. At this time, the corresponding bitmap bit is set to 1, indicating that it is allocated.
2. When the system runs, some net-dev network devices are closed, and the corresponding ring pairs are returned. The ring pair corresponding to the bitmap bit is set to 0, indicating that it is not allocated.
3. When new net-dev access ring pairs exist in the system, the unassigned ring pairs can be assigned again, and the corresponding bitmap bit is set to 1 again.
Further, the virtual network card queue allocation method further comprises the following steps: in the service logic executing process, step S40 is executed periodically, and the queue of the PCI device with the least common queue in the different PCI devices corresponding to the same virtual network device is transferred to the other PCI devices in the different PCI devices corresponding to the same virtual network device.
Where "periodically" should be understood as: the steps are performed repeatedly at a predetermined frequency and/or according to a predetermined trigger logic (e.g., each time reclamation and/or allocation is triggered). "corresponding" means that both are contacted by queue
The specific discussion is as follows: in the demand matrix, some net-dev supports the allocation of ring pairs across PCIs, but in general, the more the number of PCI devices across the allocation of ring pairs, the more easily the following problems are caused:
network stability is poor: this is due to the complex underlying structure of the virtual portal. Distributing ring across multiple PCIs can result in poor network stability relative to providing service by a few PCI devices;
management is complex: the number of lightweight PCIs involved in the bottom layer becomes large, so that management becomes complicated.
For the above reasons, in actual use, the allocation of ring pairs using a large number of PCIs is avoided as much as possible. The ring pair is recovered, and the existing structure can be adjusted according to actual conditions, so that the number of cross PCI is reduced. To simplify the algorithm, we do not consider here "whether to support cross PCI" or related "assigned weights", but simply assume that the queue weights belonging to each PCI-device are the same, and then, the sum of the number of PCI's spanned by the assigned queues of each net-dev, i.e., the sum of the number of PCI's spanned by the assigned queues of all net-dev, is reduced as much as possible.
As shown in fig. 4a, is a prior art allocation result.
For some reason, the net port of net-dev-2 is dynamically closed. Thus ring-0 is reclaimed and flags are set to unassigned. The distribution result after closing is shown in fig. 4 b.
It is desirable to make an algorithmic adjustment to obtain the assignment result as in fig. 4 c.
In fig. 4b and 4c, the shaded pattern represents that the device or queue is not actually present.
Comparing FIG. 4b with FIG. 4c, it can be seen that after the adjustment, net-dev-1 is changed from the original PCI device that spans both PCI-device-0 and PCI-device-1 to the PCI device that does not span. That is, only the ring pair on one device of PCI-device-0 is used.
The specific tuning algorithm pseudocode is as follows:
assume that: (x, k, i, j are legal integer subscripts)
ring-x is recovered;
ring-x is originally allocated to net-dev-k, belonging to PCI-device-i;
traversing and searching to obtain that: PCI-device-j has ring pairs of net-dev-k, and the number is the least;
if (number of ring pairs with net-dev-k on PCI-device-i > number of ring pairs with net-dev-k on PCI-device-j)
{
Assigning ring-x to net-dev-k;
meanwhile, closing a ring pair belonging to net-dev-k on PCI-device-j;
}
else
no operation is performed;
the basic idea of the algorithm is to continuously further reduce the number of ring pairs on the PCI-device with the least number of ring pairs of net-dev. Thus, the ring pairs of net-dev are made more and more concentrated. And finally focus on a few PCI-devices.
In addition, the ring pairs are more and more concentrated, so that subsequent ring pairs can be conveniently distributed to new devices when the new net-dev devices exist in the system. (reducing the dispersion of unallocated ring pairs relative to PCI devices) is particularly seen in subsequent "reallocation".
Of course, it is also possible to control whether this operation is performed by an option. If in actual use, closing the ring pair in use is too costly, an option may be set to prohibit the adjustment operation of this portion, or to reduce the adjustment frequency.
Further, the virtual network card queue allocation method further comprises the following steps: during execution of the business logic, the following steps are periodically executed:
s41, obtaining global queue information of a queue which can be provided by the PCI equipment.
S42, acquiring planning information of a queue required by the virtual network equipment.
S43, matching is carried out based on the global queue information and the planning information, and the queue allocation result is obtained.
And S44, comparing the new queue allocation result with the actual queue allocation situation, calculating a reset value, and if the reset value is larger than a preset threshold, setting a planning task to re-register the virtual network equipment according to the new queue allocation result at a preset time point.
Where "periodically" should be understood as: the steps are repeatedly performed at a predetermined frequency and/or according to a predetermined trigger logic (e.g., more than 10 queues for reclamation and new allocation). The "preset time point" may be understood as a fixed time, such as 12 midnight points each day, which is the time point when the user is least active, or a time point when a preset condition is met, such as triggering after the system detects that the number of active users is below a certain threshold. Of course, the concept of "preset time point" may also include: currently, the process is performed. Upon re-registration, the system may be selected to be reset or not, depending on the architecture of the system.
Steps S41 to S43 are actually the same logic as steps S11 to S13, but are distinguished by different steps due to different execution time points, and the same code can be shared when programming is performed.
The reset value can be calculated according to two aspects, namely, the difference between the new queue allocation result and the actual queue allocation situation is on one hand, and when the difference is large, the reset value is also large; on the other hand, the new queue allocation result and the actual queue allocation situation are scored for system performance, for example, scoring is performed according to the number of the cross-PCI queues, and if the difference between the two scoring is not large, the reset value is low. Based on the above ideas, a specific reset value calculation method can be developed, which will not be described here.
Preferably, the step of re-registering the virtual network device by the setting scheduling task according to the new queue allocation result at a preset time point includes: and planning a reset object based on the new queue allocation result and the actual queue allocation situation, so that only a part of the virtual network devices are re-registered. For example, there are currently 6 virtual network devices, the virtual network devices numbered 0-2 are not re-registered, and the virtual network devices numbered 3-5 are reset.
The specific analysis is as follows, through the previous two steps: marking bitmap and adjusting the existing distribution structure. The system has recovered a ring pair.
1. When new net-dev generation exists in the system, the unassigned ring pairs can be assigned again.
2. And similarly, after the ring pair is distributed, updating the bitmap bit corresponding to the ring pair again.
3. During specific allocation, unallocated ring pairs are adopted for allocation. When allocation is unsuccessful or it is desired that the fewer and better the number of cross-PCIs in the system, there are three adjustment schemes (options can be set, self-selection):
(1) Only the unassigned ring pair is used, and no change is made to the existing assignment relationship.
(2) Partial changes to existing allocation relationships may also be supported. And (5) firstly carrying out change adjustment, and then carrying out distribution and use after finishing the change adjustment.
(3) And setting a demand matrix and a resource matrix. Reinitializing the driver program, scanning all PCI-devices, and reallocating ring pairs to net-dev devices.
It is assumed that the allocation uses the greedy algorithm described above. Then, the above three specific allocation methods are unified. We focus on the second approach. The first and third methods are specific examples of the second method.
The specific implementation mode is as follows:
1. when a net-dev-x is newly registered in the system, the number of required ring pairs is k.
2. The net-dev (number n, number 0~n-1) with the ring allocated is ordered from big to small according to the selected ring.
3. Suppose the first net-dev smaller than k is j+1. Then in actual use, the latter j-n-1 net-devs all need to be reassigned.
Initializing, namely directly distributing if the distribution is successful; if the allocation is not successful, the following three strategies are adopted:
when the j value is n, namely, scheme one, the existing allocation relation is not adjusted before use;
When the j value is 0, namely, scheme III, reinitializing, and distributing all net-devs to reduce the number of ring distributed across PCI;
when the j value is between 1-n-1, namely scheme II, trying to adjust part of net-dev to reduce the number of ring distributed across PCI.
The logic described above is only one possible implementation, and the technical solution of the present invention is not limited to the above solution.
The technical key points and beneficial effects of the embodiment are as follows:
1. by modifying the flow of the VF driver, a plurality of PCI-device devices are registered on a lower number of net-devs, so that the problem that the number of ring pairs corresponding to a single net-dev is possibly insufficient is solved.
2. A demand matrix is introduced and an allocation algorithm is given. The ring pair distribution under the complex condition is realized.
3. Defining the distribution conditions and objectives can transform the distribution algorithm into a classical "0-1 knapsack problem" to get the optimal solution at a limited time.
4. And (3) dynamically maintaining a bitmap data structure to finish the distribution and recovery management of ring pairs.
The embodiment also provides a readable storage medium, wherein a program is stored on the readable storage medium, and when the program runs, the virtual network card queue allocation method is executed. The readable storage medium cooperates with an associated controller to solve problems in the prior art.
In summary, the present embodiment provides a virtual network card queue allocation method and a readable storage medium. The virtual network card queue allocation method comprises the following steps: before the execution of the business logic, the following steps are performed: acquiring global queue information of a queue which can be provided by PCI equipment; acquiring planning information of a queue required by virtual network equipment; matching based on the global queue information and the planning information, and obtaining a queue allocation result, wherein in the queue allocation result, at least one queue allocated to the virtual network device is from at least two PCI devices; and performing queue allocation based on the queue allocation result. By the configuration, decision information of queue allocation is expanded, so that the queue allocation process is more flexible, and the virtual network equipment can acquire related queues according to own requirements, so that the problems that in the prior art, the queue resource allocation flexibility is poor, and the number of the queues is insufficient under specific conditions are solved.
The foregoing description is only illustrative of the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention in any way, and any changes and modifications made by those skilled in the art in light of the foregoing disclosure will be deemed to fall within the scope and spirit of the present invention.
Claims (9)
1. The virtual network card queue allocation method is characterized by comprising the following steps of:
before the execution of the business logic, the following steps are performed:
acquiring global queue information of a queue which can be provided by PCI equipment;
acquiring planning information of a queue required by virtual network equipment; wherein the planning information includes: the number of queues required by the virtual network device;
matching based on the global queue information and the planning information, and obtaining a queue allocation result, wherein in the queue allocation result, at least one queue allocated to the virtual network device is from at least two PCI devices; the method comprises the steps of,
performing queue allocation based on the queue allocation result;
the step of matching based on the global queue information and the planning information includes: and allocating the idle queues of the PCI equipment according to the number of the queues required by the virtual network equipment.
2. The virtual network card queue allocation method of claim 1, wherein the planning information further comprises: the priority corresponding to the virtual network device and whether the virtual network device supports cross PCI device allocation;
The step of matching based on the global queue information and the planning information includes:
numbering the PCI equipment;
sequencing the virtual network devices, wherein the virtual network devices with higher priorities are more front, and the virtual network devices which do not support cross PCI device allocation are more front in the same priority;
according to the sequencing result of the virtual network device, sequentially executing: if the current virtual network equipment supports cross PCI equipment allocation, selecting the idle queue of the PCI equipment with the minimum number of idle queues to be allocated to the virtual network equipment, and circularly executing the process until the number of the queues allocated to the virtual network equipment is the same as the number of the queues required by the virtual network equipment, and switching to the next virtual network equipment; if the current virtual network equipment does not support cross PCI equipment allocation, selecting the idle queue of the PCI equipment with the minimum number, which still has idle queues and the number of which is greater than or equal to the number of the queues required by the virtual network equipment, to allocate the idle queue to the virtual network equipment, and switching to the next virtual network equipment; the method comprises the steps of,
If the virtual network equipment is completely allocated, or the idle queues of the PCI equipment are completely allocated, or the idle queues of the PCI equipment cannot meet any virtual network equipment which is not allocated yet, the allocation is ended.
3. The virtual network card queue allocation method of claim 1, wherein the planning information further comprises: whether the virtual network device supports cross PCI device allocation;
the step of matching based on the global queue information and the planning information includes:
distributing queues according to a preset sequence;
if the virtual network equipment is completely allocated, or the idle queues of the PCI equipment are completely allocated, the allocation is finished; otherwise, backtracking the allocation result of the previous queue and modifying the allocation result to be a non-backtracking result, and backtracking to the previous queue if all possible allocation results of the previous queue are backtracked; the method comprises the steps of,
if all possible allocation results of all queues are traced back, the allocation process is interrupted and an alarm is given.
4. The virtual network card queue allocation method of claim 1, wherein the planning information further comprises: the virtual network equipment is distributed with weights;
The step of matching based on the global queue information and the planning information includes:
and taking the total allocation weight corresponding to the queue allocation result as an optimization target, and acquiring the queue allocation result based on an optimization algorithm.
5. The virtual network card queue allocation method according to claim 4, wherein the step of matching based on the global queue information and the planning information comprises:
the number of the virtual network devices is regarded as the number of articles, the total number of the queues which can be provided by the PCI devices is regarded as knapsack capacity, the number of the queues which are needed by each virtual network device is regarded as the weight corresponding to the articles, the allocation weight of each virtual network device is regarded as the value, the 0/1 knapsack problem is solved based on a dynamic programming algorithm, and the result is converted into the queue allocation result.
6. The virtual network card queue allocation method according to claim 1, further comprising:
recording the use state of each queue, wherein the use state comprises allocated and unallocated;
in the execution process of the business logic, the following steps are executed:
When the virtual network device exits, the use state of the corresponding queue is set to be unassigned; the method comprises the steps of,
when a new virtual network device is accessed, an unassigned queue is selected for allocation to the new virtual network device.
7. The virtual network card queue allocation method of claim 6, further comprising:
and in the execution process of the service logic, periodically transferring the queue of the PCI device with the least common queue in the different PCI devices corresponding to the same virtual network device to other PCI devices in the corresponding different PCI devices.
8. The virtual network card queue allocation method of claim 6, further comprising:
during execution of the business logic, the following steps are periodically executed:
acquiring global queue information of a queue which can be provided by the PCI equipment;
acquiring planning information of a queue required by the virtual network equipment;
matching is carried out based on the global queue information and the planning information, and the queue allocation result is obtained; the method comprises the steps of,
And comparing the new queue allocation result with the actual queue allocation situation, calculating a reset value, and if the reset value is larger than a preset threshold, setting a planning task to re-register the virtual network equipment according to the new queue allocation result at a preset time point.
9. A readable storage medium, wherein a program is stored on the readable storage medium, and when the program runs, the virtual network card queue allocation method according to any one of claims 1 to 8 is executed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311054259.XA CN116795554B (en) | 2023-08-22 | 2023-08-22 | Virtual network card queue allocation method and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311054259.XA CN116795554B (en) | 2023-08-22 | 2023-08-22 | Virtual network card queue allocation method and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116795554A true CN116795554A (en) | 2023-09-22 |
CN116795554B CN116795554B (en) | 2023-11-17 |
Family
ID=88046225
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311054259.XA Active CN116795554B (en) | 2023-08-22 | 2023-08-22 | Virtual network card queue allocation method and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116795554B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120151472A1 (en) * | 2010-12-08 | 2012-06-14 | International Business Machines Corporation | Virtualization of hardware queues in self-virtualizing input/output devices |
CN102609298A (en) * | 2012-01-11 | 2012-07-25 | 中国科学技术大学苏州研究院 | Network card virtualizing system and network card virtualizing method on basis of hardware array expansion |
CN112003797A (en) * | 2020-07-16 | 2020-11-27 | 苏州浪潮智能科技有限公司 | Method, system, terminal and storage medium for improving performance of virtualized DPDK network |
CN113032103A (en) * | 2021-04-14 | 2021-06-25 | 中南大学 | VF (variable frequency) resource dynamic scheduling method based on SR-IOV (scheduling request-input/output) function of high-speed network card |
US20210203740A1 (en) * | 2016-09-30 | 2021-07-01 | Intel Corporation | Technologies for paravirtual network device queue and memory management |
CN113438184A (en) * | 2021-06-25 | 2021-09-24 | 北京汇钧科技有限公司 | Network card queue management method and device and electronic equipment |
-
2023
- 2023-08-22 CN CN202311054259.XA patent/CN116795554B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120151472A1 (en) * | 2010-12-08 | 2012-06-14 | International Business Machines Corporation | Virtualization of hardware queues in self-virtualizing input/output devices |
CN102609298A (en) * | 2012-01-11 | 2012-07-25 | 中国科学技术大学苏州研究院 | Network card virtualizing system and network card virtualizing method on basis of hardware array expansion |
US20210203740A1 (en) * | 2016-09-30 | 2021-07-01 | Intel Corporation | Technologies for paravirtual network device queue and memory management |
CN112003797A (en) * | 2020-07-16 | 2020-11-27 | 苏州浪潮智能科技有限公司 | Method, system, terminal and storage medium for improving performance of virtualized DPDK network |
CN113032103A (en) * | 2021-04-14 | 2021-06-25 | 中南大学 | VF (variable frequency) resource dynamic scheduling method based on SR-IOV (scheduling request-input/output) function of high-speed network card |
CN113438184A (en) * | 2021-06-25 | 2021-09-24 | 北京汇钧科技有限公司 | Network card queue management method and device and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN116795554B (en) | 2023-11-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8402469B2 (en) | Allocating resources for parallel execution of query plans | |
WO2017089944A1 (en) | Techniques for analytics-driven hybrid concurrency control in clouds | |
CN107908457B (en) | Containerized cloud resource allocation method based on stable matching | |
CN103067524A (en) | Ant colony optimization computing resource distribution method based on cloud computing environment | |
US20150186184A1 (en) | Apparatus and method for optimizing system performance of multi-core system | |
US11372683B2 (en) | Placement of virtual GPU requests in virtual GPU enabled systems using a requested memory requirement of the virtual GPU request | |
CN113032101B (en) | Resource allocation method of virtual machine, server and computer readable storage medium | |
CN104050043A (en) | Share cache perception-based virtual machine scheduling method and device | |
CN110990154A (en) | Big data application optimization method and device and storage medium | |
CN114625500B (en) | Topology-aware microservice application scheduling method and application in cloud environment | |
CN110826915A (en) | Resource scheduling method, device and computer readable storage medium | |
CN110221920A (en) | Dispositions method, device, storage medium and system | |
CN116560860B (en) | Real-time optimization adjustment method for resource priority based on machine learning | |
CN101539867B (en) | Retargetable register allocation method in dynamic binary translation system | |
CN104506669A (en) | IP address distribution system and method facing distributed network simulation platform | |
CN116795554B (en) | Virtual network card queue allocation method and readable storage medium | |
WO2021210880A1 (en) | Method and apparatus for allocating resources to virtual machine | |
CN111796932A (en) | GPU resource scheduling method | |
CN116600014B (en) | Server scheduling method and device, electronic equipment and readable storage medium | |
CN113190342A (en) | Method and system architecture for multi-application fine-grained unloading of cloud-edge cooperative network | |
CN115361349B (en) | Resource using method and device | |
KR100401443B1 (en) | Concurrent processing for event-based systems | |
CN116909729A (en) | GPU multitasking scheduling method | |
CN116302327A (en) | Resource scheduling method and related equipment | |
CN109558214B (en) | Host machine resource management method and device in heterogeneous environment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |