Network device memory usage method and device
By dividing and tailoring the memory pool according to packet size, the memory waste and low efficiency problems caused by fixed-size memory pools in network equipment are solved, flexible memory management and efficient memory utilization are achieved, and the operating efficiency of network equipment is improved.
Patent Information
- Application Number
- CN202210773854.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-01
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-07-01
AI Technical Summary
In the existing technology, when network devices process jumbo frames, the fixed-size memory pool causes memory waste and low efficiency. Especially when the sizes of packets received by the network card are inconsistent, memory utilization is low.
Divide the memory pool into fixed memory blocks according to the number of received messages and the maximum message length, trim and reclaim memory space according to the message length, and dynamically splice the reclaimed memory into the cache memory pool to achieve flexible memory management.
It improves memory usage efficiency, reduces memory waste, simplifies the memory pool structure design, and improves the operating efficiency of network equipment, especially when processing packets with inconsistent sizes.
Smart Images

Figure CN115079954B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of memory management, and in particular to a method and apparatus for using memory of a network device. Background Art
[0002] In computer networks, jumbo frames refer to frames that are longer than standard Ethernet frames, that is, frames that are larger than 1518 / 1522 bytes. Jumbo frames are mainly used to improve network throughput and efficiency (small data packets are not efficient when encapsulating Layer 2 information), and to reduce the burden on the CPU of network devices (for small packets, the CPU of network devices needs to spend a lot of time to fragment and reassemble packets). In high-speed networks, the packets received by the network card in the network device sometimes contain not only basic Ethernet frames, but also some jumbo frames. Since each data packet needs to be processed by the network card and the packet is stored in the CPU queue of the network device, the memory occupied by the packet receiving queue will be very high, and the memory utilization rate is not high.
[0003] Specifically, in the prior art, the network card driver stores jumbo frames in a packet receiving queue. The size of the packet receiving queue applies for memory according to the longest message (generally 9216 bytes) and is stored in a static cache memory pool. The memory pool technology allocates a block of memory from the memory space of the operating system in advance and divides it into several fixed-size memory blocks. Memory allocation and memory release are first performed in the memory pool. In addition, the current technology does not distinguish between the sizes of messages and uniformly stores them in the static buffer memory pool.
[0004] Although the existing technology can alleviate the performance consumption caused by the frequent memory allocation and memory release operations of the operating system, for network devices with jumbo frames received by the network card and small memory, the fixed-size memory pool wastes the storage and forwarding of messages. The sizes of messages received by the network card are inconsistent, that is, short-byte messages also occupy memory blocks during actual use, resulting in the problem of memory waste when using fixed-size memory blocks to store messages. It can be seen that the memory pool technology of the existing technology has the disadvantages of extra memory waste and being limited to the allocation and release of message data of the same size.
[0005] Therefore, there is a need for a network device memory usage method and apparatus that can perform memory pool segmentation according to message size to improve memory usage efficiency. Summary of the invention
[0006] In view of this, the present disclosure provides a method and apparatus for using memory of a network device. According to one aspect of the present disclosure, a method for using memory of a network device is proposed, the method comprising: applying for a memory pool based on the number of messages n received by the network device and the maximum message length len, wherein the maximum message length len is the maximum value of the message lengths of the messages received by the network device; dividing the applied memory pool into n fixed memory blocks, that is, the size of the fixed memory block is len; storing the n messages received by the network device in the n fixed memory blocks respectively; for the messages stored in each fixed memory block, determining the relationship between the message length and len of the messages stored in each fixed memory block, and when determining that the length of the message is less than len, cutting the fixed memory block corresponding to the message storage; recycling the cut storage space, and dynamically splicing the recycled storage space and putting it into the cache memory pool.
[0007] According to the network device memory usage method disclosed in the present invention, it also includes: for each message stored in the fixed memory block, the CPU1 in the network device determines the relationship between the message length and len of the message stored in the fixed memory block, and when the message length is equal to len, directly sends the message for processing.
[0008] According to the network device memory usage method disclosed in the present invention, it also includes: the CPU1 determines the relationship between the message length and len of the message stored in the fixed memory block. When the message length is less than len, the CPU1 obtains and records the cropped memory size and memory starting address based on the message length and the starting address of the fixed memory block.
[0009] According to the network device memory usage method disclosed in the present invention, for the message stored in each fixed memory block, when the CPU1 in the network device determines that the message length of the message stored in the fixed memory block is less than len and obtains and records the cropped memory size and memory starting address, the CPU1 processes the message stored in the fixed memory block.
[0010] According to the network device memory usage method disclosed in the present invention, the cpu2 in the network device dynamically splices the cropped memory to the tail of the cache memory pool based on the recorded cropped memory size and memory start address.
[0011] According to another aspect of the present disclosure, a network device memory usage device is provided, the device comprising: a memory pool application component, used to apply for a memory pool based on the number n of messages received by the network device and a maximum message length len, wherein the maximum message length len is the maximum value of the message lengths of the messages received by the network device; a memory pool initialization component, used to divide the applied memory pool into n fixed memory blocks, that is, the size of the fixed memory block is len; a storage component, used to store the n messages received by the network device in the n fixed memory blocks respectively; a memory clipping component, used to determine the relationship between the message length and len of the messages stored in each fixed memory block for the messages stored in each fixed memory block, and to clip the fixed memory block corresponding to the message storage when it is determined that the message length is less than len; a memory recycling component, used to recycle the clipped storage space, and dynamically splice the recycled storage space and put it into the cache memory pool.
[0012] According to the network device memory usage device disclosed in the present invention, it also includes: a message processing component, which is used for the CPU1 in the network device to determine the relationship between the message length and len of the message stored in the fixed memory block for each message stored in the fixed memory block, and when the message length is equal to len, directly send the message for processing.
[0013] According to the network device memory usage device disclosed in the present invention, the memory arbitration component is also used for: the cpu1 determines the relationship between the message length and len of the message stored in the fixed memory block. When the message length is less than len, the cpu1 obtains and records the cropped memory size and its memory starting address based on the message length and the starting address of the fixed memory block.
[0014] According to the network device memory usage device disclosed in the present invention, the message processing component is used to process the message stored in each fixed memory block when the cpu1 in the network device determines that the message length of the message stored in the fixed memory block is less than len and obtains and records the cropped memory size and memory starting address.
[0015] According to the network device memory use apparatus disclosed in the present invention, the memory recovery component is composed of cpu2 in the network device, which dynamically splices the cropped memory to the tail of the cache memory pool based on the recorded cropped memory size and memory start address.
[0016] In summary, the network device memory usage method and device disclosed in the present invention are used to cut out memory pools of different specifications according to the size of the message, and the remaining memory space is dynamically recycled. The use of memory pools of different specifications simplifies the structural design of the memory pool, and can effectively improve the efficiency of memory allocation and release. Specifically, it overcomes the shortcomings of low packet receiving and sending performance and low memory utilization when the size of the memory pool is fixed but the size of the message received by the network device is inconsistent, and provides a memory pool management method that can be used multiple times and flexibly. The mechanism of memory utilization and recycling can be applied when the size of the message is inconsistent and the traffic is large. The memory can be reasonably cut according to the size of the message and actively recycled, thereby improving the operating efficiency of the network device on the basis of saving memory.
[0017] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The above and other objects, features and advantages of the present application will become more apparent by describing in detail the exemplary embodiments thereof with reference to the accompanying drawings. The accompanying drawings described below are only some embodiments of the present application, and it is clear to a person skilled in the art that other accompanying drawings can be obtained from these accompanying drawings without creative work.
[0019] Figure 1 What is shown is a flowchart of a method for using memory of a network device according to an embodiment of the present disclosure.
[0020] Figure 2 What is shown is a schematic diagram of the memory pool structure in the network device memory use method according to an embodiment of the present disclosure.
[0021] Figure 3 What is shown is a schematic diagram of memory trimming and memory recycling in a network device memory usage method according to an embodiment of the present disclosure.
[0022] Figure 4 What is shown is a flowchart of memory block content processing, memory trimming and recycling in a network device memory use method according to an embodiment of the present disclosure.
[0023] Figure 5 What is shown is a schematic diagram of the principle of a network device memory usage apparatus according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0025] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, systems, implementations or operations are not shown or described in detail to avoid blurring the various aspects of the present disclosure.
[0026] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0027] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0028] Those skilled in the art will appreciate that the drawings are merely schematic diagrams of example embodiments, and the modules or processes in the drawings are not necessarily necessary for implementing the present disclosure, and therefore cannot be used to limit the protection scope of the present disclosure.
[0029] Figure 1 What is shown is a flowchart of a method for using memory of a network device according to an embodiment of the present disclosure.
[0030] like Figure 1 As shown, in step S102, a memory pool is applied for based on the number n of messages received by the network device and the maximum message length len, wherein the maximum message length len is the maximum value of the message lengths of the messages received by the network device; in step S104, the applied memory pool is divided into n fixed memory blocks, i.e., the size of the fixed memory block is len.
[0031] According to the method for using memory of a network device according to the embodiment of the present disclosure, the application and initialization of the memory pool are first completed with the help of step S102 and step S104. Specifically, the memory space is applied to the operating system at one time according to the number of messages received by the network card each time, and the applied memory space is divided into several memory blocks of fixed size. Memory allocation and memory clipping are first performed in the memory pool. According to the method for using memory of a network device according to the embodiment of the present disclosure, the size of the message is distinguished and uniformly stored in a memory pool of the same size, and then the size of the memory pool is divided according to the frame size received by the current device network card.
[0032] More specifically, suppose the network card receives 32 messages of inconsistent sizes in a round-robin manner. The message sizes are 64 bytes, 1024 bytes, 2048 bytes, 4096 bytes, 9216 bytes, etc., so the total memory occupied by the memory pool is 9216 bytes × 32, that is, the size of each memory block is 9216 bytes. Figure 2 FIG. 1 is a schematic diagram of a memory pool structure in a method for using memory of a network device according to an embodiment of the present disclosure. Figure 2 As shown, the memory pool after the initial application is first divided into memory blocks of the same size, whose size is len, the first address is RingHead, and the first address of the current memory block is data. The above contents are all recorded in the applied address pool.
[0033] like Figure 1 As shown, in step S106, the n messages received by the network device are respectively stored in the n fixed memory blocks; in step S108, for the messages stored in each fixed memory block, the relationship between the message length and len of the message stored in each fixed memory block is determined, and when it is determined that the length of the message is less than len, the fixed memory block corresponding to the message storage is trimmed; in step S110, the trimmed storage space is recycled, and the recycled storage space is dynamically spliced and placed in the cache memory pool.
[0034] More specifically, according to the method for using the memory of a network device according to the embodiment of the present disclosure, after applying for and initializing the memory pool, the memory block is trimmed according to the message size, that is, the current memory block is cut according to the message size received by the network card and pkt_len. First, the received message is directly filled into the memory block starting with RingHead with a memory size of len according to the actual length of the message. At the same time, the CPU determines the relationship between the length of the message and the size of the memory block. When it is determined that the message size is less than the size of the memory block (len), the memory block is trimmed, and the remaining trimmed memory is dynamically recycled. After recycling, the memory slice is spliced to the end of the dynamic memory pool. All messages received by the network card are divided and spliced according to the above-mentioned segmentation and splicing operations, and the above-mentioned operations are repeated, and the messages are copied and the memory space is recycled.
[0035] Figure 3 What is shown is a schematic diagram of memory trimming and memory recycling in a network device memory usage method according to an embodiment of the present disclosure.
[0036] More specifically, Figure 3 As shown, taking the received message size of 1024 bytes as an example, since the current message length is equal to 1024 bytes, it is determined that the message length is less than the fixed memory block size 9216 when stored in the memory block, so the fixed memory block of the message is trimmed, and the 1024-byte message continues to be processed after the memory block is trimmed, and the remaining memory space will be reclaimed by the CPU.
[0037] The network device memory usage method of the disclosed embodiment uses different CPUs for trimming and recycling, wherein CPU1 in the device is used for trimming and CPU2 in the device is used for recycling to improve efficiency.
[0038] According to the network device memory usage method of the embodiment of the present disclosure, it also includes: for each message stored in the fixed memory block, the CPU1 in the network device determines the relationship between the message length and len of the message stored in the fixed memory block, and when the message length is equal to len, directly sends the message for processing. More specifically, if the CPU1 determines that the length of the message is exactly equal to the memory block size, the memory block is not segmented and the message is directly sent for processing.
[0039] According to the network device memory usage method of the embodiment of the present disclosure, it also includes: the CPU1 determines the relationship between the message length and len of the message stored in the fixed memory block, and when the message length is less than len, the CPU1 obtains and records the trimmed memory size and memory start address based on the message length and the start address of the fixed memory block. More specifically, Figure 2 As shown in the figure, when it is determined that the fixed memory block needs to be trimmed, first, the remaining memory size is recorded as the fixed memory block size len minus the received message length pkt_len, that is, len-pkt_len; secondly, the starting position of the remaining memory address is marked as RingHead-pkt_ken to facilitate the memory recycling of cpu2 responsible for recycling; thirdly, the pointing position of RingHead is modified to RingHead-len.
[0040] According to the network device memory usage method of the embodiment of the present disclosure, for each message stored in a fixed memory block, when the CPU 1 in the network device determines that the message length of the message stored in the fixed memory block is less than len and obtains and records the trimmed memory size and memory start address, the CPU 1 processes the message stored in the fixed memory block. More specifically, for example Figure 2As shown, assuming that cpu1 determines that the first message starting from RingHead needs to be pruned, after completing the relevant calculations for memory pruning, cpu1 processes the content in the fixed memory block, and on the other hand, cpu2 reclaims the remaining memory.
[0041] According to the method for using memory of a network device according to an embodiment of the present disclosure, the cpu2 in the network device dynamically splices the cropped memory to the end of the cache memory pool based on the recorded cropped memory size and memory start address. More specifically, according to the method for using memory of a network device according to an embodiment of the present disclosure, after applying for and initializing the memory pool and cropping the memory block according to the message size, the remaining memory is recycled and spliced. Specifically, the address space remaining after the cropping by cpu1 is promptly recycled by cpu2 and put into the cache address pool after dynamic splicing.
[0042] Figure 4 What is shown is a flowchart of memory block content processing, memory trimming and recycling in a network device memory use method according to an embodiment of the present disclosure.
[0043] like Figure 4 As shown, in step S402, message storage is performed, that is, the received message is stored in a fixed memory block.
[0044] In step S404, it is determined whether the message size is equal to the fixed memory block size, that is, it is determined whether the message size of the message stored in the fixed memory block is equal to the fixed memory block size.
[0045] If the result of determining whether the message size is equal to the fixed memory block size in step S404 is "yes", the process proceeds to step S406. In step S406, the current message is processed, that is, the message whose message size is equal to the fixed memory block is directly sent for processing.
[0046] When the result of determining whether the message size is equal to the fixed memory block size in step S404 is "No", proceed to step S410. In step S410, memory clipping is performed. In step S408, message processing is performed, that is, the message stored in the fixed memory block before clipping is processed. In step S412, the remaining memory is recycled, that is, other CPUs in the device dynamically splice the recycled memory and put it into the cache pool for reuse in message storage.
[0047] Figure 5 FIG. 1 is a schematic diagram showing a principle of a network device memory usage device according to an embodiment of the present disclosure. Figure 5 As shown, the device comprises:
[0048] A memory pool application component 502, configured to apply for a memory pool based on the number n of messages received by the network device and a maximum message length len, wherein the maximum message length len is the maximum value of the message lengths of the messages received by the network device;
[0049] A memory pool initialization component 504 is used to divide the applied memory pool into n fixed memory blocks, that is, the size of the fixed memory block is len;
[0050] A storage component 506, configured to store the n messages received by the network device in the n fixed memory blocks respectively;
[0051] A memory clipping component 508 is used to determine the relationship between the message length and len of the message stored in each fixed memory block for the message stored in each fixed memory block, and to clip the fixed memory block corresponding to the message storage when it is determined that the message length is less than len;
[0052] The memory recycling component 510 is used to recycle the cropped storage space and dynamically splice the recycled storage space into the cache memory pool.
[0053] According to the network device memory usage device of the embodiment of the present disclosure, it also includes: a message processing component 512, which is used for the CPU1 in the network device to determine the relationship between the message length and len of the message stored in the fixed memory block for each message stored in the fixed memory block, and when the message length is equal to len, directly send the message for processing.
[0054] According to the network device memory usage device of the embodiment of the present disclosure, the memory arbitration component 508 is also used for: the cpu1 determines the relationship between the message length and len of the message stored in the fixed memory block. When the message length is less than len, the cpu1 obtains and records the cropped memory size and its memory starting address based on the message length and the starting address of the fixed memory block.
[0055] According to the network device memory usage device of the embodiment of the present disclosure, the message processing component 512 is used to process the message stored in each fixed memory block when the cpu1 in the network device determines that the message length of the message stored in the fixed memory block is less than len and obtains and records the cropped memory size and memory starting address.
[0056] According to the network device memory usage apparatus of the embodiment of the present disclosure, the memory recovery component 510 is composed of cpu2 in the network device, which dynamically splices the cropped memory to the tail of the cache memory pool based on the recorded cropped memory size and memory start address.
[0057] In summary, the network device memory usage method and device disclosed in the present invention are used to cut out memory pools of different specifications according to the size of the message, and the remaining memory space is dynamically recycled. The use of memory pools of different specifications simplifies the structural design of the memory pool, and can effectively improve the efficiency of memory allocation and release. Specifically, it overcomes the shortcomings of low packet receiving and sending performance and low memory utilization when the size of the memory pool is fixed but the size of the message received by the network device is inconsistent, and provides a memory pool management method that can be used multiple times and flexibly. The mechanism of memory utilization and recycling can be applied when the size of the message is inconsistent and the traffic is large. The memory can be reasonably cut according to the size of the message and actively recycled, thereby improving the operating efficiency of the network device on the basis of saving memory.
[0058] The software product may be any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0059] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0060] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0061] The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the computer-readable medium implements the following functions: generating a test script according to the type of the device to be tested; parsing the test script to generate multiple command data; calling multiple interfaces corresponding to the types of the multiple command data; sending the multiple command data to the high-acceleration stress screening control box respectively based on the multiple interfaces; the high-acceleration stress screening control box tests the device to be tested according to the command data. The computer-readable medium can also implement the following functions: during the test, the high-acceleration stress screening control box generates a return message in real time; displays the test status based on the return message; and / or generates a test report based on the return message.
[0062] Those skilled in the art will appreciate that the above modules can be distributed in the device according to the description of the embodiment, or can be changed accordingly and only used in one or more devices different from the embodiment. The modules of the above embodiments can be combined into one module, or further divided into multiple sub-modules.
[0063] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the embodiment of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiment of the present application.
[0064] The exemplary embodiments of the present application are specifically shown and described above. It should be understood that the present application is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present application is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended claims.
Claims
1. A method for using memory of a network device, include: Applying for a memory pool based on the number n of messages received by the network device and the maximum message length len, wherein the maximum message length len is the maximum value of the message lengths of the messages received by the network device; Divide the applied memory pool into n fixed memory blocks, that is, the size of the fixed memory block is len; storing the n messages received by the network device in the n fixed memory blocks respectively; For the message stored in each fixed memory block, determine the relationship between the message length and len of the message stored in each fixed memory block, and when it is determined that the length of the message is less than len, cut the fixed memory block corresponding to the message storage; The cropped storage space is reclaimed, and the reclaimed storage space is dynamically spliced and put into the cache memory pool.
2. The method for using network device memory according to claim 1, further comprising: include: For each message stored in the fixed memory block, the CPU 1 in the network device determines the relationship between the message length and len of the message stored in the fixed memory block, and when the message length is equal to len, directly sends the message for processing.
3. The method for using network device memory according to claim 2, further comprising: include: The cpu1 determines the relationship between the message length and len of the message stored in the fixed memory block. When the message length is less than len, the cpu1 obtains and records the cropped memory size and memory starting address based on the message length and the starting address of the fixed memory block.
4. The method for using the network device memory according to claim 3, in, For the message stored in each fixed memory block, when the CPU1 in the network device determines that the message length of the message stored in the fixed memory block is less than len and obtains and records the cropped memory size and memory starting address, the CPU1 processes the message stored in the fixed memory block.
5. The method for using the network device memory according to claim 4, in, The cpu2 in the network device dynamically splices the cut memory to the tail of the cache memory pool based on the recorded cut memory size and memory start address.
6. A network device memory usage device, include: A memory pool application component, used to apply for a memory pool based on the number of messages n received by the network device and a maximum message length len, wherein the maximum message length len is the maximum value of the message lengths of the messages received by the network device; A memory pool initialization component is used to divide the applied memory pool into n fixed memory blocks, that is, the size of the fixed memory block is len; A storage component, used for storing the n messages received by the network device in the n fixed memory blocks respectively; A memory clipping component is used to determine the relationship between the message length and len of the message stored in each fixed memory block for the message stored in each fixed memory block, and to clip the fixed memory block corresponding to the message storage when it is determined that the length of the message is less than len; The memory recycling component is used to recycle the cropped storage space and dynamically splice the recycled storage space into the cache memory pool.
7. The network device memory usage device according to claim 6, further comprising: include: The message processing component is used for the CPU1 in the network device to determine the relationship between the message length and len of the message stored in each fixed memory block, and when the message length is equal to len, directly send the message for processing.
8. The network device memory usage apparatus according to claim 7, wherein the memory arbitration component is further configured to: The cpu1 determines the relationship between the message length and len of the message stored in the fixed memory block. When the message length is less than len, the cpu1 obtains and records the cropped memory size and its memory starting address based on the message length and the starting address of the fixed memory block.
9. The network device memory usage device according to claim 8, in, The message processing component is used for processing the message stored in each fixed memory block when the CPU1 in the network device determines that the message length of the message stored in the fixed memory block is less than len and obtains and records the cropped memory size and memory starting address.
10. The network device memory usage device according to claim 9, in, The memory recycling component is composed of cpu2 in the network device, which dynamically splices the trimmed memory to the tail of the cache memory pool based on the recorded trimmed memory size and memory start address.
