Method and device for dynamically allocating memory of pkb, electronic equipment and storage medium
Patent Information
- Application Number
- CN202310551716.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2026-10-13
- Estimated Expiration
- 2043-05-16
AI Technical Summary
如果产品设备上安装的网卡数量少,设备CPU的核数也少,那么网卡所使用到的队列数以及最终能够分配使用的PKB内存也会少,这样容易造成内存的浪费;反之,如果产品设备上安装的网卡数量多,设备CPU的核数也多,那么网卡所使用到的队列数以及最终能够分配使用的PKB内存也会大量增加,这样容易导致网卡队列分配的PKB内存出现不足,而无法正常收发报文
[0028]本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如上述任一种所述PKB内存动态分配方法。
Smart Images

Figure CN116795730B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for dynamic PKB memory allocation. Background Technology
[0002] Security product hardware uses hardware network interface cards (NICs) to receive and send network packets. Most current NICs support multi-queue configurations, where each queue can receive and send packets. These queues require binding and initialization of packet buffer (PKB) memory based on their length.
[0003] However, existing systems allocate a fixed block of memory to the PKB based on the security product model and total memory size. For example, if the product device has 16GB of memory, 500MB of memory space will be directly allocated for PKB use. If the product device has few network cards and a few CPU cores, the number of queues used by the network cards and the final available PKB memory will be less, easily leading to memory waste. Conversely, if the product device has many network cards and a large number of CPU cores, the number of queues used by the network cards and the final available PKB memory will increase significantly, potentially leading to insufficient PKB memory allocated to the network card queues and inability to send and receive packets normally.
[0004] Therefore, how to better allocate PKB memory for security products has become a technical problem that the industry urgently needs to solve. Summary of the Invention
[0005] This invention provides a method, apparatus, electronic device, and storage medium for dynamic allocation of PKB memory, which can better allocate PKB memory for security products.
[0006] This invention provides a method for dynamic allocation of PKB memory, comprising:
[0007] Based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interfaces of each network interface card, the number of cores bound to each network interface card is determined.
[0008] Based on the number of core binding queues corresponding to each network interface card (NIC), the number of preset packet descriptors corresponding to each NIC, and the number of interfaces of each NIC, the total number of PKB memory blocks required by the system NIC interfaces is determined.
[0009] The required PKB memory allocation for the system is determined based on the total number of PKB memory blocks.
[0010] According to a dynamic PKB memory allocation method provided by the present invention, the step of determining the total number of PKB memory blocks required by the system network interface based on the number of core binding queues corresponding to each network interface card, the number of preset send / receive packet descriptors corresponding to each network interface card, and the number of interfaces of each network interface card includes:
[0011] Based on the number of core binding queues corresponding to each network card and the number of preset transceiver descriptors corresponding to each network card, calculate the number of PKB memory blocks required for each network card interface of each network card;
[0012] The number of PKB memory blocks required for each network interface card is determined based on the number of PKB memory blocks required for each network interface card and the number of interfaces of each network interface card;
[0013] The total number of PKB memory blocks required by each network card is obtained by adding up the number of PKB memory blocks required by the system network card interface.
[0014] According to the PKB memory dynamic allocation method provided by the present invention, the step of determining the number of cores bound to each network interface card (NIC) based on the number of cores in the system used for processing user-mode packet sending and receiving services and the maximum number of queues supported by the interfaces of each NIC includes:
[0015] Compare the number of cores used to process user-mode packet sending and receiving services with the maximum number of queues supported by the interface of each network card;
[0016] For any one of the network interface cards (NICs), if the number of cores used to process user-mode packet sending and receiving services is less than the maximum number of queues supported by the interface of any NIC, the number of core-bound queues corresponding to any NIC is determined to be the number of cores used to process user-mode packet sending and receiving services.
[0017] According to a PKB memory dynamic allocation method provided by the present invention, after comparing the number of cores used for processing user-mode packet sending and receiving services with the maximum number of queues supported by the interfaces of each network interface card, the method further includes:
[0018] For any one of the network interface cards (NICs), if the number of cores used to process user-mode packet sending and receiving services is not less than the maximum number of queues supported by the interface of any NIC, the number of cores bound to any NIC is determined to be the maximum number of queues supported by its interface.
[0019] According to a method for dynamic allocation of PKB memory provided by the present invention, the step of determining the PKB memory to be allocated by the system based on the total number of PKB memory blocks includes:
[0020] Determine the memory size of each PKB memory block;
[0021] The required PKB memory for system allocation is obtained by multiplying the total number of PKB memory blocks, the memory size of each PKB memory block, and a preset redundancy factor. The preset redundancy factor is determined based on the number of PKB memory blocks required for packet fragmentation and reassembly in the system.
[0022] According to a PKB memory dynamic allocation method provided by the present invention, each network interface card (NIC) includes a gigabit Ethernet NIC and a 10-gigabit optical NIC. The preset packet descriptors corresponding to the gigabit Ethernet NIC include 512 receive descriptors and 1024 send descriptors; the preset packet descriptors corresponding to the 10-gigabit optical NIC include 256 receive descriptors and 512 send descriptors.
[0023] The present invention also provides a PKB memory dynamic allocation device, comprising:
[0024] The first processing module is used to determine the number of cores bound to each network card based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interface of each network card.
[0025] The second processing module is used to determine the total number of PKB memory blocks required by the system network card interface based on the number of core binding queues corresponding to each network card, the number of preset send / receive packet descriptors corresponding to each network card, and the number of interfaces of each network card.
[0026] The third processing module is used to determine the amount of PKB memory that the system needs to allocate based on the total number of PKB memory blocks.
[0027] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement any of the above-described PKB memory dynamic allocation methods.
[0028] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the PKB memory dynamic allocation method as described above.
[0029] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the PKB memory dynamic allocation method as described above.
[0030] The PKB memory dynamic allocation method, apparatus, electronic device, and storage medium provided by this invention, by considering the actual configuration of security product equipment, determines the number of cores in the device system used to process user-mode packet sending and receiving services and the maximum number of queues supported by each network card interface, calculates the actual number of core binding queues required for core binding for each network card, and then calculates the total number of PKB memory blocks actually required by the system network card interfaces based on the number of interfaces of each network card, the number of core binding queues corresponding to each network card, and the number of preset packet descriptors. PKB memory is allocated based on the total number of PKB memory blocks, which can reasonably and effectively optimize the initial allocation of PKB memory for security products, and dynamically initialize and allocate the PKB memory size according to different hardware configurations of security product equipment. Attached Figure Description
[0031] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0032] Figure 1 This is a flowchart illustrating the PKB memory dynamic allocation method provided by the present invention;
[0033] Figure 2 This is a schematic diagram of the structure of the PKB memory dynamic allocation device provided by the present invention;
[0034] Figure 3 This is a schematic diagram of the physical structure of the electronic device provided by the present invention. Detailed Implementation
[0035] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0036] The following is combined with Figures 1-3 The present invention describes a PKB memory dynamic allocation method, apparatus, electronic device, and storage medium.
[0037] Figure 1 This is a flowchart illustrating the PKB memory dynamic allocation method provided by the present invention, as shown below. Figure 1 As shown, it includes:
[0038] Step 110: Based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interfaces of each network card, determine the number of cores bound to each network card.
[0039] Step 120: Based on the number of core binding queues corresponding to each network card, the number of preset send / receive packet descriptors corresponding to each network card, and the number of interfaces of each network card, determine the total number of PKB memory blocks required by the system network card interfaces;
[0040] Step 130: Determine the amount of PKB memory that the system needs to allocate based on the total number of PKB memory blocks.
[0041] Specifically, the system described in the embodiments of the present invention refers to a system of safety product equipment.
[0042] The core used for processing user-mode packet sending and receiving services as described in the embodiments of the present invention refers to the core used for processing user-mode packet sending and receiving services after the cores of the hardware CPU in the system are divided.
[0043] In an embodiment of the present invention, the security product device system can employ a 16-core system. Therefore, the 16 cores of the CPU can be differentiated, with two cores isolated for kernel use only, not for user-mode packet sending and receiving. The remaining 14 cores are used as packet sending and receiving cores to handle user-mode packet sending and receiving services. It is understood that, in this case, the number of cores in the system used for handling user-mode packet sending and receiving services is 14.
[0044] The network interface card (NIC) described in this embodiment of the invention refers to the NIC installed in the system, which may include gigabit Ethernet NICs and 10-gigabit optical NICs.
[0045] The maximum number of queues supported by each interface of the network card can be determined based on the performance parameters provided by the network card model. For example, an 8-port Gigabit Ethernet network card of model Intel i350 can support a maximum of 8 queues per interface.
[0046] The number of core-bound queues described in this embodiment of the invention refers to the number of queues used by a core for processing user-mode packet sending and receiving services.
[0047] In an embodiment of the present invention, in step 110, by determining the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interface of each network card, the number of core binding queues corresponding to each network card is determined according to the actual capacity of the number of queues used by the system core binding.
[0048] Based on the above embodiments, as an optional embodiment, the number of cores bound to each network interface card (NIC) is determined based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by each NIC's interface, including:
[0049] Compare the number of cores used to process user-mode packet sending and receiving services with the maximum number of queues supported by each network interface card's interface;
[0050] For any network interface card (NIC), if the number of cores used to process user-mode packet sending and receiving services is less than the maximum number of queues supported by the interface of any NIC, the number of cores bound to any NIC is determined to be the number of cores used to process user-mode packet sending and receiving services.
[0051] Specifically, in embodiments of the present invention, the number of cores used to process user-mode packet sending and receiving services can be compared with the maximum number of queues supported by the interface of each network card. By comparing the size of the two, the number of cores bound to each network card can be determined.
[0052] In one specific embodiment, the security product device has a 16-core system, in which 2 cores are isolated for kernel use and the remaining 14 cores are used to process user-mode packet sending and receiving services. The system is equipped with two network cards, including an Intel i350 8-port gigabit Ethernet network card and an Intel XL710 4-port 10-gigabit optical network card.
[0053] For the Intel XL710's four 10 Gigabit optical network card, the maximum number of queues supported by each interface far exceeds 14. This means that the number of cores in the system used to process user-mode packet sending and receiving services is far less than the maximum number of queues supported by the Intel XL710 network card's interface. Therefore, it can be determined that the number of cores bound to queues for the Intel XL710 network card is the number of cores used to process user-mode packet sending and receiving services, which is 14.
[0054] Based on the above embodiments, as an optional embodiment, after comparing the number of cores used to process user-mode packet sending and receiving services with the maximum number of queues supported by the interface of each network interface card, the method further includes:
[0055] For any network interface card (NIC) in each NIC, provided that the number of cores used to process user-mode packet sending and receiving services is not less than the maximum number of queues supported by the interface of any NIC, the number of cores bound to any NIC is determined to be the maximum number of queues supported by its interface.
[0056] Specifically, in the embodiments of the present invention, the number of cores used to process user-mode packet sending and receiving services is 14. For the 8-port Gigabit Ethernet network card of Intel i350, the maximum number of queues supported by each interface is 8. It can be seen that the number of cores used to process user-mode packet sending and receiving services is not less than the maximum number of queues supported by the interface of Intel i350 network card. At this time, it can be determined that the number of queues bound to the cores of Intel i350 network card is the maximum number of queues supported by its interface, which is 8.
[0057] In embodiments of the present invention, based on the above method, the number of core binding queues corresponding to each network card can be calculated according to the system type of the security product equipment and the various network cards of different models installed.
[0058] It should be noted that each queue can receive and send messages, including a receive queue and a send queue. The receive queue includes pre-configured receive descriptors, and the send queue includes pre-configured send descriptors.
[0059] A certain number of receive descriptors are pre-configured in the receive queue. Each receive descriptor has a first field and a second field. The first field is used to fill in the first address information, and the second field is used to fill in the second address information. This allows the processor to obtain the packet header corresponding to the receive descriptor through the first address information during business processing. The second address information is used to obtain the packet body during forwarding.
[0060] After processing the packet header of the received descriptor which is in an occupied state, the system processor can write the first address information and the second address information corresponding to the received descriptor into the sent descriptor which is in an idle state. The first address information is the identifier information of the write address of the packet header corresponding to the received descriptor, and the second address information is the identifier information of the write address of the packet body corresponding to the received descriptor.
[0061] The number of preset packet descriptors described in this embodiment of the invention includes the number of receive packet descriptors and the number of send packet descriptors, which can be determined according to the type and model of the network card.
[0062] Based on the above embodiments, as an optional embodiment, each network interface card (NIC) includes a gigabit Ethernet NIC and a 10-gigabit optical NIC. The preset packet descriptors corresponding to the gigabit Ethernet NIC include 512 receive descriptors and 1024 send descriptors; the preset packet descriptors corresponding to the 10-gigabit optical NIC include 256 receive descriptors and 512 send descriptors.
[0063] Specifically, in one embodiment, the system is equipped with two network cards: an 8-port Gigabit Ethernet network card from an Intel i350 and a 4-port 10 Gigabit optical network card from an Intel XL710. The preset packet descriptors for the 8-port Gigabit Ethernet network card from the Intel i350 can be set to include 512 receive packet descriptors and 1024 send packet descriptors, while the preset packet descriptors for the 4-port 10 Gigabit optical network card from the Intel XL710 can be set to include 256 receive packet descriptors and 512 send packet descriptors.
[0064] The method in this embodiment of the invention sets the preset packet descriptors for gigabit Ethernet network cards to 512 receive descriptors and 1024 send descriptors, and the preset packet descriptors for 10-gigabit optical network cards to 256 receive descriptors and 512 send descriptors, which can ensure optimal performance and efficiency of the system in processing packet transmission and reception services.
[0065] Furthermore, in an embodiment of the present invention, in step 120, based on the number of core binding queues corresponding to each network card, the number of preset send / receive packet descriptors corresponding to each network card, and the number of interfaces of each network card, the total number of PKB memory blocks required by the system network card interfaces is calculated according to the actual configuration of the device.
[0066] Based on the above embodiments, as an optional embodiment, in step 120, determining the total number of PKB memory blocks required by the system network interface card (NIC) based on the number of core binding queues corresponding to each NIC, the number of preset packet descriptors corresponding to each NIC, and the number of interfaces of each NIC includes:
[0067] Based on the number of core binding queues corresponding to each network card and the number of preset transceiver descriptors corresponding to each network card, calculate the number of PKB memory blocks required for each network card interface of each network card.
[0068] The number of PKB memory blocks required for each network card is determined based on the number of PKB memory blocks required for each network card interface and the number of interfaces for each network card.
[0069] Add up the number of PKB memory blocks required by each network card to get the total number of PKB memory blocks required by the system's network card interfaces.
[0070] Specifically, in the embodiments of the present invention, after obtaining the number of core binding queues corresponding to each network card and the number of preset send / receive packet descriptors corresponding to each network card, the total number of send / receive packet descriptors that can be set by the number of core binding queues can be calculated by multiplication, thereby determining the number of PKB memory blocks required for each network interface of each network card.
[0071] After determining the number of PKB memory blocks required for each interface of each network card, the number of PKB memory blocks required for each network card can be calculated by multiplying the number of interfaces of each network card. Therefore, based on the number of network cards installed in the system, the number of PKB memory blocks required for each network card is added together to obtain the total number of PKB memory blocks required for the system's network card interfaces.
[0072] The method of this invention can effectively calculate the total number of PKB memory blocks actually required by the system's network interface by considering the number of send and receive packet descriptors set in each queue bound to the core and the actual number of interfaces of each network card, thus providing a reliable data source for the PKB memory allocated by the subsequent computing system.
[0073] Further, in step 130, the required PKB memory to be allocated by the system is calculated based on the total number of PKB memory blocks and the memory size of each PKB memory block.
[0074] Based on the above embodiments, as an optional embodiment, step 130, determining the PKB memory to be allocated by the system according to the total number of PKB memory blocks, includes:
[0075] Determine the memory size of each PKB memory block;
[0076] The required PKB memory for the system is calculated by multiplying the total number of PKB memory blocks, the memory size of each PKB memory block, and the preset redundancy factor. The preset redundancy factor is determined based on the number of PKB memory blocks required for packet fragmentation and reassembly in the system.
[0077] Specifically, the preset redundancy coefficient described in this embodiment of the invention is used to ensure that buffer space is provided for packet fragmentation and reassembly in the system, and it is determined based on the number of PKB memory blocks required for packet fragmentation and reassembly in the system. In this embodiment of the invention, the preset redundancy coefficient can be 2.
[0078] In an embodiment of the present invention, after determining the total number of PKB memory blocks required by the system network card interface, the total number of PKB memory blocks required for PKB initialization is determined by multiplying the total number of PKB memory blocks with a preset redundancy coefficient, taking into account the memory required for packet fragmentation and reassembly in the system.
[0079] Furthermore, the memory size of each PKB memory block is determined, for example, the memory of each PKB memory block is determined to be 4KB. The actual PKB memory to be allocated by the system is obtained by multiplying the total number of PKB memory blocks required for PKB memory initialization by the memory size of each PKB memory block.
[0080] In embodiments of the present invention, by taking into account the packet fragmentation and reassembly in the system, the PKB memory allocated during the initialization of system memory allocation is optimized to avoid insufficient PKB memory and further improve the accuracy and effectiveness of the initial allocation of PKB memory.
[0081] The PKB memory dynamic allocation method of this invention, by considering the actual configuration of the security product device, determines the number of cores in the device system used to process user-mode packet sending and receiving services and the maximum number of queues supported by each network card interface. It calculates the number of core binding queues that each network card actually needs to bind to cores. Then, based on the number of interfaces of each network card, the number of core binding queues corresponding to each network card, and the number of preset packet descriptors, it calculates the total number of PKB memory blocks actually required by the system network card interfaces. Based on the total number of PKB memory blocks, it allocates PKB memory, which can reasonably and effectively optimize the initial allocation of PKB memory for security products. According to different hardware configurations of security product devices, it can dynamically initialize and allocate the memory size of PKB.
[0082] In a specific embodiment of the present invention, the basic hardware configuration of the security product device is as follows: the CPU is a single-socket CPU with 16 cores. The 16 cores of the CPU are differentiated, with 2 cores isolated for kernel use and not used for user-mode packet sending and receiving. The remaining 14 cores are used as packet sending and receiving cores. The memory is 16G. Two network cards are installed: one is an 8-port Gigabit Ethernet network card from Intel i350, and the other is a 4-port 10 Gigabit optical network card from Intel XL710.
[0083] In this embodiment, based on the configuration of the aforementioned security product equipment, the method for calculating the required PKB memory allocation for the system is as follows:
[0084] Step S1: Based on the 8-port gigabit Ethernet card of Intel i350, the maximum number of queues that each interface can support is 8. Since there are fewer than 14 CPU cores, it can be determined that the actual number of queues used for core binding is 8; determine that the number of receive packet descriptors is set to 512 and the number of send packet descriptors is set to 1024.
[0085] Step S2: Based on the Intel XL710's 4-port 10 Gigabit optical network card, the maximum number of queues that each interface can support is very large, far exceeding the number of CPU cores used to process packet sending and receiving services, i.e., 14. Therefore, it can be determined that the actual number of queues used for core binding is 14; the number of receive packet descriptors is set to 256, and the number of send packet ring descriptors is set to 512.
[0086] Step S3, calculate the number of PKB memory blocks required for the Intel i350's 8-port Gigabit Ethernet card:
[0087] (512+1024)*8(number of queues)*8(number of interfaces)=98304;
[0088] And calculate the number of PKB memory blocks required for the Intel XL710's four 10 Gigabit optical network cards:
[0089] (256+512)*14 (number of queues)*4 (number of interfaces) = 43008;
[0090] Step S4: Calculate the total number of PKB memory blocks required for all registered network interface cards: 98304 + 43008 = 141312;
[0091] Step S5, calculate the number of PKB memory initializations as: 141312*2 (preset redundancy coefficient) = 282624;
[0092] Step S6: Based on the size of each PKB memory block (assuming 4K for ease of calculation), the total size of PKB memory required by the system is:
[0093] 4K*141312*2=1130496K=1131M;
[0094] Therefore, based on the calculation results above, the total size of the PKB memory actually required by the system can be determined to be 1131M.
[0095] The method described in this invention ensures that the size of the PKB memory is dynamically initialized and allocated based on the actual configuration of the device. If the hardware device changes its CPU or adds (removes, or replaces) a network card, after restarting the system, the device can automatically and dynamically initialize and allocate the size of the PKB memory according to the new configuration, thereby effectively avoiding memory waste or insufficient memory usage.
[0096] The PKB memory dynamic allocation device provided by the present invention is described below. The PKB memory dynamic allocation device described below can be referred to in correspondence with the PKB memory dynamic allocation method described above.
[0097] Figure 2 This is a schematic diagram of the structure of the PKB memory dynamic allocation device provided by the present invention, as shown below. Figure 2 As shown, it includes:
[0098] The first processing module 210 is used to determine the number of cores bound to each network card based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interface of each network card.
[0099] The second processing module 220 is used to determine the total number of PKB memory blocks required by the system network card interface based on the number of core binding queues corresponding to each network card, the number of preset send and receive packet descriptors corresponding to each network card, and the number of interfaces of each network card.
[0100] The third processing module 230 is used to determine the amount of PKB memory that the system needs to allocate based on the total number of PKB memory blocks.
[0101] The PKB memory dynamic allocation device described in this embodiment can be used to execute the above-described PKB memory dynamic allocation method embodiment. Its principle and technical effects are similar, and will not be repeated here.
[0102] The PKB memory dynamic allocation device of this invention, by considering the actual configuration of the security product device, determines the number of cores in the device system used to process user-mode packet sending and receiving services and the maximum number of queues supported by each network card interface. It calculates the number of core binding queues that each network card actually needs to bind to cores. Then, based on the number of interfaces of each network card, the number of core binding queues corresponding to each network card, and the number of preset packet descriptors, it calculates the total number of PKB memory blocks actually required by the system network card interfaces. Based on the total number of PKB memory blocks, it allocates PKB memory, which can reasonably and effectively optimize the initial allocation of PKB memory for security products. According to different hardware configurations of security product devices, it can dynamically initialize and allocate the memory size of PKB.
[0103] Based on the above embodiments, as an optional embodiment, the second processing module 220 is specifically used for:
[0104] Based on the number of core binding queues corresponding to each network card and the number of preset transceiver descriptors corresponding to each network card, calculate the number of PKB memory blocks required for each network card interface of each network card.
[0105] The number of PKB memory blocks required for each network card is determined based on the number of PKB memory blocks required for each network card interface and the number of interfaces for each network card.
[0106] Add up the number of PKB memory blocks required by each network card to get the total number of PKB memory blocks required by the system's network card interfaces.
[0107] Based on the above embodiments, as an optional embodiment, the first processing module 210 is specifically used for:
[0108] Compare the number of cores used to process user-mode packet sending and receiving services with the maximum number of queues supported by each network interface card's interface;
[0109] For any network interface card (NIC), if the number of cores used to process user-mode packet sending and receiving services is less than the maximum number of queues supported by the interface of any NIC, the number of cores bound to any NIC is determined to be the number of cores used to process user-mode packet sending and receiving services.
[0110] Based on the above embodiments, as an optional embodiment, the first processing module 210 is further configured to:
[0111] For any network interface card (NIC) in each NIC, provided that the number of cores used to process user-mode packet sending and receiving services is not less than the maximum number of queues supported by the interface of any NIC, the number of cores bound to any NIC is determined to be the maximum number of queues supported by its interface.
[0112] Based on the above embodiments, as an optional embodiment, the third processing module 230 is specifically used for:
[0113] Determine the memory size of each PKB memory block;
[0114] The required PKB memory for the system is calculated by multiplying the total number of PKB memory blocks, the memory size of each PKB memory block, and the preset redundancy factor. The preset redundancy factor is determined based on the number of PKB memory blocks required for packet fragmentation and reassembly in the system.
[0115] Figure 3 This is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as... Figure 3 As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, communications interface 320, and memory 330 communicate with each other through the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute the dynamic PKB memory allocation method provided by the above methods. This method includes: determining the number of core-bound queues corresponding to each network card based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interfaces of each network card; determining the total number of PKB memory blocks required by the system network card interfaces based on the number of core-bound queues corresponding to each network card, the number of preset packet descriptors corresponding to each network card, and the number of interfaces of each network card; and determining the PKB memory to be allocated by the system according to the total number of PKB memory blocks.
[0116] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0117] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the dynamic PKB memory allocation method provided by the above methods. The method includes: determining the number of core-bound queues corresponding to each network card based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interfaces of each network card; determining the total number of PKB memory blocks required by the system network card interfaces based on the number of core-bound queues corresponding to each network card, the number of preset packet descriptors corresponding to each network card, and the number of interfaces of each network card; and determining the PKB memory to be allocated by the system according to the total number of PKB memory blocks.
[0118] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the dynamic PKB memory allocation method provided by the above methods. The method includes: determining the number of core-bound queues corresponding to each network interface card (NIC) based on the number of cores in the system used for processing user-mode packet sending and receiving services and the maximum number of queues supported by the interfaces of each NIC; determining the total number of PKB memory blocks required by the system NIC interfaces based on the number of core-bound queues corresponding to each NIC, the number of preset packet descriptors corresponding to each NIC, and the number of interfaces of each NIC; and determining the PKB memory to be allocated by the system according to the total number of PKB memory blocks.
[0119] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0120] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0121] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for dynamic allocation of PKB memory, characterized in that, include: Based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interfaces of each network interface card, the number of cores bound to each network interface card is determined. Based on the number of core binding queues corresponding to each network interface card (NIC), the number of preset packet descriptors corresponding to each NIC, and the number of interfaces of each NIC, the total number of PKB memory blocks required by the system NIC interfaces is determined. The required PKB memory allocation for the system is determined based on the total number of PKB memory blocks.
2. The PKB memory dynamic allocation method according to claim 1, characterized in that, The determination of the total number of PKB memory blocks required by the system network interface cards (NICs) based on the number of core binding queues corresponding to each NIC, the number of preset transceiver descriptors corresponding to each NIC, and the number of interfaces of each NIC includes: Based on the number of core binding queues corresponding to each network card and the number of preset send / receive packet descriptors corresponding to each network card, calculate the number of PKB memory blocks required for each network card interface of each network card; The number of PKB memory blocks required for each network card is determined based on the number of PKB memory blocks required for each network card interface and the number of interfaces of each network card; The total number of PKB memory blocks required by each network card is obtained by adding up the number of PKB memory blocks required by the system network card interface.
3. The PKB memory dynamic allocation method according to claim 1, characterized in that, The determination of the number of cores bound to each network interface card (NIC) based on the number of cores in the system used for processing user-mode packet sending and receiving services and the maximum number of queues supported by each NIC's interface includes: Compare the number of cores used to process user-mode packet sending and receiving services with the maximum number of queues supported by the interface of each network card; For any one of the network interface cards (NICs), if the number of cores used to process user-mode packet sending and receiving services is less than the maximum number of queues supported by the interface of any NIC, the number of core-bound queues corresponding to any NIC is determined to be the number of cores used to process user-mode packet sending and receiving services.
4. The PKB memory dynamic allocation method according to claim 3, characterized in that, After comparing the number of cores used for processing user-mode packet sending and receiving services with the maximum number of queues supported by the interfaces of each network interface card, the method further includes: For any one of the network interface cards (NICs), if the number of cores used to process user-mode packet sending and receiving services is not less than the maximum number of queues supported by the interface of any NIC, the number of cores bound to any NIC is determined to be the maximum number of queues supported by its interface.
5. The PKB memory dynamic allocation method according to any one of claims 1-4, characterized in that, The step of determining the required PKB memory allocation for the system based on the total number of PKB memory blocks includes: Determine the memory size of each PKB memory block; The required PKB memory for system allocation is obtained by multiplying the total number of PKB memory blocks, the memory size of each PKB memory block, and a preset redundancy factor. The preset redundancy factor is determined based on the number of PKB memory blocks required for packet fragmentation and reassembly in the system.
6. The PKB memory dynamic allocation method according to any one of claims 1-4, characterized in that, Each network interface card includes a gigabit Ethernet network interface card and a 10-gigabit optical network interface card. The preset packet descriptors corresponding to the gigabit Ethernet network interface card include 512 packet descriptors and 1024 packet descriptors. The preset packet descriptors corresponding to the 10 Gigabit optical network interface card include 256 receive packet descriptors and 512 send packet descriptors.
7. A PKB-based dynamic memory allocation device, characterized in that, include: The first processing module is used to determine the number of cores bound to each network card based on the number of cores in the system used to process user-mode packet sending and receiving services and the maximum number of queues supported by the interface of each network card. The second processing module is used to determine the total number of PKB memory blocks required by the system network card interface based on the number of core binding queues corresponding to each network card, the number of preset send / receive packet descriptors corresponding to each network card, and the number of interfaces of each network card. The third processing module is used to determine the amount of PKB memory that the system needs to allocate based on the total number of PKB memory blocks.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the PKB memory dynamic allocation method as described in any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the PKB memory dynamic allocation method as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the PKB memory dynamic allocation method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Data processing method and equipment
CN113688072A
Packet buffering device and packet discarding method
US20110286468A1