A cache allocation method for a computer communication interface and related devices

By monitoring and adjusting the port transmission status information of the computer communication interface, dynamically optimizing the interface cache allocation, the problem of low bandwidth utilization of the communication interface is solved and communication efficiency is improved.

CN117370223BActive Publication Date: 2025-07-18HAIGUANG INTEGRATED CIRCUIT DESIGN (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311424330.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-30
Publication Date
2025-07-18
Estimated Expiration
2043-10-30

AI Technical Summary

Technical Problem

The bandwidth utilization of computer communication interfaces is low, resulting in a reduced communication efficiency.

Method used

By monitoring the transmission status information of each port in the communication interface, including the average bandwidth, port cache size and average occupancy, the allocation of the interface cache between each port is dynamically adjusted to optimize bandwidth utilization and cache occupancy.

Benefits of technology

The bandwidth utilization and communication efficiency of the communication interface are improved, ensuring that the port cache size is in line with the bandwidth utilization situation, and avoiding becoming a bottleneck.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117370223B_ABST
    Figure CN117370223B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a cache allocation method and related device for a computer communication interface, which relates to the field of computer technology and can effectively improve the bandwidth utilization rate and communication efficiency of the communication interface. The computer communication interface includes an interface cache and at least two ports, and the interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port. The method includes: monitoring the transmission status information of each port in the communication interface within a certain period of time, where the transmission status information includes the average bandwidth of the data passed by the port, the size of the port cache, and the average occupancy of the port cache; determining whether to adjust the allocation of the interface cache among the ports according to the transmission status information. The present invention is applicable to computer technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technologies, and particularly to a cache allocation method and related apparatus for a computer communication interface. Background Art

[0002] With the development of electronic and communication technologies, devices for implementing various functions emerge in an endless stream. To enable these devices to access a computer, the computer provides multiple communication interfaces. However, in many cases, although these communication interfaces theoretically have a large communication bandwidth, in actual use, the actual communication bandwidth is greatly reduced, often having a large gap with the theoretical value, and the bandwidth utilization rate of the communication interface is low, greatly reducing the communication efficiency of the interface. Summary of the Invention

[0003] In view of this, embodiments of the present invention provide a cache allocation method and related apparatus for a computer communication interface, which can effectively improve the bandwidth utilization rate and communication efficiency of the communication interface.

[0004] In a first aspect, an embodiment of the present invention provides a cache allocation method for a computer communication interface. The computer communication interface includes an interface cache and at least two ports. The interface cache is allocated to each port according to a preset rule as a port cache corresponding to each port. The method includes: monitoring transmission status information of each port in the communication interface within a certain period of time, where the transmission status information includes the average bandwidth of data passed by the port, the size of the port cache, and the average occupancy of the port cache; and determining whether to adjust the allocation of the interface cache among the ports according to the transmission status information.

[0005] In an implementation manner, the monitoring of the transmission status information of each port in the communication interface within a certain period of time includes: obtaining the number of data packets transmitted by each port within a certain period of time; and determining the average bandwidth of data passed by each port based on the number of data packets transmitted by each port within a certain period of time.

[0006] In an implementation manner, the obtaining of the number of data packets transmitted by each port within a certain period of time includes: obtaining the number of transmitted data packets of each port multiple times in sequence; and determining the number of data packets transmitted by each port within the time period determined by any two of the obtained operations based on the difference between the number of transmitted data packets obtained any two times.

[0007] In one embodiment, the monitoring of the transmission status information of each port in the communication interface within a certain period of time includes: obtaining the occupancy of the port buffer of each port multiple times in sequence; determining the average value of the occupancy of the port buffer obtained each time, and using the average value as the average occupancy of the port buffer within the period between the first and the last acquisition operations.

[0008] In one embodiment, the determining whether to adjust the allocation of the interface buffer among the ports according to the transmission status information includes: determining the bandwidth utilization rate and the buffer occupancy rate of each port according to the transmission status information; and determining whether to adjust the allocation of the interface buffer among the ports according to the bandwidth utilization rate and the buffer occupancy rate.

[0009] In one embodiment, the determining the bandwidth utilization rate and the buffer occupancy rate of each port according to the transmission status information includes: determining the bandwidth utilization rate according to the average bandwidth of the data passed through each port and the ideal bandwidth of the port, and determining the buffer occupancy rate according to the size of the port buffer of each port and the average occupancy of the port buffer.

[0010] In one embodiment, the determining whether to adjust the allocation of the interface buffer among the ports according to the bandwidth utilization rate and the buffer occupancy rate includes: adjusting the allocation of the interface buffer among the ports when the bandwidth utilization rate corresponding to at least one port is lower than a first threshold and the buffer occupancy rate corresponding to this port is higher than a second threshold.

[0011] In one embodiment, the adjusting the allocation of the interface buffer among the ports when the bandwidth utilization rate corresponding to at least one port is lower than a first threshold and the buffer occupancy rate corresponding to this port is higher than a second threshold includes: determining the port with the bandwidth utilization rate lower than the first threshold and the buffer occupancy rate higher than the second threshold as the target port, and the ports other than the target port in the communication interface as non-target ports; according to a preset policy, allocating the unoccupied part of the port buffer corresponding to at least one non-target port in the communication interface to the target port as the new buffer of the target port.

[0012] In one embodiment, the method of allocating the unoccupied portion of the port buffer corresponding to at least one non-target port in the communication interface to the target port as the new buffer for the target port according to the preset policy includes: determining the buffer gap of the target port according to the difference between the bandwidth utilization rate and the first threshold; starting from the non-target port with the lowest buffer occupancy rate, sequentially extracting at least a part of the buffer from the unoccupied port buffers corresponding to each non-target port and allocating it to the target port as the new buffer for the target port until the size of the new buffer is equal to the size of the buffer gap.

[0013] In one embodiment, the transmission status information includes: transmission status information in the sending direction and / or transmission status information in the receiving direction; the interface buffer includes: a sending buffer used in the sending direction and / or a receiving buffer used in the receiving direction, wherein the sending buffer is allocated to each port according to the preset rule as the sending port buffer corresponding to each port, and the receiving buffer is allocated to each port according to the preset rule as the receiving port buffer corresponding to each port.

[0014] In one embodiment, the method of determining whether to adjust the allocation of the interface buffer among the ports according to the transmission status information includes: determining whether to adjust the allocation of the sending buffer among the ports according to the transmission status information in the sending direction; and / or determining whether to adjust the allocation of the receiving buffer among the ports according to the transmission status information in the receiving direction.

[0015] In a second aspect, an embodiment of the present invention further provides a buffer allocation device for a computer communication interface. The computer communication interface includes an interface buffer and at least two ports. The interface buffer is allocated to each port according to a preset rule as the port buffer corresponding to each port. The device includes: a monitoring unit for monitoring the transmission status information of each port in the communication interface within a certain period of time, where the transmission status information includes the average bandwidth of data passed through the port, the size of the port buffer, and the average occupancy of the port buffer; a determining unit for determining whether to adjust the allocation of the interface buffer among the ports according to the transmission status information.

[0016] In one embodiment, the monitoring unit includes: a first obtaining module for obtaining the number of data packets transmitted by each port within a certain period of time; a first determining module for determining the average bandwidth of data passed through each port based on the number of data packets transmitted by each port within a certain period of time.

[0017] In one embodiment, the determination unit includes: a second determination module, configured to determine the bandwidth utilization rate and cache occupancy rate of each port according to the transmission status information; and a third determination module, configured to determine whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate.

[0018] In one embodiment, the third determination module is specifically configured to adjust the allocation of the interface cache among the ports when the bandwidth utilization rate corresponding to at least one of the ports is lower than a first threshold and the cache occupancy rate corresponding to this port is higher than a second threshold.

[0019] In one embodiment, the communication interface includes at least one of the following: a Peripheral Component Interconnect Express (PCIe) interface, a Compute Express Link (CXL) interface, or a Universal Serial Bus (USB) interface.

[0020] In one embodiment, the transmission status information includes: transmission status information in the sending direction and / or transmission status information in the receiving direction; the interface cache includes: a sending cache used in the sending direction, and / or, a receiving cache used in the receiving direction, wherein the sending cache is allocated to each port according to the preset rule as the sending port cache corresponding to each port, and the receiving cache is allocated to each port according to the preset rule as the receiving port cache corresponding to each port.

[0021] In a third aspect, an embodiment of the present invention further provides a computer system, including a processor and a communication interface controller; the processor is communicatively connected to the communication interface controller; an interface cache and at least two ports are provided in the communication interface controller, each port is used to connect a corresponding communication device, the interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port; the processor is configured to: monitor the transmission status information of each port within a certain time period, the transmission status information including the average bandwidth of the data passed through the port, the size of the port cache, and the average occupancy of the port cache; determine whether to adjust the allocation of the interface cache among the ports according to the transmission status information; the communication interface controller is configured to: record the transmission status information of the data transmission between the processor and each port of the communication interface controller; adjust the allocation of the interface cache among the ports according to the control instruction of the processor, wherein the control instruction is generated by the processor according to the transmission status information.

[0022] Fourth aspect, an embodiment of the present invention further provides an electronic device, which includes: a housing, a processor, a memory, a circuit board and a power supply circuit. Among them, the circuit board is arranged inside the space surrounded by the housing, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to each circuit or device of the above-mentioned electronic device; the memory is used to store executable program codes; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, and is used to execute the cache allocation method for a computer communication interface provided in any embodiment of the present invention.

[0023] Fifth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the cache allocation method for a computer communication interface provided in any embodiment of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0025] Figure 1 It is a flowchart of the cache allocation method for a computer communication interface provided in an embodiment of the present invention;

[0026] Figure 2 It is a schematic diagram of port cache adjustment in the cache allocation method for a computer communication interface provided in an embodiment of the present invention;

[0027] Figure 3 It is a detailed schematic diagram of the cache allocation method for a computer communication interface provided in an embodiment of the present invention;

[0028] Figure 4 It is a schematic structural diagram of a cache allocation device for a computer communication interface provided in an embodiment of the present invention;

[0029] Figure 5 It is a schematic structural diagram of a computer system provided in an embodiment of the present invention;

[0030] Figure 6 It is a schematic structural diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0031] The embodiments of the present invention will be described in detail below with reference to the drawings.

[0032] It should be clear that the described embodiments are only a part of the embodiments of the present invention, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative work belong to the scope of protection of the present invention.

[0033] In a first aspect, an embodiment of the present invention provides a cache allocation method for a computer communication interface, which can effectively improve the bandwidth utilization rate and communication efficiency of the communication interface.

[0034] As Figure 1 shown, an embodiment of the present invention provides a cache allocation method for a computer communication interface. The computer communication interface includes an interface cache and at least two ports. The interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port. The method may include:

[0035] S11, monitor the transmission status information of each port in the communication interface within a certain period of time. The transmission status information includes the average bandwidth of the data passed through the port, the size of the port cache, and the average occupancy of the port cache;

[0036] The communication interface may be an interface provided in a computer for communication between a processor and various terminals, components, etc. For example, in one example, the communication interface may include one or more of the following: a peripheral component interconnect express interface, a compute express link interface, or a universal serial bus interface. Multiple communication channels may be provided in the communication interface (such as lanes in a PCIe interface), and each communication channel may be used for simplex or duplex signal transmission. In an embodiment of the present invention, according to needs, each communication channel of the communication interface may be divided for use by one or more terminals / components. Depending on the type and number of terminals / components connected to the communication interface, the communication interface may be divided into different numbers of ports, and the number of communication channels included in each port may be the same or different. Further, while dividing the communication interface into different numbers of ports, the interface cache in the communication interface may also be divided into each port according to a preset rule to form the port cache of each port for use by the port. The size of the port cache allocated to each port may be stored in a corresponding register in the communication interface. Optionally, the preset rules for dividing the interface cache may include various types. For example, it may be evenly divided according to the number of ports in the communication interface, or according to the busyness of each port, according to the data throughput of each port, according to the number of communication channels included in each port, etc. The embodiments of the present invention do not limit this.

[0037] In this step, the transmission status information of each port in the communication interface can be monitored within a certain period of time. Here, monitoring the transmission status information can either refer to directly obtaining the transmission status information or further calculating based on the obtained information to obtain the transmission status information. The length of the certain period of time here can be set and adjusted as needed. For example, it can be 1 second, 5 seconds, 10 seconds, etc.

[0038] In an embodiment of the present invention, the transmission status information may include the average bandwidth of data passing through the port, the size of the port buffer, and the average occupancy of the port buffer. Among them, the average bandwidth of data passing through the port is used to describe the average rate of data transmission of the port. For example, the average bandwidth of data passing through is 500 Mbps (500 megabits per second). The size of the port buffer can refer to how much buffer is allocated for the port to use. For example, it can be 256 bytes or 512 bytes. The average occupancy of the port buffer can refer to how much of the buffer in the port is occupied on average, that is, how much of the buffer stores data on average. For example, on average, 54 bytes store data.

[0039] S12. Determine whether to adjust the allocation of the interface buffer among the ports according to the transmission status information.

[0040] After the transmission status information is monitored, in this step, it can be determined whether to adjust the allocation of the interface buffer among the ports according to the transmission status information. That is to say, in an embodiment of the present invention, after the interface buffer is allocated to each port, it is not fixed, but can be adjusted according to the transmission status of each port on how to allocate the interface buffer among the ports. For example, according to different transmission status information, the port buffers of some ports may increase, the port buffers of some other ports may decrease, and of course, it is also possible that the port buffers of some ports remain unchanged. Whether adjustment is needed specifically and how to adjust can be determined according to the transmission status information.

[0041] The cache allocation method for a computer communication interface provided by an embodiment of the present invention can monitor the transmission status information of each port in the communication interface, and determine whether to adjust the allocation of the interface cache in the communication interface among the ports according to the transmission status information. Among them, the computer communication interface includes an interface cache and at least two ports, and the interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port. Since the transmission status information includes the average bandwidth of the data passed by the port, the size of the port cache, and the average occupancy of the port cache, it can reflect the bandwidth utilization and cache occupancy of each port. In this way, the size of the port cache allocated by the interface cache to each port can be dynamically adjusted according to the bandwidth utilization and cache occupancy of each port, so that the size of the port cache can adapt to the bandwidth utilization and will not become a bottleneck restricting bandwidth utilization. Therefore, it can effectively improve the bandwidth utilization rate of the port, and further improve the bandwidth utilization rate and communication efficiency of the communication interface.

[0042] Specifically, in an embodiment of the present invention, step S11 of monitoring the transmission status information of each port in the communication interface may include: obtaining the number of data packets transmitted by each port within a certain period of time; and determining the average bandwidth of the data passed by each port based on the number of data packets transmitted by each port within a certain period of time.

[0043] In an example, each port can record the number of data packets that have been transmitted so far (i.e., the number of transmitted data packets). Based on this, obtaining the number of data packets transmitted by each port within a certain period of time may specifically include: obtaining the number of transmitted data packets of each port multiple times in sequence; and determining the number of data packets transmitted by each port within the time period determined by any two acquisition operations according to the difference between the number of transmitted data packets obtained in any two acquisitions. Multiplying the number of data packets by the number of bytes contained in each data packet and the number of bits contained in each byte can obtain the average bandwidth of the data passed by the port within the corresponding time period. Optionally, the data packet here may be, for example, a TLP (Transaction Layer Packet) in a PCIe communication interface.

[0044] For example, in an embodiment of the present invention, at the moment of 1 second, the number of transmitted data packets obtained is 332, at the moment of 2 seconds, the number of transmitted data packets obtained is 591, and at the moment of 3 seconds, the number of transmitted data packets obtained is 864. Then it can be known that within 1 second - 2 seconds, the number of transmitted data packets is 591 - 332 = 259, within 2 seconds - 3 seconds, the number of transmitted data packets is 864 - 591 = 273, and within 1 second - 3 seconds, the number of transmitted data packets is 864 - 332 = 532. Multiply the number of these data packets by the number of bytes contained in each data packet and the number of bits contained in each byte, and the average bandwidth of the data passing through the port within the corresponding time period can be known.

[0045] In addition to monitoring the number of transmitted data packets, in an embodiment of the present invention, the occupancy of the port buffer of each port can also be monitored. Specifically, in an embodiment of the present invention, the monitoring of the transmission status information of each port in the communication interface within a certain time period may include: obtaining the occupancy of the port buffer of each port multiple times in sequence; determining the average value of the occupancy of the port buffer obtained each time, and using this average value as the average occupancy of the port buffer within the time period between the first and the last acquisition operations.

[0046] For example, in an embodiment of the present invention, at the moment of 1 second, the occupancy of the port buffer obtained is 46, at the moment of 2 seconds, the number of transmitted data packets obtained is 90, at the moment of 3 seconds, the number of transmitted data packets obtained is 77, at the moment of 4 seconds, the occupancy of the port buffer obtained is 35, at the moment of 5 seconds, the occupancy of the port buffer obtained is 10, at the moment of 6 seconds, the occupancy of the port buffer obtained is 58, and at the moment of 7 seconds, the occupancy of the port buffer obtained is 99. Then the average value of the occupancy of the port buffer obtained in these 7 times is (46 + 90 + 77 + 35 + 10 + 58 + 99) / 7 = 59.3 (rounded to one decimal place), and this average value of 59.3 can be used as the average occupancy of the port buffer within the time period from 1 second to 7 seconds.

[0047] After obtaining the above - mentioned transmission status information, it is possible to determine whether to adjust the allocation of the interface buffer among the ports in step S12. Specifically, determining whether to adjust the allocation of the interface buffer among the ports according to the transmission status information may include: determining the bandwidth utilization rate and cache occupancy rate of each port according to the transmission status information; determining whether to adjust the allocation of the interface buffer among the ports according to the bandwidth utilization rate and the cache occupancy rate.

[0048] Optionally, in one embodiment, determining the bandwidth utilization rate and cache occupancy rate of each port according to the transmission status information includes: determining the bandwidth utilization rate according to the average bandwidth of data passing through each port and the ideal bandwidth of the port, and determining the cache occupancy rate according to the size of the port cache of each port and the average occupancy of the port cache.

[0049] For the bandwidth utilization rate, the bandwidth utilization rate can be equal to the ratio of the above-mentioned average bandwidth to the above-mentioned ideal bandwidth, and the cache occupancy rate can be equal to the ratio of the average occupancy of the port cache to the size of the port cache. Among them, the ideal bandwidth is the ideal value determined during the design of the port bandwidth and is a known quantity. The size of the port cache is the size of the cache allocated to the port.

[0050] It should be noted that in the embodiments of the present invention, the length of the time period for monitoring the transmission status information can be set and adjusted as needed. The shorter the time period, the more sensitive the cache adjustment is to the change in bandwidth, which is beneficial to maintaining a high level of bandwidth utilization; the longer the time period, the less sensitive the cache adjustment is to the change in bandwidth, which is beneficial to reducing the overly frequent cache allocation adjustment caused by bandwidth fluctuations.

[0051] For the cache occupancy rate, in an example, the port cache is 64 bytes in size. Among them, 30 bytes of the cache store data (that is, 30 bytes of the cache are occupied). Then, in this embodiment, the cache occupancy is 30, the cache size is 64, and the cache occupancy rate is 30 / 64.

[0052] After determining the bandwidth utilization rate and cache occupancy rate of each port based on the transmission status information, it is possible to determine whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate. Specifically, determining whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate may specifically include: when the bandwidth utilization rate corresponding to at least one port is lower than a first threshold and the cache occupancy rate corresponding to this port is higher than a second threshold, adjusting the allocation of the interface cache among the ports. Among them, both the first threshold and the second threshold are numbers greater than 0 and less than or equal to 1, and the specific values can be set or adjusted as needed. Exemplarily, in an example, the first threshold may be 70%-90%, and the second threshold may be 90%-100%. That is to say, if there is a port with a low bandwidth utilization rate (such as lower than 75%) in the communication interface, it can be further determined whether the cache occupancy rate of the port cache of this port is very high (such as higher than 95%). If so, it can be considered that it is very likely that the cache occupancy rate is too high, resulting in the data to be transmitted not being cached in time, which further affects the bandwidth. Therefore, the allocation of the interface cache among the ports can be adjusted to increase the port cache of this port.

[0053] Optionally, in an embodiment of the present invention, when the bandwidth utilization rate corresponding to at least one port is lower than a first threshold and the cache occupancy rate corresponding to this port is higher than a second threshold, adjusting the allocation of the interface cache among the ports may specifically include: determining the port with the bandwidth utilization rate lower than the first threshold and the cache occupancy rate higher than the second threshold as the target port, and the ports other than the target port in the communication interface as non-target ports; according to a preset policy, allocating the unoccupied part of the port cache corresponding to at least one non-target port in the communication interface to the target port as the new cache of the target port. Optionally, the new cache and the original port cache of this target port may be continuous with each other or not continuous with each other, as long as the corresponding cache can be accessed according to the address.

[0054] For example, in an example, the communication interface C includes port C1, port C2, and port C3. Among them, the bandwidth occupancy rate of port C1 is 95%, the cache occupancy rate is 60%, the bandwidth occupancy rate of port C2 is 65%, the cache occupancy rate is 98%, and the bandwidth occupancy rate of port C3 is 80%, and the cache occupancy rate is 100%. If the first threshold is 85% and the second threshold is 90%, then port C1 is a non-target port, port C2 is a target port, and port C3 is a target port. Then, a part of the unoccupied cache of port C1 can be allocated to port C2 and port C3 respectively as the new cache of port C2 and the new cache of port C3.

[0055] When allocating the unoccupied part of the port buffer corresponding to at least one non-target port in the communication interface to the target port as the new cache of the target port, there can be various allocation strategies. For example, a part of the unoccupied cache can be drawn from each of multiple non-target ports and allocated to one or more target ports, or, alternatively, a part of the unoccupied cache can be drawn from one non-target port and allocated to one or more target ports. Optionally, the proportion of the drawn cache in the unoccupied cache can be various. For example, 50% of the unoccupied cache in non-target port D can be drawn out and allocated to other target ports, and 80% of the unoccupied cache in non-target port E can be drawn out and allocated to other target ports.

[0056] Specifically, in an embodiment of the present invention, allocating the unoccupied part of the port buffer corresponding to at least one non-target port in the communication interface to the target port as the new cache of the target port according to a preset strategy may include: determining the cache gap of the target port according to the difference between the bandwidth utilization rate and the first threshold; starting from the non-target port with the lowest cache occupancy rate, sequentially drawing at least a part of the cache from the unoccupied port buffers corresponding to each of the non-target ports and allocating it to the target port as the new cache of the target port until the size of the new cache is equal to the size of the cache gap. In this way, on the one hand, it can roughly determine the lack degree of the port buffer of the target port according to the difference between the bandwidth utilization rate of each target port and the first threshold, so that the size of the new cache required by the target port is clearer, which is more conducive to the reasonable utilization of cache resources and effectively improves the cache adjustment efficiency. On the other hand, it can also make full use of the port buffer with the lowest cache occupancy rate for cache allocation adjustment, effectively avoiding or reducing the situation that the non-target port lacks cache due to the extraction of a part of the unoccupied cache in the non-target port. Of course, if the size of the new cache is still smaller than the gap cache after drawing a part of the port buffer from all non-target ports, the cache allocation adjustment can be stopped.

[0057] For example, in one example, the bandwidth utilization rate of the target port D1 is 60%, the first threshold is 90%, and the cache occupancy rate of the target port D1 is 100%. Since the 60% is still 30% away from the first threshold of 90% and the gap is relatively large, it is necessary to multiply the original bandwidth utilization rate of 60% by 1.5 times to reach it. Therefore, it can be determined that the cache gap of the target port D1 is also relatively large. For example, it can be determined that the cache gap is 0.5 times the original port cache in the target port D1. If the original port cache in D1 is 32 bytes, the cache gap can be determined to be 16 bytes. Assume that the cache utilization rate of the non-target port D2 is 40%, the cache utilization rate of the non-target port D3 is 60%, and the cache utilization rate of the non-target port D4 is 80%. Then, a part of the cache can be extracted from the unoccupied cache of the non-target port D2 according to a preset ratio (such as 50%), then a part of the cache can be extracted from the unoccupied cache of the non-target port D3 according to a preset ratio (such as 50%), and finally a part of the cache can be extracted from the unoccupied cache of the non-target port D4 according to a preset ratio (such as 50%) until the newly added cache reaches the cache gap. For example, if the unoccupied cache in D2 is 12 bytes, the unoccupied cache in D3 is 20 bytes, and the unoccupied cache in D4 is 12 bytes, then 6 bytes can be extracted from the unoccupied cache of D2, and 10 bytes can be extracted from the unoccupied cache of D3. Since 16 bytes have been extracted at this time, which is equal to the cache gap, there is no need to extract cache from D4.

[0058] In the above embodiments, the data packet transmission and the use of port caches in each port of the communication interface are generally described. However, more specifically, in some embodiments of the present invention, the communication performed in each port can have a direction difference. For example, a port can send data packets or receive data packets, so sending data packets and receiving data packets belong to communications in different directions. Correspondingly, in an embodiment of the present invention, the transmission status information may include: transmission status information in the sending direction and / or transmission status information in the receiving direction; the interface cache may include: a sending cache used in the sending direction, and / or, a receiving cache used in the receiving direction, where the sending cache is allocated to each port according to the preset rule as the sending port cache corresponding to each port, and the receiving cache is allocated to each port according to the preset rule as the receiving port cache corresponding to each port. Then, based on this, determining whether to adjust the allocation of the interface cache among the ports according to the transmission status information may specifically include: determining whether to adjust the allocation of the sending cache among the ports according to the transmission status information in the sending direction; and / or, determining whether to adjust the allocation of the receiving cache among the ports according to the transmission status information in the receiving direction.

[0059] That is to say, in the embodiments of the present invention, when adjusting the distribution of the interface cache among ports, the transmit cache and the receive cache are adjusted separately, and no mutual adjustment is made between the transmit cache and the receive cache. However, the embodiments of the present invention are not limited thereto. In other embodiments of the present invention, part of the transmit cache may also be adjusted to the receive cache, or part of the receive cache may be adjusted to the transmit cache as needed, and the embodiments of the present invention do not limit this.

[0060] Exemplarily, taking the PCIe communication interface as an example, the adjustment of the port cache will be briefly described. As Figure 2 shown, in an embodiment of the present invention, there are four ports, namely port 0, port 1, port 2, and port 3, in the PCIe communication interface controller, and each port contains four lanes (indicated by ×4 in the figure). Among them, port 0 and port 1 are respectively connected to corresponding PCIe devices. For each port, it may include a transaction layer (TL) and a data link layer (DLL) cache. The transaction layer defines the bus transactions used by the PCIe bus. These transactions can be transmitted to other PCIe devices. When PCIe devices access each other, the transmitted data packets will be packed into one or more transaction layer packets (TLP) by the transaction layer, and these TLP can be sent to the requested device through the PCIe bus. The data link layer cache can cache the TLP to be sent or the received TLP respectively during the sending or receiving of the TLP. The operating system can transmit status information from the PCIe controller and adjust the port cache allocated to each port according to the obtained transmission status information.

[0061] The following will detail the cache allocation method for a computer communication interface provided by the embodiments of the present invention through a specific embodiment.

[0062] As Figure 3 shown, the cache allocation method for a computer communication interface provided by the embodiments of the present invention may include:

[0063] S201. Obtain the number of transmitted data packets of each port and the occupancy of the port cache used for transmitting the data packets at preset time intervals respectively;

[0064] S202. Determine the number of data packets transmitted by each port during the time period determined by the two acquisition operations according to the difference between the number of transmitted data packets obtained in the first and last acquisitions; based on the number of data packets transmitted by each port during the time period, determine the average bandwidth of each port for data.

[0065] S203. Determine the average occupancy of the port buffer obtained each time, and use the average value as the average occupancy of the port buffer during the time period between the first and the last acquisition operations.

[0066] S204. Determine the bandwidth utilization rate according to the average bandwidth of the data passing through each port and the ideal bandwidth of the port, and determine the cache occupancy rate according to the size of the port buffer of each port and the average occupancy of the port buffer.

[0067] S205. Determine the target ports as the ports with the bandwidth utilization rate lower than the first threshold and the cache occupancy rate higher than the second threshold, and the ports other than the target ports in the communication interface are non-target ports.

[0068] S206. According to a preset policy, allocate the unoccupied part of the port buffer corresponding to at least one non-target port in the communication interface to the target port as the new cache of the target port.

[0069] In a second aspect, an embodiment of the present invention further provides a cache allocation device for a computer communication interface, which can effectively improve the bandwidth utilization rate and communication efficiency of the communication interface.

[0070] As Figure 4 shown, the cache allocation device for a computer communication interface provided by the embodiment of the present invention, the computer communication interface includes an interface cache and at least two ports, and the interface cache is allocated to each port according to a preset rule as the port buffer corresponding to each port. The device may include:

[0071] A monitoring unit 31, configured to monitor the transmission status information of each port in the communication interface during a certain time period, where the transmission status information includes the average bandwidth of the data passing through the port, the size of the port buffer, and the average occupancy of the port buffer.

[0072] A determination unit 32, configured to determine whether to adjust the allocation of the interface cache among the ports according to the transmission status information.

[0073] The cache allocation device for a computer communication interface provided by an embodiment of the present invention can monitor the transmission status information of each port in the communication interface, and determine whether to adjust the allocation of the interface cache in the communication interface among the ports according to the transmission status information. Among them, the computer communication interface includes an interface cache and at least two ports, and the interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port. Since the transmission status information includes the average bandwidth of the data passed by the port, the size of the port cache, and the average occupancy of the port cache, it can reflect the bandwidth utilization and cache occupancy of each port. In this way, the size of the port cache allocated by the interface cache to each port can be dynamically adjusted according to the bandwidth utilization and cache occupancy of each port, so that the size of the port cache can adapt to the bandwidth utilization situation and will not become a bottleneck restricting bandwidth utilization. Therefore, it can effectively improve the bandwidth utilization rate of the port, and further improve the bandwidth utilization rate and communication efficiency of the communication interface.

[0074] In one implementation, the monitoring unit 31 may include:

[0075] The first acquisition module is used to acquire the number of data packets transmitted by each port within a certain time period;

[0076] The first determination module is used to determine the average bandwidth of the data passed by each port based on the number of data packets transmitted by each port within a certain time period.

[0077] In one implementation, the determination unit 32 may include:

[0078] The second determination module is used to determine the bandwidth utilization rate and cache occupancy rate of each port according to the transmission status information;

[0079] The third determination module is used to determine whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate.

[0080] In one implementation, the third determination module is specifically used to adjust the allocation of the interface cache among the ports when the bandwidth utilization rate corresponding to at least one port is lower than the first threshold and the cache occupancy rate corresponding to this port is higher than the second threshold.

[0081] In one implementation, the communication interface includes at least one of the following: a peripheral component interconnect express interface, a compute express link interface, or a universal serial bus interface.

[0082] In one embodiment, the transmission status information includes: transmission status information in the sending direction and / or transmission status information in the receiving direction; the interface buffer includes: a sending buffer used in the sending direction and / or a receiving buffer used in the receiving direction, wherein the sending buffer is allocated to each port according to the preset rule as the sending port buffer corresponding to each port, and the receiving buffer is allocated to each port according to the preset rule as the receiving port buffer corresponding to each port.

[0083] In a third aspect, an embodiment of the present invention further provides a computer system, as Figure 5 shown, the computer system may include a processor 41 and a communication interface controller 42; the processor 41 is communicatively connected to the communication interface controller 42;

[0084] An interface buffer 420 and at least two ports 421 are provided in the communication interface controller 42. Each port 421 is used to connect a corresponding communication device (not shown). The interface buffer 420 is allocated to each port 421 according to a preset rule as the port buffer corresponding to each port;

[0085] The processor 41 can be used to: monitor the transmission status information of each port 421 within a certain time period, where the transmission status information includes the average bandwidth of the data passed through the port 421, the size of the port buffer, and the average occupancy of the port buffer; determine whether to adjust the allocation of the interface buffer 420 among the ports 421 according to the transmission status information;

[0086] The communication interface controller 42 can be used to: record the transmission status information of data transmission between the processor 41 and each port 421 of the communication interface controller 42 itself; adjust the allocation of the interface buffer 420 among the ports 421 according to the control instruction of the processor 41, where the control instruction is generated by the processor 41 according to the transmission status information.

[0087] The computer system provided by an embodiment of the present invention has a processor that can monitor the transmission status information of each port in a communication interface controller and determine whether to adjust the allocation of the interface cache in the communication interface among the ports according to the transmission status information. Among them, the computer communication interface includes an interface cache and at least two ports, and the interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port. Since the transmission status information includes the average bandwidth of the data passed through the port, the size of the port cache, and the average occupancy of the port cache, it can reflect the bandwidth utilization and cache occupancy of each port. In this way, the size of the port cache allocated from the interface cache to each port can be dynamically adjusted according to the bandwidth utilization and cache occupancy of each port, so that the size of the port cache can adapt to the bandwidth utilization and will not become a bottleneck restricting bandwidth utilization. Therefore, it can effectively improve the bandwidth utilization rate of the port, and further improve the bandwidth utilization rate and communication efficiency of the communication interface.

[0088] In one implementation, the communication interface controller 42 can respectively set corresponding transmission status registers and cache configuration registers for each port 421. Specifically, the processor 41 can be used to monitor the transmission status information according to the data in the transmission status register. Specifically, the communication interface controller 42 can be used to modify the values of the cache configuration registers corresponding to each port according to the control instructions issued by the processor to adjust the allocation of the interface cache 420 among the ports 421. For example, in an embodiment of the present invention, the processor 41 can obtain the address range of each port cache and the distribution range of the occupied cache therein through the transmission status register in the communication interface controller, so as to configure the address range of the unoccupied port cache into the cache configuration registers of other ports to allocate the unoccupied port cache in one port to other ports for use.

[0089] In a fourth aspect, an embodiment of the present invention further provides an electronic device that can effectively improve the bandwidth utilization rate and communication efficiency of a communication interface.

[0090] As Figure 6 shown, the electronic device provided by an embodiment of the present invention may include: a housing 51, a processor 52, a memory 53, a circuit board 54, and a power supply circuit 55. Among them, the circuit board 54 is arranged inside the space surrounded by the housing 51, and the processor 52 and the memory 53 are arranged on the circuit board 54; the power supply circuit 55 is used to supply power to each circuit or device of the above-mentioned electronic device; the memory 53 is used to store executable program codes; the processor 52 runs a program corresponding to the executable program code by reading the executable program codes stored in the memory 53, and is used to execute the cache allocation method for a computer communication interface provided in any of the foregoing embodiments.

[0091] The specific execution process of the above steps by the processor 52 and the steps further executed by the processor 52 by running the executable program code can be referred to the description of the foregoing embodiments and will not be elaborated herein.

[0092] In a fifth aspect, an embodiment of the present invention further provides a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to implement any one of the cache allocation methods for a computer communication interface provided by the foregoing embodiments, and thus can also achieve corresponding technical effects. Details have been described in the foregoing, and will not be elaborated herein.

[0093] It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0094] Each embodiment in this specification is described in a related manner. For the same or similar parts between the embodiments, reference can be made to each other. The key point of each embodiment is to illustrate the differences from other embodiments.

[0095] In particular, for the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0096] For the convenience of description, the above apparatus is described by dividing it into various units / modules according to functions. Of course, when implementing the present invention, the functions of each unit / module can be implemented in the same or multiple software and / or hardware.

[0097] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a magnetic disk, an optical disc, a read-only memory (ROM), or a random access memory (RAM), etc.

[0098] As described above, the above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A cache allocation method for a computer communication interface, characterized in that The computer communication interface includes an interface cache and at least two ports. The interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port. The method includes: Monitoring the transmission status information of each port in the communication interface within a certain period of time. The transmission status information includes the average bandwidth of data passed through the port, the size of the port cache, and the average occupancy of the port cache. Determining whether to adjust the allocation of the interface cache among the ports according to the transmission status information. The determining whether to adjust the allocation of the interface cache among the ports according to the transmission status information includes: determining the bandwidth utilization rate and cache occupancy rate of each port according to the transmission status information; and determining whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate. The determining whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate includes: adjusting the allocation of the interface cache among the ports when the bandwidth utilization rate corresponding to at least one port is lower than a first threshold and the cache occupancy rate corresponding to this port is higher than a second threshold. The adjusting the allocation of the interface cache among the ports when the bandwidth utilization rate corresponding to at least one port is lower than a first threshold and the cache occupancy rate corresponding to this port is higher than a second threshold includes: determining the port with the bandwidth utilization rate lower than the first threshold and the cache occupancy rate higher than the second threshold as the target port, and the ports other than the target port in the communication interface as non-target ports; and according to a preset policy, allocating the unoccupied part of the port cache corresponding to at least one non-target port in the communication interface to the target port as the new cache of the target port.

2. The method according to claim 1, wherein The monitoring the transmission status information of each port in the communication interface within a certain period of time includes: Obtaining the number of data packets transmitted by each port within a certain period of time. Determining the average bandwidth of data passed through each port based on the number of data packets transmitted by each port within a certain period of time.

3. The method according to claim 2, wherein The obtaining the number of data packets transmitted by each port within a certain period of time includes: Obtaining the number of transmitted data packets of each port multiple times successively. Determining the number of data packets transmitted by each port within the time period determined by two obtaining operations according to the difference between the number of transmitted data packets obtained any two times.

4. The method according to claim 1, wherein The monitoring the transmission status information of each port in the communication interface within a certain period of time includes: Obtaining the occupancy of the port cache of each port multiple times successively. Determining the average value of the occupancy of the port cache obtained each time, and using the average value as the average occupancy of the port cache within the time period between the first and the last obtaining operations.

5. The method according to claim 1, characterized in that, The determining the bandwidth utilization rate and cache occupancy rate of each port according to the transmission status information includes: Determine the bandwidth utilization rate according to the average bandwidth of data passing through each said port and the ideal bandwidth of the port, and determine the cache occupancy rate according to the size of the port cache of each said port and the average occupancy of the port cache.

6. The method according to claim 1, wherein The step of allocating the unoccupied part of the port cache corresponding to at least one non-target port in the communication interface to the target port as the new cache of the target port according to a preset policy includes: Determine the cache gap of the target port according to the difference between the bandwidth utilization rate and the first threshold; Starting from the non-target port with the lowest cache occupancy rate, sequentially extract at least a part of the cache from the unoccupied port caches corresponding to each non-target port and allocate it to the target port as the new cache of the target port until the size of the new cache is equal to the size of the cache gap.

7. The method according to any one of claims 1 to 6, characterized in that, The transmission status information includes: transmission status information in the sending direction and / or transmission status information in the receiving direction; The interface cache includes: a sending cache used in the sending direction and / or a receiving cache used in the receiving direction, wherein the sending cache is allocated to each port according to the preset rule as the sending port cache corresponding to each port, and the receiving cache is allocated to each port according to the preset rule as the receiving port cache corresponding to each port.

8. The method according to claim 7, wherein The step of determining whether to adjust the allocation of the interface cache among the ports according to the transmission status information includes: Determine whether to adjust the allocation of the sending cache among the ports according to the transmission status information in the sending direction; and / or Determine whether to adjust the allocation of the receiving cache among the ports according to the transmission status information in the receiving direction.

9. A cache allocation device for a computer communication interface, characterized in that, The computer communication interface includes an interface cache and at least two ports, the interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port, and the device includes: A monitoring unit for monitoring the transmission status information of each port in the communication interface within a certain period of time, the transmission status information including the average bandwidth of data passing through the port, the size of the port cache, and the average occupancy of the port cache; A determination unit for determining whether to adjust the allocation of the interface cache among the ports according to the transmission status information; The determination unit includes: a second determination module for determining the bandwidth utilization rate and cache occupancy rate of each port according to the transmission status information; a third determination module for determining whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate; The third determination module is specifically configured to adjust the allocation of the interface cache among the ports when the bandwidth utilization rate corresponding to at least one port is lower than the first threshold and the cache occupancy rate corresponding to the port is higher than the second threshold; When the bandwidth utilization rate corresponding to at least one of the ports is lower than a first threshold and the cache occupancy rate corresponding to the port is higher than a second threshold, adjusting the allocation of the interface cache among the ports includes: determining a target port whose bandwidth utilization rate is lower than the first threshold and whose cache occupancy rate is higher than the second threshold, and the ports other than the target port in the communication interface are non-target ports; according to a preset policy, allocating the unoccupied part of the port cache corresponding to at least one non-target port in the communication interface to the target port as the new cache of the target port.

10. The device according to claim 9, wherein The monitoring unit includes: a first acquisition module, configured to acquire the number of data packets transmitted by each port within a certain period of time; a first determination module, configured to determine the average bandwidth of each port passing through data based on the number of data packets transmitted by each port within a certain period of time.

11. The device according to any one of claims 9 to 10, characterized in that, The communication interface includes at least one of the following: a Peripheral Component Interconnect Express (PCIe) interface, a Compute Express Link (CXL) interface, or a Universal Serial Bus (USB) interface.

12. The device according to any one of claims 9 to 10, characterized in that The transmission status information includes: transmission status information in the sending direction and / or transmission status information in the receiving direction; The interface cache includes: a transmission cache used in the sending direction and / or a receiving cache used in the receiving direction, wherein the transmission cache is allocated to each port according to the preset rule as the sending port cache corresponding to each port, and the receiving cache is allocated to each port according to the preset rule as the receiving port cache corresponding to each port.

13. A computer system, characterized in that, including a processor and a communication interface controller; the processor is communicatively connected to the communication interface controller; The communication interface controller is provided with an interface cache and at least two ports, each port is used to connect a corresponding communication device, and the interface cache is allocated to each port according to a preset rule as the port cache corresponding to each port; The processor is configured to: monitor the transmission status information of each port within a certain period of time, where the transmission status information includes the average bandwidth of the port passing through data, the size of the port cache, and the average occupancy of the port cache; determine whether to adjust the allocation of the interface cache among the ports according to the transmission status information; The communication interface controller is configured to: record the transmission status information of data transmission between the processor and each port of the communication interface controller; adjust the allocation of the interface cache among the ports according to the control instruction of the processor, where the control instruction is generated by the processor according to the transmission status information; The determining whether to adjust the allocation of the interface cache among the ports according to the transmission status information includes: determining the bandwidth utilization rate and cache occupancy rate of each port according to the transmission status information; determining whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate; Determining whether to adjust the allocation of the interface cache among the ports according to the bandwidth utilization rate and the cache occupancy rate includes: when the bandwidth utilization rate corresponding to at least one of the ports is lower than a first threshold and the cache occupancy rate corresponding to this port is higher than a second threshold, adjusting the allocation of the interface cache among the ports; When the bandwidth utilization rate corresponding to at least one of the ports is lower than a first threshold and the cache occupancy rate corresponding to this port is higher than a second threshold, adjusting the allocation of the interface cache among the ports includes: determining the port with the bandwidth utilization rate lower than the first threshold and the cache occupancy rate higher than the second threshold as the target port, and the ports other than the target port in the communication interface as non-target ports; according to a preset policy, allocating the unoccupied part of the port cache corresponding to at least one non-target port in the communication interface to the target port as the new cache of the target port.

14. An electronic device, characterized in that, The electronic device includes: a housing, a processor, a memory, a circuit board, and a power supply circuit. Among them, the circuit board is arranged inside the space surrounded by the housing, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to each circuit or device of the above-mentioned electronic device; the memory is used to store executable program codes; the processor runs the program corresponding to the executable program codes by reading the executable program codes stored in the memory, and is used to execute the cache allocation method for a computer communication interface according to any one of the preceding claims 1 to 8.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the cache allocation method for a computer communication interface according to any one of the preceding claims 1 to 8.

Citation Information

Patent Citations

  • Multichannel cache distribution method and device

    CN101957800A

  • Shared cache system and method, electronic equipment and storage medium

    CN112953853A