Data processing method and related device
By associating RDMA data with the storage area and completion queue under the same thread, the thread switching problem in RDMA data processing is solved, improving CPU utilization and reducing latency.
Patent Information
- Application Number
- CN202310209435.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-27
- Publication Date
- 2024-08-27
AI Technical Summary
During the RDMA data processing process, there is a thread switching problem, which causes the data processing delay to increase.
By associating RDMA data with the corresponding storage area and completion queue under the same thread, single-thread processing is achieved and cross-thread access and thread switching are avoided.
It improves the effective utilization of the CPU, reduces the latency of RDMA data processing, and avoids the overhead caused by thread switching.
Smart Images

Figure CN118550854A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a data processing method and related devices. Background Art
[0002] Remote direct memory access (RDMA) is a transport layer network protocol that uses queue pairs (QPs) to send and receive consumer data over the network. See Figure 1 , Figure 1 This is a schematic diagram of an architecture for RDMA data processing. Figure 1 In the QP, there are 1 send queue (SQ) and 1 receive queue (RQ). SQ is responsible for RDMA operations on the request side, and RQ is responsible for RDMA message processing on the response side. QP is associated with a completion queue (CQ). On the request side of the RDMA operation, the processor submits a work queue element (WQE) in its corresponding SQ according to the work request (WR) submitted by the consumer process. The network card encapsulates the RDMA operation indicated by the WQE and the data corresponding to the RDMA operation into a message and sends it to the network through the port. When the network card completes an RDMA operation indicated by a WQE, it writes a completion queue entry (CQE) in the CQ associated with the SQ, so that when the processor processes the CQE, it notifies the consumer that a certain WR submitted by it has completed the RDMA operation processing.
[0003] However, currently, after receiving data through QP, there is generally a problem of thread switching during data processing, which increases the latency of data processing. Summary of the invention
[0004] The present application provides a data processing method and related devices, which can avoid the problem of thread switching.
[0005] In a first aspect, the present application provides a data processing method, which includes: first, receiving first information, second information and RDMA data, wherein the first information indicates a storage area of the RDMA data, the second information indicates information of a completion queue CQ, and the storage area and CQ are associated with the same thread; then, processing the RDMA data according to the first information and the second information.
[0006] In the present application, after receiving the RDMA data, single-thread processing of the RDMA data is achieved by associating the RDMA data with the corresponding storage area and CQ under the same thread, avoiding the problem of thread switching caused by cross-thread access, improving the effective utilization of the CPU, and reducing the latency of RDMA data processing.
[0007] In a possible implementation manner of the first aspect, processing data according to the first information and the second information includes:
[0008] storing the RDMA data in a storage area according to the first information, and generating a completion queue element CQE;
[0009] The CQE is placed into the corresponding CQ according to the second information to process the RDMA data.
[0010] In this possible implementation, the storage area of the RDMA data is indicated by the first information, and the location of the CQE generated after the data is stored in the CQ is indicated by the second information, so as to implement single-threaded processing of the RDMA data.
[0011] In a possible implementation manner of the first aspect, the first information includes a number of a non-uniform memory access NUMA node, and according to the first information, the RDMA data is stored in a storage area, and a completion queue element CQE is generated, including:
[0012] Determine the NUMA node according to the NUMA node number;
[0013] Get the work queue element WQE from the memory corresponding to the NUMA node;
[0014] The RDMA data is stored in the storage area specified in the WQE and a CQE is generated.
[0015] In this possible implementation, RDMA data is stored in the memory of a specified NUMA node to implement RDMA data processing on the same NUMA node, thereby avoiding cross-NUMA processing of RDMA data and reducing RDMA data processing latency.
[0016] In a possible implementation manner of the first aspect, obtaining a work queue element WQE from a memory corresponding to a NUMA node includes:
[0017] Determine the shared receive queue SRQ corresponding to the NUMA node;
[0018] Get the WQE from the SRQ's memory.
[0019] In this possible implementation, the SRQ policy is adopted to store the RDMA data in the SRQ corresponding to the specified NUMA node, thereby saving memory space.
[0020] In a possible implementation manner of the first aspect, the second information includes a number CQN of the CQ, and placing the CQE into the corresponding CQ according to the second information to process the RDMA data includes:
[0021] Determine the CQ where the CQE is stored based on the CQN;
[0022] The CQE is placed in the CQ to process the RDMA data.
[0023] In this possible implementation, after the RDMA data is stored in the specified storage area, the CQE generated by the stored RDMA data is stored in the CQ associated with the storage area under the same thread, thereby achieving single-thread processing of the RDMA data and avoiding the problems of cross-thread access and thread switching.
[0024] In a possible implementation manner of the first aspect, the method includes:
[0025] Get the correspondence between threads and CQ;
[0026] Send the corresponding relationship.
[0027] In this possible implementation, by sending the correspondence between the thread and the CQ, the device receiving the correspondence can specify the RDMA data processing thread of the local end through the correspondence when establishing an RDMA connection with the local end, thereby ensuring single-threaded processing of the RDMA data.
[0028] In a possible implementation manner of the first aspect, the processing specifically includes:
[0029] Use threads to determine the storage area of the RDMA data from the CQ;
[0030] A thread is used to obtain the RDMA data from the storage space to process the RDMA data.
[0031] In this implementation, the storage space of the RDMA data is obtained from the corresponding CQ based on the same thread, and the RDMA data is processed, thereby avoiding the problem of cross-thread access and processing of the RDMA data.
[0032] In a possible implementation manner of the first aspect, receiving the first information, the second information, and the RDMA data includes:
[0033] The first information, the second information and the RDMA data are received using the RDMA interface card.
[0034] In a second aspect, the present application provides a data processing method, comprising:
[0035] Receive RDMA data;
[0036] The completion queue element CQE is placed in the specified completion queue CQ to process the RDMA data. The CQE is obtained based on the stored RDMA data, and the CQ corresponds to the thread one by one.
[0037] In the present application, by placing the CQE corresponding to the stored RDMA data in a specified CQ and making a one-to-one correspondence between the CQ and the thread, single-thread processing of the RDMA data is achieved, thereby avoiding the problem of thread switching.
[0038] In a possible implementation manner of the second aspect, placing the CQE into a specified CQ to process the RDMA data includes:
[0039] Get the index corresponding to CQE and the total number of all CQs;
[0040] The remainder of the index and the total number is used as the CQ number;
[0041] Place the CQE into the CQ corresponding to the number to process the RDMA data.
[0042] In this possible implementation, CQEs are placed in different CQs by taking the remainder, so that CQEs corresponding to different RDMA data are mapped to different threads for processing, thereby implementing single-threaded processing of RDMA data.
[0043] In a possible implementation manner of the second aspect, placing the CQE into a specified CQ to process the RDMA data includes:
[0044] Get the number of CQEs stored in each CQ;
[0045] The CQE is placed in the CQ that stores the least number of CQEs to process the RDMA data.
[0046] In this possible implementation, by placing the CQE into the CQ that currently stores the least CQE, the RDMA data is processed according to the thread corresponding to the CQ. This not only avoids cross-thread processing of RDMA data, but also reduces the accumulation of RDMA data and speeds up the processing of RDMA data.
[0047] In a possible implementation manner of the second aspect, the processing specifically includes:
[0048] Use threads to determine the storage area of the RDMA data from the CQ;
[0049] A thread is used to obtain the RDMA data from the storage space to process the RDMA data.
[0050] In a possible implementation manner of the second aspect, receiving the first information, the second information, and the RDMA data includes:
[0051] The first information, the second information and the RDMA data are received using the RDMA interface card.
[0052] In a third aspect, the present application provides a network device, and the beneficial effects can be found in the description of the first aspect, which will not be repeated here. The device has the function of implementing the behavior in the method example of the first aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. The network device includes:
[0053] A receiving module, configured to receive first information, second information, and RDMA data, wherein the first information indicates a storage area for the RDMA data, and the second information indicates information of a completion queue CQ, wherein the storage area and the CQ are associated with the same thread;
[0054] The processing module is used to process the RDMA data according to the first information and the second information.
[0055] In a possible implementation manner of the third aspect, the processing module is further configured to:
[0056] storing the RDMA data in a storage area according to the first information, and generating a completion queue element CQE;
[0057] The CQE is placed into the corresponding CQ according to the second information to process the RDMA data.
[0058] In a possible implementation manner of the third aspect, the first information includes a number of a non-uniform memory access NUMA node, and according to the first information, the RDMA data is stored in a storage area, and a completion queue element CQE is generated, including:
[0059] Determine the NUMA node according to the NUMA node number;
[0060] Get the work queue element WQE from the memory corresponding to the NUMA node;
[0061] The RDMA data is stored in the storage area specified in the WQE and a CQE is generated.
[0062] In a possible implementation manner of the third aspect, obtaining a work queue element WQE from a memory corresponding to a NUMA node includes:
[0063] Determine the shared receive queue SRQ corresponding to the NUMA node;
[0064] Get the WQE from the SRQ's memory.
[0065] In a possible implementation manner of the third aspect, the second information includes a number CQN of the CQ, and placing the CQE into the corresponding CQ according to the second information to process the RDMA data includes:
[0066] Determine the CQ where the CQE is stored based on the CQN;
[0067] The CQE is placed in the CQ to process the RDMA data.
[0068] In a possible implementation manner of the third aspect, the network device is further used for:
[0069] Get the correspondence between threads and CQ;
[0070] Send the corresponding relationship.
[0071] In the third aspect of the present application, the various modules included in the network device can also be used to implement the steps in the various possible implementation methods of the first aspect. For the specific implementation methods of the third aspect of the embodiment of the present application and certain steps in the various possible implementation methods of the third aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the first aspect, and will not be repeated here one by one.
[0072] In a fourth aspect, the present application provides a network device, and the beneficial effects can be found in the description of the second aspect, which will not be repeated here. The device has the function of implementing the behavior in the method example of the second aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. The network device includes:
[0073] A receiving module, used for receiving RDMA data;
[0074] The processing module is used to place the completion queue element CQE in the specified completion queue CQ to process the RDMA data. The CQE is obtained based on the stored RDMA data, and the CQ corresponds to the thread one by one.
[0075] In a possible implementation manner of the fourth aspect, the processing module is further configured to:
[0076] Get the index corresponding to CQE and the total number of all CQs;
[0077] The remainder of the index and the total number is used as the CQ number;
[0078] Place the CQE into the CQ corresponding to the number to process the RDMA data.
[0079] In a possible implementation manner of the fourth aspect, the processing module is further configured to:
[0080] Get the number of CQEs stored in each CQ;
[0081] The CQE is placed in the CQ that stores the least number of CQEs to process the RDMA data.
[0082] In the fourth aspect of the present application, the various modules included in the network device can also be used to implement the steps in the various possible implementation methods of the second aspect. For the specific implementation methods of the fourth aspect of the embodiment of the present application and certain steps in the various possible implementation methods of the fourth aspect, as well as the beneficial effects brought about by each possible implementation method, you can refer to the description of the various possible implementation methods in the second aspect, and will not be repeated here one by one.
[0083] In a fifth aspect, the present application provides a network device, the network device comprising: a processor, configured to enable the network device to implement the method described in the first aspect or any possible implementation of the first aspect. The device may also include a memory, the memory is coupled to the processor, and when the processor executes instructions stored in the memory, the network device may implement the method described in any possible implementation of the first aspect. The device may also include a communication interface, the communication interface is used for the device to communicate with other devices, and illustratively, the communication interface may be a transceiver, circuit, bus, module, or other type of communication interface.
[0084] The instructions in the memory in this application can be pre-stored or downloaded from the Internet and stored when the network device is used. This application does not specifically limit the source of the instructions in the memory. The coupling in this application is an indirect coupling or connection between devices, units or modules, which can be electrical, mechanical or other forms, for information exchange between devices, units or modules.
[0085] In a sixth aspect, the present application provides a network device, the network device comprising: a processor, configured to enable the network device to implement the method described in the aforementioned second aspect or any possible implementation of the second aspect. The device may also include a memory, the memory is coupled to the processor, and when the processor executes instructions stored in the memory, the network device may implement the method described in any possible implementation of the aforementioned second aspect. The device may also include a communication interface, the communication interface is used for the device to communicate with other devices, and illustratively, the communication interface may be a transceiver, circuit, bus, module, or other type of communication interface.
[0086] The instructions in the memory in this application can be pre-stored or downloaded from the Internet and stored when the network device is used. This application does not specifically limit the source of the instructions in the memory. The coupling in this application is an indirect coupling or connection between devices, units or modules, which can be electrical, mechanical or other forms, for information exchange between devices, units or modules.
[0087] In the seventh aspect, the present application provides a computer storage medium, which may be non-volatile; the computer storage medium stores computer-readable instructions, which, when executed by a processor, implement the method described in the first aspect or any possible implementation of the first aspect.
[0088] In an eighth aspect, the present application provides a computer storage medium, which may be non-volatile; the computer storage medium stores computer-readable instructions, which, when executed by a processor, implement the method described in the second aspect or any possible implementation of the second aspect.
[0089] In a ninth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method described in the first aspect or any possible implementation of the first aspect.
[0090] In a tenth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method described in the second aspect or any possible implementation of the second aspect.
[0091] In an eleventh aspect, the present application provides a network system comprising at least one network device for sending first information, second information and RDMA data, and at least one network device as described in the third aspect or the fifth aspect above.
[0092] In a twelfth aspect, the present application provides a network system, which includes at least one network device for sending RDMA data, and at least one network device as described in the fourth aspect or the sixth aspect.
[0093] The solutions provided in the third, fifth, seventh, ninth and eleventh aspects are used to implement or cooperate with the method provided in the first aspect, and therefore can achieve the same or corresponding beneficial effects as the first aspect, and will not be repeated here.
[0094] The solutions provided in the fourth, sixth, eighth, tenth and twelfth aspects are used to implement or cooperate with the method provided in the second aspect, and therefore can achieve the same or corresponding beneficial effects as the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0095] Figure 1 A schematic diagram of an architecture for RDMA data processing;
[0096] Figure 2 A schematic diagram of a NUMA architecture provided in an embodiment of the present application;
[0097] Figure 3a A schematic diagram of an application scenario of the data processing method provided in an embodiment of the present application;
[0098] Figure 3b A flowchart of a data processing method provided in an embodiment of the present application;
[0099] Figure 3c Another flowchart of the data processing method provided in the embodiment of the present application;
[0100] Figure 4a Another schematic diagram of the architecture of RDMA data processing provided in an embodiment of the present application;
[0101] Figure 4b Another schematic diagram of the architecture of RDMA data processing provided in the embodiment of the present application
[0102] Figure 4c Another schematic diagram of the architecture of RDMA data processing provided in an embodiment of the present application;
[0103] Figure 5 Another flowchart of the data processing method provided in the embodiment of the present application;
[0104] Figure 6 Another schematic diagram of the architecture of RDMA data processing provided in an embodiment of the present application;
[0105] Figure 7 A schematic diagram of a connection relationship between QP and SRQ provided in an embodiment of the present application;
[0106] Figure 8 Another flowchart of the data processing method provided in the embodiment of the present application;
[0107] Fig. 9 Another schematic diagram of the architecture of RDMA data processing provided in an embodiment of the present application;
[0108] Fig.10 A schematic diagram of the structure of a network device provided in an embodiment of the present application;
[0109] Fig.11 Another structural diagram of a network device provided in an embodiment of the present application;
[0110] Fig.12 Another structural diagram of a network device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0111] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application. It is known to those skilled in the art that with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0112] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules that are clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices.
[0113] The term "and / or" in this application can be a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.
[0114] It should also be noted that, in some alternative implementations, the functions / acts noted may occur out of the order of the drawings. For example, two figures shown in succession may in fact occur substantially simultaneously or may sometimes be performed in the reverse order, depending on the functions / acts involved.
[0115] In the embodiments of the present application, unless otherwise specified, the meaning of "at least one" refers to one or more, and the meaning of "plurality" refers to two or more. It is understood that in the present application, "when", "if" and "if" all refer to the device making corresponding processing under certain objective circumstances, and do not limit the time, nor do they require that there must be a judgment action when the device is implemented, nor do they mean that there are other limitations. In addition, the special word "exemplary" means "used as an example, embodiment or illustrative". Any embodiment described as "exemplary" is not necessarily interpreted as being superior or better than other embodiments.
[0116] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0117] In order to better understand a data processing method provided in an embodiment of the present application, some terms involved in the embodiment of the present application are first explained below.
[0118] (1) Remote Direct Memory Access (RDMA)
[0119] RDMA is a direct memory access technology that can transfer data directly from the memory of one computer to the memory of another computer without the intervention of the operating systems of both parties, thereby achieving low-latency data transmission. The basic unit of RDMA communication is a queue pair (QP), and each QP consists of a send queue (SQ) and a receive queue (RQ).
[0120] RDMA is a transport layer network protocol that uses QP in the channel adapter (CA) to send and receive data from consumers. Each QP contains an SQ and an RQ, where SQ is responsible for sending messages and RQ is responsible for receiving messages. The SQ and RQ of each QP can be associated with a completion queue (CQ) respectively. Each QP has its own connection context to maintain its connection status, and SQ, RQ, and CQ also have their own queue context to maintain their queue usage status.
[0121] (2) Shared Receive Queue (SRQ)
[0122] Several QPs share the same RQ, called SRQ. Since each queue consumes memory resources, the use of receive queues is much less than that of send queues, so SRQ can be used to save memory.
[0123] (3) Non Uniform Memory Access (NUMA)
[0124] NUMA is a memory architecture designed for multi-processor computers where memory access time depends on the location of the memory relative to the processor. In a NUMA architecture, a processor can access its own local memory faster than non-local memory (memory located on another processor or memory shared between processors).
[0125] For example, see Figure 2 , Figure 2 A schematic diagram of a NUMA architecture provided in an embodiment of the present application.
[0126] exist Figure 2 In the illustrated architecture, the NUMA architecture 200 is divided into two chips, such as CPU0 and CPU1, wherein each chip includes at least one NUMA node. Figure 2 The NUMA architecture 200 shown includes four NUMA nodes, namely NUMA node 0, NUMA node 1, NUMA node 2 and NUMA node 3, each of which has multiple processor cores or CPU cores (core0, core1, etc.). Among them, NUMA node 0 and NUMA node 1 are located in CPU0, and NUMA node 2 and NUMA node 3 are located in CPU1. CPU0 and CPU1 can communicate through an interconnect bus, and NUMA node 0 can communicate with NUMA node 2 through the interconnect bus.
[0127] Each NUMA node can contain 32 CPU cores. Figure 2 As shown, NUMA node 0 includes 32 cores, core 0, core 1, ..., core 31, and NUMA node 2 includes 32 cores, core 64, core 65, ..., core 95, etc. At the same time, each NUMA node can also be configured with corresponding memory, such as NUMA node 0 can be configured with memory 0, whose size can be 4*32G, etc.
[0128] exist Figure 2In the NUMA architecture shown, NUMA node 0 is taken as the benchmark, and NUMA node 0 can be called a local node. NUMA node 1 and NUMA node 2 adjacent to NUMA node 0 can be called neighbor nodes of NUMA node 0, and NUMA node 3, which is neither a local node nor a neighbor node, can be called a remote node.
[0129] Among them, the speed at which the local node accesses the memory corresponding to different NUMA nodes is usually different. Specifically, the local node has the fastest access speed when accessing its own configured memory 0; the slowest access speed when accessing the remote node's memory 3; and the access speed when accessing the neighbor node's memory 1 or memory 2 is slower than the access speed to memory 0, but faster than the access speed to memory 3. For different neighbor nodes, the speed at which the local node accesses the memory of the neighbor node located on the same CPU is faster than the speed at which the local node accesses the memory of the neighbor node located on a different CPU.
[0130] It should be noted that in actual application, the connection relationship between each node in the NUMA architecture, the number of NUMA nodes included in the NUMA architecture, the number of CPU cores contained in a single NUMA node, and Figure 2 The various parameter indicators shown in the figure can be set according to actual needs. They are only used as examples and are not limited to these.
[0131] The above introduces the terminology concepts involved in the embodiments of the present application. In order to better understand the technical solutions provided by the embodiments of the present application, the following introduces the application scenarios of the data processing methods provided by the embodiments of the present application.
[0132] See also Figure 3a , Figure 3a A schematic diagram of an application scenario of the data processing method provided in the embodiment of the present application. Figure 3a As shown, the application scenario includes several network devices and several intermediate network devices. The network device can be a server, and the server can be a physical server including an independent host, or a virtual server, a cloud server, etc. carried by a host cluster, and the intermediate network device can be a physical device such as a router, a switch or a gateway. Each network device is provided with an RDMA interface card, and is interconnected through an intermediate network device. Now, the RDMA interface card is taken as an RDMA network card for explanation. It should be understood that this is only an example and is not limited.
[0133] Optionally, each network device includes an RDMA network card and a host, at least one process is running on the host, and the host creates RDMA resources, including QP and CQ, etc., through the at least one process. Then, the host communicates with processes on other network devices through the RDMA network card. In the process of communicating with each other, each network device will send an RDMA message, and the RDMA message is communicated through an intermediate network device between each network device.
[0134] It should be noted that the connection relationship between the RDMA network card and the network device shown in the drawings of this application is only for illustration and is only used to show the internal logic. The RDMA network card can be built into the network device or connected to the network device as a separate product or device, which is not limited here. In addition, the number of RDMA cards is not limited to Figure 3a The quantity shown in can be set according to actual needs and is not limited here.
[0135] Optionally, each network device may also be integrated into an RDMA network card or replaced by an RDMA network card, and the RDMA network card may be used as a separate product to implement the data processing method provided in the embodiment of the present application. Figure 3a The location and connection relationship of the RDMA network card integrated in the network device shown is only for illustration and is not limited here.
[0136] It is understandable that in RDMA technology, the basic unit of communication is QP. For each network device, at least one process is loaded in the network device. The network device creates RDMA resources through the process and communicates with the remote process through QP.
[0137] Before the local network device sends an RDMA message, the local network device can send the data indicated by the WQE to the network through the QP after submitting (posting) a work queue element (WQE) through the SQ in the QP. When the network card completes the transmission of all contents of a message indicated by a WQE, it submits a completion queue element (CQE) to the CQ associated with the SQ to notify the process that the RDMA operation indicated by a certain WQE it submitted has been completed.
[0138] Before the local network device receives the RDMA message, it will submit a WQE to the RQ in the QP in advance. After the QP receives the data from the network, it writes the data to the storage space indicated by the WQE of the RQ. When the network card completes the data storage, it submits a CQE to the CQ associated with the RQ to process the data.
[0139] It should be noted that Figure 3aThe application environment shown is only one example of an environment. The data processing method provided in the embodiment of the present application can be applied to the above-mentioned scenario but is not limited to it. Figure 3a In the structure shown in , the relationship between the network device and the RDMA network card can be set according to actual needs. The network device can include the RDMA network card, or can be integrated with or equivalent to the RDMA network card, which is not limited here.
[0140] For a possible implementation, see Figure 3b , Figure 3b A flow chart of a data processing method provided in an embodiment of the present application. The method can be Figure 3a The method specifically includes: 301b, receiving first information, second information and RDMA data, the first information indicating the storage area of the RDMA data, the second information indicating the information of the completion queue CQ, and the storage area and the CQ are associated with the same thread. Optionally, the first information includes the number corresponding to the thread. Optionally, the second information includes the number CQN of the CQ. 302b, processing the RDMA data according to the first information and the second information.
[0141] In this implementation, after receiving the data, the network device realizes single-threaded processing of the data by associating the data with the corresponding storage area and CQ under the same thread, avoiding the problem of thread switching caused by cross-thread access, improving the effective utilization of the CPU, and reducing data processing latency.
[0142] For a possible implementation, see Figure 3c , Figure 3c Another flow chart of the data processing method provided in the embodiment of the present application is shown in FIG. Figure 3a The method specifically includes: 301c, receiving RDMA data. 302c, placing a completion queue element CQE in a specified completion queue CQ to process the RDMA data, the CQE is obtained based on the stored RDMA data, and the CQ corresponds to the thread one by one.
[0143] In this implementation, the network device places the CQE corresponding to the stored data in the specified CQ and corresponds the CQ to the thread one by one, thereby implementing single-threaded processing of data and avoiding the problem of thread switching.
[0144] It is understandable that the data processing method provided in the embodiment of the present application can be applied to Figure 3a On any network device shown, by processing the data in the received RDMA message, the data processing process is improved to solve the problem of cross-thread access.
[0145] The above introduces the application scenarios involved in the embodiments of the present application. In order to better understand the technical solutions provided by the embodiments of the present application, the current data processing method is introduced below using a network device using 128 CPU cores as an example.
[0146] (1) Method 1
[0147] For example, see Figure 4a , Figure 4a Another schematic diagram of the architecture of RDMA data processing provided in the embodiment of the present application. Figure 4a As shown, the local network device and the opposite network device are interconnected through a switch, and at least one process is running on each local network device and each opposite network device, and multiple threads are running on each process. In order to communicate with each process of the remote network device, at least one process is running on a single remote network device, and at least n processes are running on n remote network devices, where n is a positive integer. Corresponding to each process of the remote network device, multiple remote processes relative to the remote end shown in the local network device are respectively created with multiple QPs for communicating with the remote process. Assume that 128 QPs are created on the local network device for communicating with each process of the remote network device, each QP is associated with a CQ, and one CPU core is bound to one thread. Each thread creates a memory resource pool and a CQ for receiving data.
[0148] The data processing flow is as follows:
[0149] (a) Each thread on the local network device applies for memory from the memory resource pool corresponding to the thread and reserves it for QP to receive data.
[0150] (b) The local network device receives the message from the remote network device through the QP, puts the data in the message into the location specified in the WQE, and then generates a CQE and places it into the CQ associated with the QP.
[0151] (c) Each thread on the local network device polls the CQ corresponding to the thread, processes the CQE, retrieves the received data, and performs business logic processing.
[0152] (d) After processing the business logic, each thread on the local network device releases the memory to the resource pool corresponding to the thread.
[0153] However, method 1 has the following disadvantages:
[0154] (a) In order to communicate with each remote process of the remote network device, the local network device creates a QP for communication corresponding to each remote process. Since one QP is associated with one CQ, on a network device with 128 CPU cores, the local network device needs to create 128 QPs to communicate with the same remote process. The large number of QPs created results in excessive consumption of memory resources of the local network device.
[0155] (b) Since the memory resources of the RDMA network card are limited, when the number of QPs is too large, the network card cannot store the resources of all QPs, resulting in a decrease in the performance of the network card.
[0156] (2) Method 2
[0157] On the basis of method 1, in order to reduce the number of QPs, during the communication between the local server and the remote network device, the local network device only creates a small number of QPs in each process corresponding to the remote network device.
[0158] For example, see Figure 4b , Figure 4b Another schematic diagram of the architecture of RDMA data processing provided in the embodiment of the present application. Figure 4b As shown, the local network device creates a CQ for each thread, and each QP is associated with a CQ. Each process on the local network device contains only 4 QPs, which are used to receive data sent by the remote network device. Each QP is associated with a CQ, and a total of 4 threads are used.
[0159] It can be understood that the data processing flow of method 2 is similar to that of method 1, except that the number of QPs in each process of the local network device is different. The data processing flow of method 2 can be specifically referred to the content of method 1, which will not be repeated here.
[0160] However, method 2 has the following disadvantages:
[0161] (a) When the local network device receives less data, the CPU resources on the local network device cannot be fully utilized. Only a small number of CPU cores can be used, and the remaining CPU cores are idle, resulting in resource waste.
[0162] (b) When the load of each process is unbalanced, it is easy for some QPs in the same process to receive more data, and the corresponding CPU cores are fully loaded, while some CPU cores are idle, resulting in some QPs having good performance and some QPs having poor performance in the end-to-end data processing process.
[0163] (3) Method 3
[0164] For example, see Figure 4c , Figure 4c Another schematic diagram of the architecture of RDMA data processing provided by the embodiment of the present application. Figure 4c In the example, the local network device creates one thread for each CPU core. The local network device uses four threads as communication threads, creates one CQ for each communication thread, which is responsible for sending and receiving RDMA data, and uses the rest as service processing threads.
[0165] The data processing flow is as follows:
[0166] (a) The communication thread on the local network device applies for the receive buffer corresponding to the RDMA data from the memory resource pool, and then sends a WQE representing the receive task to the RDMA network card and puts it in the RQ.
[0167] (b) The local network device receives the message through the RDMA network card, obtains the WQE from the RQ, puts the data in the message into the receive buffer specified in the WQE, and then generates a CQE and places it in the CQ.
[0168] (c) The communication thread on the local network device obtains RDMA data from the receive buffer according to the CQ, queues the data, and then redistributes it.
[0169] (d) The service processing thread on the local network device obtains the RDMA data from the queue and performs service logic processing. After the processing is completed, the memory of the buffer is released.
[0170] However, method three has the following disadvantages:
[0171] (a) The communication thread used by the local network device to receive data is different from the business processing thread used to process data. During the process of receiving and processing data, there is a problem of thread switching, which increases the processing delay.
[0172] (b) Thread switching needs to be completed through data enqueuing and dequeuing, and both enqueuing and dequeuing processing will generate excess CPU overhead.
[0173] (c) The buffer application and release are not in the same thread, which makes it impossible to implement lock-free and conflict-free memory application and release management based on a single thread, resulting in unnecessary CPU overhead.
[0174] (d) Due to the different sizes of different RDMA data, in order to process different RDMA data in a timely manner, it is difficult to achieve the optimal configuration ratio of communication threads and business processing threads on the local network device.
[0175] It can be understood that the connection relationship between the RDMA network card and the network device shown in the drawings of the present application is only for illustration and is only used to facilitate the display of the internal logic. The RDMA network card can be built into the network device or connected to the network device as a separate product or device, which is not limited here.
[0176] The above describes several data processing methods currently used in the embodiments of the present application. Figures 4a to 4c In order to overcome the defects of the data processing method shown in the figure, the present application provides a data processing method. The following specifically describes a data processing method provided by an embodiment of the present application in combination with the accompanying drawings and application scenarios.
[0177] See also Figure 5 , Figure 5 Another flow chart of the data processing method provided in the embodiment of the present application. Figure 5 The data processing method shown can be performed by Figure 3a The network device execution shown is mainly used to solve cross-NUMA and cross-thread problems. Among them, in order to distinguish the receiver and sender of RDMA data, the data processing method provided in the embodiment of the present application is described by taking the case that after the opposite network device sends the data, the local network device receives and processes the data. It should be understood that the local network device and the opposite network device are only used to distinguish the two parties of network communication. In the actual communication process, the local network device and the opposite network device need to be set according to the execution subject of the sender and receiver of the data. This is only an example and does not specifically limit the execution subject of the embodiment of the present application. Figure 5 As shown, the network device can process the data included in the RDMA message by executing the following steps 501 to 503.
[0178] Before step 501, in a possible implementation, the method performs the following steps:
[0179] Step 1: The network device obtains the corresponding relationship between the thread and the CQ.
[0180] In the embodiment of the present application, based on the establishment of a connection between the local network device and the opposite network device, after receiving a request message from the opposite network device, the local network device will obtain the correspondence between its own thread and CQ.
[0181] In an optional implementation manner, the network device obtains the correspondence between the thread number and the CQ number.
[0182] In this implementation, the local network device binds the thread to the CQ by acquiring the correspondence between the number of each thread of the local network device and the number of the CQ (CQNumber, CQN).
[0183] It should be understood that when the same NUMA node includes multiple CPU cores and each CPU core is bound to a thread, the local network device applies for storage space from the memory corresponding to a NUMA node through a thread in the NUMA node to store data, and places the CQE corresponding to the stored data in the CQ corresponding to the thread to achieve storage and processing of data under the same thread, avoiding the problem of cross-NUMA and cross-thread switching.
[0184] In an optional implementation, the network device may also obtain a correspondence between the number of the NUMA node and the number of the CQ.
[0185] In this implementation, if a single thread corresponds to a NUMA node, in this case, only the NUMA node number and the CQ number need to be specified to ensure data processing under a single thread.
[0186] Specifically, the local network device and the opposite network device exchange information about the NUMA nodes and CQ numbers of threads at both ends, including information such as the correspondence between the NUMA node numbers and the CQ numbers, so that when the opposite network device communicates data with the local network device, it can specify the correspondence between the NUMA node and the CQ numbers on the local network device to ensure that the data is stored and processed under the same NUMA node, thereby avoiding cross-NUMA problems.
[0187] In addition, it is understandable that the local network device and the opposite network device need to establish a connection before exchanging information. After the local network device and the opposite network device establish a connection, they exchange information from the opposite end.
[0188] Optionally, a connection is established between the local network device and the opposite network device via a Transmission Control Protocol (TCP).
[0189] Optionally, a connection is established between the local network device and the opposite network device via User Datagram Protocol (UDP).
[0190] It should be noted that, in actual application, the specific communication protocol and communication method adopted by the local network device and the opposite network device can be set according to actual needs and are not limited here.
[0191] Step 2: The network device sends the corresponding relationship.
[0192] In the embodiment of the present application, after obtaining the correspondence between each of its own threads and the CQ number, the local network device sends the correspondence to the opposite network device so that the opposite network device can obtain thread-related information of the local network device.
[0193] Optionally, the local network device may send the corresponding relationship via the TCP protocol.
[0194] Optionally, the local network device may send the corresponding relationship via the UDP protocol.
[0195] It should be noted that, in actual application, the specific communication protocol and communication method adopted by the local network device and the opposite network device can be set according to actual needs and are not limited here. In addition, it should be noted that step 1 and step 2 are optional steps. In actual application, the corresponding relationship can be pre-configured in the network device, or, when each network device adopts other implementation methods to obtain the corresponding relationship of other network devices, step 1 and step 2 do not need to be repeated. The above steps can be skipped.
[0196] Further, based on the information exchange completed in advance between the local network device and the opposite network device, the processing of the RDMA data can be completed by executing the following steps 501 to 503. The following is an explanation in conjunction with the specific steps, and steps 501 to 503 are specifically as follows:
[0197] 501, the network device receives an RDMA message.
[0198] In the embodiment of the present application, when the opposite network device needs to access the memory of the local network device, it can establish a network connection with the RDMA network card of the local network device, and send an RDMA message to the local network device through the network connection. Before the local network device receives the RDMA message, the thread on the local network device has applied for memory for the RDMA message in the memory resource pool corresponding to the thread, and the RDMA network card obtains the corresponding WQE from the RQ to prepare to receive the message.
[0199] An RDMA message may include multiple RDMA packets. After the peer network device splits the RDMA message into multiple RDMA packets and sends them to the local network device, the RDMA network card of the local network device assembles the received RDMA packets and obtains information and RDMA data. However, it should be noted that in actual application, RDMA messages can also be equivalent to RDMA data. This application is only one of the optional expressions and does not limit the specific form, content, and sending method of RDMA messages.
[0200] It should be understood that the number of peer network devices can be set according to actual needs, and the local network device can simultaneously receive RDMA messages sent by multiple peer network devices to achieve communication with different peer network devices. In each process, multiple threads are used to process the received RDMA data in parallel.
[0201] 502. The network device parses the RDMA message to obtain the first information, the second information and the RDMA data.
[0202] In the embodiment of the present application, after the local network device receives the RDMA message sent by the opposite network device through the RDMA network card, the local network device parses the RDMA message to obtain the first message, the second message and the RDMA data from the RDMA message.
[0203] In an optional implementation, the first information includes a number of a non-uniform memory access NUMA node.
[0204] In this implementation, the peer network device indicates the corresponding NUMA node when the data is stored and processed on the local network device to implement data processing under the same NUMA node, avoid cross-NUMA data processing, and reduce data processing latency.
[0205] Specifically, the NUMA node numbers represent different NUMA nodes. For details, see Figure 2 , Figure 2 4 NUMA nodes are numbered, namely NUMA node 0, NUMA node 1, NUMA node 2 and NUMA node 3.
[0206] It is understandable that the number of NMUA nodes included in the NUMA architecture can be configured according to actual needs. Figure 2 The number of NUMA nodes described in the embodiments of the present application is for illustrative purposes only and is not intended to be limiting.
[0207] In another optional implementation, the first information also includes a number corresponding to the thread.
[0208] In this implementation, in the case where there are multiple threads under the same NUMA node, the network device on the other end adds information on the number of the thread corresponding to the first information so that the network device on the local end stores the data in the specified thread under the specified NUMA node according to the information, thereby realizing data processing under the same thread under the same NUMA node, avoiding the problem of cross-NUMA and cross-thread data processing, and further reducing the data processing delay.
[0209] It is understandable that a plurality of threads are loaded in the network device, and each thread corresponds to a CPU core. In order to distinguish different threads, each thread can be numbered, such as thread 1, thread 2, etc.
[0210] In an optional implementation, the second information includes the CQ number CQN.
[0211] In this optional implementation, there are multiple threads in a NUMA node, and one thread corresponds to one CQ. The peer network device stores the CQ stored in the CQE generated by the specified stored RDMA data, and informs the local network device in the form of a number, so that the local network device places the CQ in the CQ corresponding to the same thread as the storage space of the RDMA data, thereby realizing the reception and processing of RDMA data in the same thread.
[0212] 503. The network device processes the RDMA data according to the first information and the second information.
[0213] In an embodiment of the present application, after the local network device obtains the first information, the second information and the RDMA data from the received RDMA message, the RDMA data can be stored in a specified location according to the information indicated by the first information, and the CQE submitted after the RDMA data is stored can be placed in the specified CQ according to the information indicated by the second information. Subsequently, the local network device processes the RDMA data by obtaining the CQE in the CQ. The first information and the second information correspond to the same thread.
[0214] For example, see Figure 6 , Figure 6 Another schematic diagram of the architecture of RDMA data processing provided by the embodiment of the present application. Figure 6 In the network device, a multi-NUMA architecture is used. Assume that the NUMA architecture contains two NUMA nodes, NUMA0 and NUMA1. Each NUMA node contains two threads. Figure 6 Thread 1, thread 2, etc. are used as examples. Corresponding to the 32 remote processes, the network device is respectively provided with QP groups corresponding to the 32 remote processes, each QP group is loaded with 4 QPs, each QP can be associated with multiple CQs, and each CQ is bound to a thread.
[0215] by Figure 6 The architecture diagram shown illustrates the specific contents of the embodiments of the present application.
[0216] Specifically, Figure 6As shown, before the local network device receives the message, the local network device has applied for storage space for caching RDMA data in the RDMA message from the corresponding NUMA node through a thread. Assuming that QP1-1 receives the RDMA message sent by the opposite network device as an example, after QP1-1 receives the RDMA message sent by the opposite network device from the network, it parses the RDMA message, and then applies for WQE from the corresponding NUMA node according to the storage space indicated in the first information, and stores the RDMA data in the storage space specified by the WQE, and then generates CQE. QP1-1 selects the corresponding CQ according to the information of the CQ indicated in the second information, and places the CQE in the corresponding CQ. Afterwards, when the thread bound to the CQ on the local network device polls the CQE in the CQ, it processes the RDMA data according to the information in the CQE.
[0217] In one implementation, the network device stores the RDMA data in a storage area indicated by the first information according to the first information, and generates a completion queue element CQE.
[0218] In this implementation, after receiving the RDMA message sent by the peer network device, the local network device obtains the first information, the second information and the RDMA data from the RDMA message. Subsequently, the local network device stores the RDMA data in the corresponding storage area according to the storage area indicated by the first information. After the RDMA data is stored, the local network device generates a corresponding CQE.
[0219] Optionally, the first information includes a number of a non-uniform memory access NUMA node.
[0220] Specifically, after receiving the first information, the local network device determines the corresponding NUMA node according to the NUMA number, then obtains the WQE from the memory corresponding to the NUMA node, stores the RDMA data in the storage area specified in the WQE, and generates a CQE. Figure 6 For example, assuming that the NUMA node included in the first information is NUMA0, after receiving the RDMA message through the RDMA network card, the local network device will obtain WQE from the RQ bound to NUMA0 through the RDMA network card, store the RDMA data received from the network in the storage area specified by WQE, and generate CQE.
[0221] Optionally, the network device obtains the WQE from the SRQ corresponding to the NUMA node.
[0222] Specifically, the network device associates a QP with multiple SRQs. After receiving the RDMA message sent by the peer network device, the local network device applies for a WQE from the SRQ of the corresponding NUMA through the number of the NUMA node included in the first information, and then stores the RDMA data received from the network in the storage area specified by the WQE. The SRQ is created according to NUMA.
[0223] For example, see Figure 7 , Figure 7 A schematic diagram of a connection relationship between QP and SRQ provided in an embodiment of the present application. Figure 7 As shown, assuming that QP1 is taken as an example, QP1 is associated with multiple SRQs, and each SRQ is bound to a thread. After the local network device receives the RDMA message sent by the peer network device through QP1, through the NUMA node number NUMA0 contained in the first information, WQE can be applied from SRQ1 corresponding to NUMA0, and RDMA data can be stored in the storage area specified by WQE. Among them, since SRQ1 is bound to thread 1 in the NUM0 node, thread 1 obtains RDMA data from the corresponding CQ to achieve RDMA data processing under the same thread.
[0224] It is worth noting that the network device reduces the number of QPs by associating one QP with multiple SRQs, so that the threads of all CPU cores can process the received RDMA data in a load-balanced manner, avoiding the overhead caused by switching threads, avoiding mutually exclusive access between multiple threads, and reducing latency.
[0225] Optionally, the first information also includes a number corresponding to the thread.
[0226] Specifically, Figure 6 For example, assuming that the thread number included in the first information is thread 1, after the local network device receives the RDMA message through the RDMA network card, it will obtain WQE from the RQ bound to thread 1 through the RDMA network card and store the RDMA data received from the network in the storage area specified by WQE.
[0227] It is understandable that different threads under the same NUMA node generally share the same memory area. Therefore, whether the number of the NUMA node is specified or any thread under the NUMA node is further specified, the RDMA data is stored in the same NUMA node.
[0228] In one implementation, the network device places the CQE into the CQ indicated by the second information according to the second information to process the RDMA data.
[0229] In this implementation, after receiving the RDMA message sent by the peer network device, the local network device obtains the first information, the second information and the RDMA data from the RDMA message. Subsequently, after storing the RDMA data in the corresponding storage area according to the storage area indicated by the first information, the local network device generates the corresponding CQE. Subsequently, the local network device further processes the RDMA data according to the CQ information indicated in the second information.
[0230] Optionally, the second information includes the CQ number CQN.
[0231] Specifically, the network device determines the CQ where the CQE is stored according to the CQN, and then places the CQE in the CQ to process the RDMA data. Figure 6 For example, assuming that the number of the CQ included in the second information is CQ1, after the local network device stores the RDMA data in the designated storage area and generates CQE, it will place the CQE in CQ1 to process the RDMA data.
[0232] It is understandable that Figure 6 It can be seen that, corresponding to each process of the remote network device, each QP in the corresponding process of the local network device can be associated with multiple CQs. By reducing the number of QPs, the network card can receive multiple messages from the same QP. After the QP receives the RDMA data on the network, the CQE can be queued to the corresponding CQ through the first information and the second information, realizing a one-to-many correspondence between QP and CQ, and also improving the performance of the network card in sending and receiving RDMA data.
[0233] After the network device places the CQE into the specified CQ, in an optional implementation, the network device processes the RDMA data specifically including:
[0234] The network device uses threads to determine the storage area of the RDMA data from the CQ;
[0235] The network device uses a thread to obtain the RDMA data from the storage space to process the RDMA data.
[0236] In this implementation, after the local network device stores the data in the storage space specified by the peer network device, the local network device generates a corresponding CQE and places it in the CQ specified by the peer network device. Subsequently, when the network device needs to process the RDMA data, the network device uses a thread to access the CQE in the CQ and determines the storage space of the RDMA data according to the information indicated by the CQE. Then, the network device uses a thread to obtain the RDMA data from the storage space to process the RDMA data.
[0237] It is worth noting that compared with Figure 4a The method provided, the data processing method provided in the embodiment of the present application reduces the number of QPs and avoids the problem shown in method 1. Figure 4b The method provided, the data processing method provided in the embodiment of the present application reduces the number of QPs, associates a QP with multiple CQs, and specifies the CQ bound to the QP, so that the local network device can achieve flexible and effective use of the CQ by specifying the CQ regardless of the amount of RDMA data received, thereby achieving flexible and effective use of the CPU and bound to the CQ. Figure 4c The method provided, the data processing method provided in the embodiment of the present application avoids the problem of cross-thread switching of RDMA data when receiving and processing by specifying the storage area and CQ of RDMA data, and placing the CQE generated by the stored RDMA data into the CQ under the same thread associated with the storage area of the RDMA data. In the embodiment of the present application, the opposite network device associates the first information and the second information with the same thread, and after the local network device stores the RDMA data in the memory under the thread, it will place the generated CQE into the CQ corresponding to the thread, thereby realizing RDMA data processing within the same thread, avoiding cross-thread processing, and improving the effective utilization of the CPU.
[0238] It is understandable that, in actual application, the contents of the first information and the second information can be set according to actual needs and are not limited here.
[0239] See also Figure 8 , Figure 8 Another flow chart of the data processing method provided in the embodiment of the present application. Figure 8 The data processing method shown in can be Figure 3a The network device execution shown is mainly used to solve the problem of cross-thread switching in scenarios where the cross-NUMA problem has less impact. Among them, in order to distinguish the receiver and sender of RDMA data, the data processing method provided in the embodiment of the present application is described by taking the case that after the opposite network device sends the RDMA data, the local network device receives and processes the RDMA data. It should be understood that the local network device and the opposite network device are only used to distinguish the two parties of network communication. In the actual communication process, the local network device and the opposite network device need to be set according to the execution subject of the sender and receiver of the RDMA data. This is only an example and does not specifically limit the execution subject of the embodiment of the present application. Figure 8 As shown, the data processing method includes the following steps 801 to 803.
[0240] 801, the network device receives RDMA data.
[0241] In an embodiment of the present application, after the local network device receives the RDMA message, the RDMA data is obtained from the RDMA message. When the opposite network device needs to access the memory of the local network device, it can establish a network connection with the RDMA network card of the local network device and send the RDMA message to the local network device through the network connection. Before the local network device receives the RDMA message, the thread on the local network device has applied for memory for the RDMA message in the memory resource pool corresponding to the thread, and the RDMA network card obtains the corresponding WQE from the RQ to prepare to receive the message.
[0242] It should be understood that RDMA messages can be understood as messages communicated between network devices. After the local network device receives the RDMA message, the corresponding RDMA data can be obtained from the message. RDMA messages can also be understood as RDMA data to be processed by the local network device. The former is used as an example for explanation. In actual application, it can be selected according to needs and is not limited here.
[0243] 802. The network device stores the RDMA data and generates a CQE.
[0244] In the embodiment of the present application, after receiving the RDMA message through the RDMA network card, the local network device obtains the RDMA data to be processed from the RDMA message and stores the RDMA data in the storage space indicated by the WQE of the RQ. When the RDMA network card completes the reception of the RDMA data, it submits the CQE to the CQ associated with the RQ.
[0245] 803, the network device places the CQE in the specified CQ to process the RDMA data.
[0246] In the embodiment of the present application, after completing the storage of RDMA data and generating CQE, the local network device processes the RDMA data by placing the CQE into a specified CQ. The implementation methods of specifying the CQ where the CQE is stored may include the following two.
[0247] In an optional implementation, the step of placing the CQE into the specified CQ by the network device includes:
[0248] The network device obtains the index corresponding to the CQE and the total number of all CQs.
[0249] The network device uses the remainder of the index and the total number as the CQ number.
[0250] The network device places the CQE into the CQ corresponding to the number.
[0251] In this implementation, after the local network device stores the RDMA data in the memory and generates the CQE, it can use polling to send the CQE to different CQs to implement single-threaded RDMA data processing and memory management. Specifically, after the local network device stores the RDMA data in the memory and generates the CQE, it obtains the index corresponding to the CQE and the total number of CQs, takes the remainder of the two as the CQ number, and places the CQE in the CQ corresponding to the number. Among them, the index can also be understood as the number of the CQE or the number of the RDMA data corresponding to the CQE. For example, the CQE corresponding to the kth message numbered in sequence received by the RDMA network card within a period of time, the index can be k.
[0252] For example, see Fig. 9 , Fig. 9 Another schematic diagram of the architecture of RDMA data processing provided by the embodiment of the present application. Fig. 9 In , a QP is associated with multiple CQs, and each thread is bound to a CQ. Each thread is bound to a CPU core. Fig. 9 In the example, thread 1 and thread 2 are used for explanation. Each thread creates a corresponding memory resource pool. Fig. 9 In the description, memory 1 and memory 2 are used as examples.
[0253] like Fig. 9 As shown, after QP receives and stores RDMA data, a CQE is generated. Assuming that the total number of current CQs n is 3, QP receives the 7th message and generates a CQE with a number or index k equal to 7. By calculating the remainder of 7 and 3 as 1, 1 is used as the CQ number, and CQE7 is sent to CQ1. Then, if QP receives the 8th message, CQE8 is generated, and by calculating the remainder of 8 and 3 as 2, 2 is used as the CQ number, and CQE8 is sent to CQ2, so that CQEs are sent to different CQs in sequence. Since one CQ corresponds to one thread, through the above-mentioned polling method, the CQE generated after the received RDMA data is stored can be sent to different CQs in sequence, ensuring that one CQ corresponds to one thread, thereby realizing single-threaded RDMA data processing and avoiding the problem of cross-thread access.
[0254] In another optional implementation, the step of placing the CQE into the specified CQ by the network device includes:
[0255] The network device obtains the number of CQEs stored in each of all CQs;
[0256] The network device places the CQE into the CQ that stores the least number of CQEs.
[0257] In this implementation, after receiving RDMA data and generating the corresponding CQE, the network device obtains the CQ with the least CQE currently stored, that is, the CQ with the least tasks currently stored, and places the CQE in the CQ with the least tasks to speed up the processing efficiency of RDMA data. In addition, by specifying the CQ, it can ensure that the RDMA data corresponds to a single thread, realize single-thread RDMA data processing, and avoid the problem of thread switching.
[0258] It is understandable that after the thread completes processing the corresponding RDMA message, the memory of the message can be released to the memory resources corresponding to the thread without lock, thereby realizing lock-free and conflict-free memory release based on a single thread and reducing CPU overhead.
[0259] After the network device places the CQE into the specified CQ, in an optional implementation, the network device processes the RDMA data specifically including:
[0260] The network device uses threads to determine the storage area of the RDMA data from the CQ;
[0261] The network device uses a thread to obtain the RDMA data from the storage space to process the RDMA data.
[0262] In this implementation, after the local network device stores the data in the storage space specified by the peer network device, the local network device generates a corresponding CQE and places it in the CQ specified by the peer network device. Subsequently, when the network device needs to process the RDMA data, the network device uses a thread to access the CQE in the CQ and determines the storage space of the RDMA data according to the information indicated by the CQE. Then, the network device uses a thread to obtain the RDMA data from the storage space to process the RDMA data.
[0263] It is worth noting that the current data processing methods also adopt the scheme of associating QP with CQ one-to-one, for example Figure 4a , Figure 4b and Figure 4c However, if Figure 4a If too many QPs are created, the memory resources of the network device will be consumed too much. On this basis, the number of QPs can be reduced. However, when the number of QPs is reduced, the following problems may occur: Figure 4b The CPU resources on the local network device cannot be fully utilized. Figure 4cBy distinguishing between communication threads and business processing threads, the problem of large performance differences between different QPs in the case of unbalanced load can be avoided. However, this method will cause switching problems between the two threads. In an embodiment of the present application, by associating one QP with multiple CQs, fewer QP resources are used, so that the network device can receive multiple messages through the same QP and be processed in parallel by multiple threads, avoiding the problem of cross-thread access.
[0264] exist Figures 1 to 9 On the basis of the corresponding embodiments, in order to better implement the above-mentioned solutions of the embodiments of the present application, related devices for implementing the above-mentioned solutions are also provided below.
[0265] See also Fig.10 , Fig.10 A schematic diagram of a network device provided in an embodiment of the present application, the network device may be as follows Figure 3a Any network device shown. The network device 1000 includes:
[0266] The receiving module 1001 is used to receive first information, second information and RDMA data, where the first information indicates a storage area for the RDMA data, and the second information indicates information of a completion queue CQ, where the storage area and the CQ are associated with the same thread;
[0267] The processing module 1002 is used to process the RDMA data according to the first information and the second information.
[0268] In a possible implementation, the processing module 1002 is further configured to:
[0269] storing the RDMA data in a storage area according to the first information, and generating a completion queue element CQE;
[0270] The CQE is placed into the corresponding CQ according to the second information to process the RDMA data.
[0271] In a possible implementation, the first information includes the number of the non-uniform memory access NUMA node, and according to the first information, the RDMA data is stored in the storage area, and the completion queue element CQE is generated, including:
[0272] Determine the NUMA node according to the NUMA node number;
[0273] Get the work queue element WQE from the memory corresponding to the NUMA node;
[0274] The RDMA data is stored in the storage area specified in the WQE and a CQE is generated.
[0275] In a possible implementation, obtaining a work queue element WQE from a memory corresponding to a NUMA node includes:
[0276] Determine the shared receive queue SRQ corresponding to the NUMA node;
[0277] Get the WQE from the SRQ's memory.
[0278] In a possible implementation, the second information includes a CQ number CQN, and placing the CQE into the corresponding CQ according to the second information to process the RDMA data includes:
[0279] Determine the CQ where the CQE is stored based on the CQN;
[0280] The CQE is placed in the CQ to process the RDMA data.
[0281] In a possible implementation, the network device is further configured to:
[0282] Get the correspondence between threads and CQ;
[0283] Send the corresponding relationship.
[0284] It should be noted that the information interaction, execution process, etc. between the modules in the network device 1000 are the same as those in the present application. Figure 5 The corresponding method embodiments are based on the same concept. For specific contents, please refer to the description in the method embodiments shown above in this application, which will not be repeated here.
[0285] See also Fig.11 , Fig.11 Another structural diagram of a network device provided in an embodiment of the present application, the network device may be as follows Figure 3a Any network device shown. The network device 1100 includes:
[0286] A receiving module 1101 is used to receive RDMA data;
[0287] The processing module 1102 is used to place the completion queue element CQE in the specified completion queue CQ to process the RDMA data. The CQE is obtained based on the stored RDMA data. The CQ corresponds to the thread one by one.
[0288] In a possible implementation, the processing module 1102 is further configured to:
[0289] Get the index corresponding to CQE and the total number of all CQs;
[0290] The remainder of the index and the total number is used as the CQ number;
[0291] Place the CQE into the CQ corresponding to the number to process the data.
[0292] In a possible implementation, the processing module 1102 is specifically configured to:
[0293] Get the number of CQEs stored in each CQ;
[0294] The CQE is placed in the CQ that stores the least number of CQEs to process the data.
[0295] It should be noted that the information interaction, execution process, etc. between the modules in the network device 1100 are the same as those in the present application. Figure 8 The corresponding method embodiments are based on the same concept. For specific contents, please refer to the description in the method embodiments shown above in this application, which will not be repeated here.
[0296] See also Fig.12 , Fig.12 Another structural diagram of a network device provided in an embodiment of the present application. Fig.12 Although the network device 1200 shown in the figure shows certain specific features, those skilled in the art will realize from the embodiments of the present application that for the sake of brevity, Fig.12 Various other features are not shown to avoid obscuring more relevant aspects of the embodiments disclosed in the embodiments of the present application. To this end, as an example, in some implementations, such as Fig.12 As shown, the network device 1200 is implemented by a general bus architecture.
[0297] The network device 1200 includes at least one processor 1201 , a communication bus 1202 , a memory 1203 , and at least one communication interface 1204 .
[0298] The processor 1201, the memory 1203, and the communication interface 1204 communicate via the communication bus 1202, and may also communicate via other means such as wireless transmission. The memory 1203 is used to store instructions, and the processor 1201 is used to execute the instructions stored in the memory 1203. The memory 1203 stores program codes, and the processor 1201 can call the program codes stored in the memory 1203 to execute Figure 5 In the embodiment shown, steps 501 to 503 are performed, or, Figure 8 Steps 801 to 803 in the illustrated embodiment are not described in detail here.
[0299] Optionally, the processor 1201 is a general-purpose central processing unit (CPU), and may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices (PLD), transistor logic devices, hardware components, or any combination thereof. The above-mentioned PLD is a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0300] The communication bus 1202 is used to transmit information between the processor 1201, the memory 1203 and the communication interface 1204. The communication bus 1202 is divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0301] Optionally, the memory 1203 is a read-only memory (ROM) or other types of static storage devices that can store static information and instructions. Alternatively, the memory 1203 is a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions. Alternatively, the memory 1203 is an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited to this. Optionally, the memory 1203 exists independently and is connected to the processor 1201 through the communication bus 1202. Optionally, the memory 1203 and the processor 1201 are integrated together.
[0302] The communication interface 1204 uses any transceiver-like device to communicate with one or more other network devices or communication networks in the network system. The communication interface 1204 includes a wired communication interface. Optionally, the communication interface 1204 also includes a wireless communication interface. Among them, the wired communication interface is, for example, an Ethernet interface. The Ethernet interface is an optical interface, an electrical interface or a combination thereof. The wireless communication interface is a wireless local area network (WLAN) interface, a cellular network communication interface or a combination thereof, etc.
[0303] In a specific implementation, as an embodiment, the processor 1201 includes one or more CPUs, such as Fig.12 CPU0 and CPU1 are shown in the figure.
[0304] In a specific implementation, as an embodiment, the network device 1200 includes multiple processors, such as Fig.12 1 and 1205. Each of these processors is a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The processor here refers to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
[0305] In some embodiments, the memory 1203 is used to store program codes for executing the solution of the present application, and the processor 1201 executes the program codes stored in the memory 1203. In other words, the network device 1200 implements the above-mentioned data processing method embodiment through the processor 1201 and the program codes in the memory 1203.
[0306] It is to be understood that the method steps in the embodiments of the present application may be implemented in hardware or in software instructions executable by the processor 1201. The software instructions may be composed of corresponding software modules, and the software modules may be stored in a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, a register, a hard disk, a mobile hard disk, a CD-ROM, or any other form of storage medium known in the art. In addition, the scope of the device described in the present application is not limited thereto, and the structure of the device may not be limited thereto. Fig. 9 A device may be a stand-alone device or may be part of a larger device. For example, a device may be:
[0307] (1) Independent integrated circuit IC, or chip, or chip system or subsystem;
[0308] (2) having a set of one or more ICs, and optionally, the IC set may also include a storage component for storing data and / or instructions;
[0309] (3) Modules that can be embedded in other devices;
[0310] (4) Receivers, terminals, intelligent terminals, wireless devices, handheld devices, mobile units, vehicle-mounted devices, artificial intelligence devices, machinery and equipment, household equipment, medical equipment, industrial equipment, etc.;
[0311] (5)Others
[0312] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0313] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the data processing method.
[0314] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the data processing method.
[0315] The network device provided in the embodiment of the present application may specifically be a chip, and the chip includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit, etc. The processing unit may execute the computer execution instructions stored in the storage unit so that the chip executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device end, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0316] In some possible embodiments, the above network device can be implemented as a virtualized device. The virtualized device can be a virtual machine (VM) running a program for sending a message function, a virtual router or a virtual switch. The virtualized device is deployed on a hardware device (e.g., a physical server). For example, the network device can be implemented based on a general physical server combined with network function virtualization (NFV) technology.
[0317] It should be understood that the network devices in the above-mentioned various product forms have any functions of the network devices in the above-mentioned method embodiments, which will not be described in detail here.
[0318] Furthermore, the embodiment of the present application also provides a computer program product, which, when executed on a network device, enables the network device to execute the above Figure 5 or Figure 8 The method executed by the network device in the corresponding method embodiment.
[0319] The embodiment of the present application further provides a chip system, including a processor and an interface circuit, wherein the interface circuit is used to receive instructions and transmit them to the processor. The processor is used to implement the method in any of the above method embodiments.
[0320] Optionally, the chip system further includes a memory, and the processor in the chip system may be one or more. The processor may be implemented by hardware or software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented by software, the processor may be a general-purpose processor that implements the method in any of the above method embodiments by reading the software code stored in the memory.
[0321] Optionally, the memory in the chip system may be one or more. The memory may be integrated with the processor or may be separately provided with the processor, which is not limited in the present application. Exemplarily, the memory may be a non-transient processor, such as a read-only memory ROM, which may be integrated with the processor on the same chip or may be provided on different chips. The present application does not specifically limit the type of memory and the arrangement of the memory and the processor.
[0322] The above describes the embodiments of the present application in detail. The steps in the method of the embodiments of the present application can be scheduled in sequence, merged or deleted according to actual needs; the modules in the device of the embodiments of the present application can be divided, merged or deleted according to actual needs.
[0323] It is understood that the devices and methods described in the present application can also be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0324] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0325] The naming or numbering of the steps in this application does not mean that the steps in the method flow must be executed in the time / logical sequence indicated by the naming or numbering. The named or numbered process steps can change the execution order according to the technical purpose to be achieved, as long as the same or similar technical effects can be achieved. The division of the units in this application is a logical division. There may be other division methods when it is implemented in actual applications. For example, multiple units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, and the indirect coupling or communication connection between units can be electrical or other similar forms, which are not limited in this application. In addition, the unit or subunit described as a separate component may or may not be physically separated, may or may not be a physical unit, or may be distributed in multiple circuit units, and some or all of the units can be selected according to actual needs to achieve the purpose of the present application solution.
[0326] The above is only a specific implementation mode of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The various digital numbers involved in the embodiments of the present application are only for the convenience of description and are not used to limit the scope of the embodiments of the present application. The size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic.
[0327] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. A data processing method, characterized in that: include: receiving first information, second information, and RDMA data, wherein the first information indicates a storage area of the RDMA data, the second information indicates information of a completion queue CQ, and the storage area and the CQ are associated with the same thread; The RDMA data is processed according to the first information and the second information.
2. The method according to claim 1, characterized in that The processing of the data according to the first information and the second information includes: storing the RDMA data in the storage area according to the first information, and generating a completion queue element CQE; The CQE is placed into the corresponding CQ according to the second information to process the RDMA data.
3. The method according to claim 2, characterized in that The first information includes a number of a non-uniform memory access NUMA node, and storing the RDMA data in the storage area according to the first information and generating a completion queue element CQE includes: Determine the NUMA node according to the number of the NUMA node; Obtain a work queue element WQE from the memory corresponding to the NUMA node; The RDMA data is stored in the storage area specified in the WQE, and the CQE is generated.
4. The method according to claim 2 or 3, characterized in that: The second information includes a CQ number CQN, and placing the CQE into the corresponding CQ according to the second information to process the RDMA data includes: Determine the CQ in which the CQE is stored according to the CQN; The CQE is placed in the CQ to process the RDMA data.
5. The method according to any one of claims 1 to 4, characterized in that: The processing specifically includes: Determine a storage area of the RDMA data from the CQ using the thread; The RDMA data is acquired from the storage space using the thread to process the RDMA data.
6. The method according to any one of claims 1 to 5, characterized in that: The receiving of the first information, the second information and the RDMA data comprises: The first information, the second information, and the RDMA data are received using an RDMA interface card.
7. A data processing method, characterized in that: include: Receive RDMA data; A completion queue element CQE is placed in a designated completion queue CQ to process the RDMA data, the CQE is obtained based on the stored RDMA data, and the CQ corresponds to a thread one by one.
8. The method according to claim 7, characterized in that Placing the CQE into a specified CQ to process the RDMA data includes: Obtain the index corresponding to the CQE and the total number of all the CQs; The remainder of the index and the total number is used as the number of the CQ; The CQE is placed into the CQ corresponding to the number to process the RDMA data.
9. The method according to claim 7, characterized in that: Placing the CQE into a specified CQ to process the RDMA data includes: Obtain the quantity of the CQE stored in each of all CQs; The CQE is placed in the CQ storing the least number of CQEs, so as to process the RDMA data.
10. The method according to any one of claims 7 to 9, characterized in that: The processing specifically includes: Determine a storage area of the RDMA data from the CQ using the thread; The RDMA data is acquired from the storage space using the thread to process the RDMA data.
11. The method according to any one of claims 7 to 10, characterized in that: The receiving of the first information, the second information and the RDMA data comprises: The first information, the second information, and the RDMA data are received using an RDMA interface card.
12. A network device, characterized in that: include: A receiving module, configured to receive first information, second information, and RDMA data, wherein the first information indicates a storage area of the RDMA data, the second information indicates information of a completion queue CQ, and the storage area and the CQ are associated with the same thread; A processing module is used to process the RDMA data according to the first information and the second information.
13. The network device according to claim 12, characterized in that: The processing module is also used for: storing the RDMA data in the storage area according to the first information, and generating a completion queue element CQE; The CQE is placed into the corresponding CQ according to the second information to process the RDMA data.
14. The network device according to claim 13, characterized in that: The first information includes the number of the NUMA node, and storing the RDMA data in the storage area according to the first information and generating a completion queue element CQE includes: Determine a NUMA node according to the number of the NUMA node; Obtain a work queue element WQE from the memory corresponding to the NUMA node; The RDMA data is stored in the storage area specified in the WQE, and the CQE is generated.
15. The network device according to claim 13 or 14, characterized in that: The second information includes a CQ number CQN, and placing the CQE into the corresponding CQ according to the second information to process the RDMA data includes: Determine the CQ in which the CQE is stored according to the CQN; The CQE is placed in the CQ to process the RDMA data.
16. A network device, characterized in that: include: A receiving module, used for receiving RDMA data; The processing module is used to place a completion queue element CQE in a specified completion queue CQ to process the RDMA data, wherein the CQE is obtained based on the stored RDMA data, and the CQ corresponds to a thread one by one.
17. The network device according to claim 16, characterized in that: The processing module is also used for: Obtain the index corresponding to the CQE and the total number of all the CQs; The remainder of the index and the total number is used as the number of the CQ; The CQE is placed into the CQ corresponding to the number to process the RDMA data.
18. The network device according to claim 16, characterized in that: The processing module is also used for: Obtain the quantity of the CQE stored in each of all CQs; The CQE is placed in the CQ storing the least number of CQEs, so as to process the RDMA data.
19. A network device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a program, and the processor runs the program to execute the method according to any one of claims 1 to 6.
20. A network device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a program, and the processor runs the program to execute the method according to any one of claims 7 to 11.
21. A network system, characterized in that: The method comprises at least one network device for sending first information, second information and RDMA data, and at least one network device according to any one of claims 12 to 15.
22. A network system, characterized in that: The method comprises at least one network device for sending RDMA data, and at least one network device according to any one of claims 16 to 18.
23. A computer-readable storage medium, characterized in that: The method comprises instructions, which, when executed on a computing device, cause the computing device to execute the method according to any one of claims 1 to 6.
24. A computer-readable storage medium, characterized in that: The method comprises instructions, which, when executed on a computing device, cause the computing device to perform the method according to any one of claims 7 to 11.
Citation Information
Cited By
Inter-node communication method and electronic equipment
CN122268868A
