Communication method and system based on socket interface
By extending the socket interface to register user-mode memory addresses in the kernel and enabling direct memory access, the performance degradation caused by CPU involvement in memory copying during SMC protocol communication is resolved, achieving efficient data transmission and reducing development and maintenance costs.
Patent Information
- Application Number
- PCT/CN2025/103958
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-08-05
- Filing Date
- 2025-06-26
- Publication Date
- 2026-02-12
AI Technical Summary
In existing technologies, communication based on the SMC protocol requires the CPU to participate in memory copying and semantic translation between kernel mode and user mode, which leads to reduced communication performance and high development and maintenance costs.
Extend the socket interface. When the local node and the remote node support the shared memory communication SMC protocol and the target link is reachable, register the local memory address requested by the user space into the kernel and perform data transmission through direct memory access, bypassing the CPU's operation on the communication data path.
It improves communication performance, reduces development and maintenance costs, enables direct data communication between user-mode memory regions, and avoids memory copying and semantic conversion between kernel mode and user mode.
Smart Images

Figure CN2025103958_12022026_PF_FP_ABST
Abstract
Description
A communication method and system based on socket interface
[0001] The present disclosure claims priority to Chinese Patent Application No. 202411062523.9, filed on August 5, 2024 with the Chinese Patent Office, entitled "A communication method and system based on socket interface", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present disclosure relates to the field of communication technology, and in particular, to a communication method and system based on socket interface. BACKGROUND
[0003] Large-scale data analysis and transaction processing, high-frequency trading systems, real-time data synchronization and backup, large parallel computing tasks and artificial intelligence model training, and cloud computing and data center internal network optimization scenarios have strict requirements on inter-host communication performance.
[0004] User-mode remote direct memory access (RDMA) verbs are the first choice in the above high-performance network communication scenarios, which allow user-mode processes to bypass the kernel and the central processing unit (CPU) to directly operate data on network hardware, significantly reducing latency and CPU load, providing higher data throughput and lower data transmission latency. However, developing RDMA applications based on verbs requires developers and operation teams to not only have professional network and hardware knowledge, but also continuously invest time and resources in technology updates and system optimization to ensure the efficient operation and stability of the system.
[0005] Shared Memory Communication (SMC) is a high-performance network protocol proposed by IBM, which transparently replaces TCP communication with RDMA communication without any application modification, solving the above problem of too complex programming based on verbs interface, and limiting the maintenance cost to the kernel, greatly reducing the cost of developers and maintenance teams. However, in order to be fully compatible with standard TCP applications, SMC introduces instruction overhead and copy overhead between user mode and kernel in implementation. In view of this technical problem, the related art has not yet proposed an effective solution. SUMMARY
[0006] Embodiments of the present disclosure provide a communication method and system based on socket interface to solve one or more of the above technical problems.
[0007] In a first aspect, the embodiments of the present disclosure provide a socket interface-based communication method, comprising:
[0008] In a case where a local node and a remote node support a shared memory communication (SMC) protocol and a target link is reachable, a local memory address applied for by a user state is registered in a kernel to obtain local address registration information, wherein the target link corresponds to a type of underlying hardware device of the SMC;
[0009] The local address registration information is sent to the remote node, and remote address registration information sent by the remote node is received;
[0010] After target data is written into a space of the local memory address by the user state, the target data is read from the user state by a direct memory access mode and transmitted into a space of a remote memory address corresponding to the remote address registration information.
[0011] In a second aspect, the embodiments of the present disclosure provide a socket interface, comprising:
[0012] A first sub-interface is configured to, in a case where a local node and a remote node support a shared memory communication (SMC) protocol and a target link is reachable, register a local memory address applied for by a user state in a kernel to obtain local address registration information, wherein the target link corresponds to a type of underlying hardware device of the SMC; send the local address registration information to the remote node, and receive remote address registration information sent by the remote node;
[0013] A second sub-interface is configured to, after target data is written into a space of the local memory address by the user state, read the target data from the user state by a direct memory access mode and transmit the target data into a space of a remote memory address corresponding to the remote address registration information.
[0014] In a third aspect, the embodiments of the present disclosure provide a socket interface-based communication system, comprising:
[0015] A local node is configured to, in a case where a local node and a remote node support a shared memory communication (SMC) protocol and a target link is reachable, register a local memory address applied for by a user state in a kernel to obtain local address registration information, wherein the target link corresponds to a type of underlying hardware device of the SMC; send the local address registration information to the remote node, and receive remote address registration information sent by the remote node; after target data is written into a space of the local memory address by the user state, read the target data from the user state by a direct memory access mode and transmit the target data into a space of a remote memory address corresponding to the remote address registration information.
[0016] a remote node configured to determine remote address registration information, send the remote address registration information to the local node, and write the target data into a space of a remote memory address corresponding to the remote address registration information after receiving the target data.
[0017] In a fourth aspect, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory. The processor implements any of the above methods when executing the computer program.
[0018] In a fifth aspect, a computer readable storage medium is provided, which stores a computer program. The computer program, when executed by a processor, implements any of the above methods.
[0019] In a sixth aspect, a computer program product is provided, which includes computer instructions. The computer instructions, when executed by a processor, implement any of the above methods.
[0020] Compared with the related art, the present disclosure has the following advantages:
[0021] The socket interface is extended in the embodiments of the present disclosure. In the case that the local node and the remote node support a shared memory communication (SMC) protocol and a target link is reachable, the extended socket interface registers a local memory address applied for by a user state in a kernel to obtain local address registration information, where the target link corresponds to a type of underlying hardware device of the SMC. The local address registration information is sent to the remote node, and remote address registration information of the remote node is obtained. After target data is written into a space of the local memory address in the user state, the target data is read from the user state in a direct memory access manner and transmitted into a space of a remote memory address corresponding to the remote address registration information. That is, the extended socket interface of the embodiments of the present disclosure can allow an application to directly perform data communication using a user state memory region, without any operation of a CPU on a communication data path, thereby solving the technical problem that the CPU needs to participate in memory copying and semantic conversion between a kernel state and a user state in the communication based on the SMC protocol in the related art, and reducing the communication performance, and further achieving the technical effect of improving the communication performance.
[0022] The above description is only a summary of the technical solutions of the present disclosure. In order to more clearly understand the technical means of the present disclosure, the description can be implemented according to the content of the specification, and in order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the specific implementation manner of the present disclosure is described below. BRIEF DESCRIPTION OF DRAWINGS
[0023] In the drawings, like numerals refer to like elements throughout the several views. The drawings are not necessarily to scale, the emphasis instead being placed upon illustrating the principles of the disclosure. It should be understood that the drawings are merely schematic and that the illustrations are not intended to be limiting.
[0024] FIG. 1 shows a flow chart of a socket interface-based communication method provided in an embodiment of the present disclosure;
[0025] FIG. 2 shows a schematic diagram of a socket interface-based communication architecture provided in an embodiment of the present disclosure;
[0026] FIG. 3 shows a flow chart of another socket interface-based communication method provided in an embodiment of the present disclosure;
[0027] FIG. 4 shows a block diagram of a socket interface structure provided in an embodiment of the present disclosure;
[0028] FIG. 5 shows a block diagram of a socket interface-based communication apparatus provided in an embodiment of the present disclosure;
[0029] FIG. 6 shows a block diagram of a socket interface-based communication system provided in an embodiment of the present disclosure; and
[0030] FIG. 7 shows a block diagram of an electronic device for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] In the following, only certain exemplary embodiments are simply described. As those skilled in the art can recognize, the described embodiments can be modified in various different ways without departing from the concept or scope of the present disclosure. Therefore, the drawings and the description are considered to be exemplary in nature, rather than limiting.
[0032] For the convenience of understanding the technical solutions of the embodiments of the present disclosure, the related technologies of the embodiments of the present disclosure are described below. The following related technologies can be combined with the technical solutions of the embodiments of the present disclosure in any manner as optional solutions, which all belong to the protection scope of the embodiments of the present disclosure.
[0033] Terminology explanation
[0034] TCP, Transmission Control Protocol (TCP), is a connection-oriented, reliable, byte-stream-based transport layer communication protocol defined by IETF RFC 793. In the simplified OSI model of computer network, it completes the functions specified by the fourth layer of the transport layer.
[0035] Socket, socket is a software structure inside a computer network node, acting as an endpoint for sending and receiving data through the network, or a software endpoint for process communication inside the node.
[0036] RDMA, remote direct memory access, is a technology that accesses data in the memory of a remote host without going through the operating system kernel. By bypassing the operating system, it not only saves a lot of CPU resources, but also improves system throughput and reduces system network communication delay, and is widely used in large-scale parallel computer clusters.
[0037] ISM, internal shared memory, is a virtual device that provides a shared memory space for multiple logical partitions (LPARs) or virtual machines (VMs) running on the same physical server. It enables each partition or virtual machine to efficiently exchange data by directly accessing this shared memory area, without going through the network protocol stack, thereby reducing latency and improving communication performance.
[0038] SMC / SMC-D / SMC-R, Shared Memory Communication (SMC) is a high-performance network protocol proposed by IBM. SMC protocol transparently transmits TCP socket stream data in a shared memory access manner, providing high throughput, low latency, and low overhead network. When the shared memory operation in SMC is based on IBM ISM device implementation, it is called Shared Memory Communication over DMA (SMC-D); when the shared memory operation in SMC is based on RDMA device implementation, it is called Shared Memory Communication over RDMA (SMC-R).
[0039] verbs, which is a class of application programming interfaces (APIs) or command sets, is a programming abstraction used to perform specific operations. In RDMA, ibverbs is the user-space programming library name for operating InfiniBand (IB) hardware (IB is a high-performance computer network communication standard, mainly used for high-speed data transmission, especially in data centers, high-performance computing, and enterprise storage. IB is designed to support very high-speed data transmission requirements and ensure data transmission reliability and low latency. IB hardware refers to various physical devices and components related to this communication standard) and defines a series of operations to manage RDMA resources such as Protection Domain, Memory Region, Queue Pair, etc. These operations usually include creating, modifying, and destroying resources, as well as starting data transmission operations, etc.
[0040] Developing RDMA applications based on verbs faces many challenges: 1) developers need to have a deep understanding of RDMA technical details, especially the learning threshold and programming complexity brought by the abstraction of various network card hardware resources; 2) there is a lack of unified operating system (OS) monitoring and operation and maintenance management capabilities, which need to be implemented by the application using RDMA; 3) significant cost of maintaining a large RDMA software stack. These all require developers and operation and maintenance teams not only to have professional network and hardware knowledge, but also to continuously invest time and resources in technology updates and system optimization to ensure the efficient operation and stability of the system.
[0041] In a related technology prior to the present disclosure, RDMA communication management (RDMA-CM) is a set of APIs that manage the connection of RDMA (Remote Direct Memory Access) devices, providing a mechanism to establish, listen, disconnect and destroy RDMA connections. RDMA-CM is built on the InfiniBand Trade Association (IBTA) specification and RDMA over Converged Ethernet (RoCE) technology, and aims to simplify RDMA programming to enable applications to more easily use RDMA technology for high-performance, low-latency network communication. However, its main disadvantages include: 1) unable to reduce the significant cost of maintaining the RDMA software stack dependency, still requires developers and maintenance teams to have professional network and hardware knowledge, and continuously invest time and resources in technology updates and system optimization; 2) the development cost based on RDMA-CM is still higher than the socket interface, and developers may need to implement different code logic for different scenarios.
[0042] In another related technology prior to the present disclosure, for large-scale memory-intensive computing scenarios, an RDMA-based memory system is designed on a distributed computing platform, which discloses the memory of the machines in the cluster as a shared address space. Applications can use transactions to allocate, read, write and release objects in the address space. One of its important goals is also to simplify programming to enable applications to more easily use RDMA technology for high-performance, low-latency network communication. Its main disadvantages include: 1) there is still a cost of maintaining the RDMA software stack dependency in the user mode, which requires developers and maintenance teams to have certain professional network and hardware knowledge; 2) the development and learning cost is high, which is still higher than the socket interface, on the other hand, as an RDMA-based distributed memory system, the coding flexibility in general scenarios is weak, and developers may need to implement additional code for different scenarios, such as switching back to using the socket model for coding in the RDMA failure scenario.
[0043] Later, the related technology proposes a new kernel network protocol stack SMC-R, which can transparently replace TCP communication with RDMA communication without any modification, solves the problem of too complex programming based on verbs interface, and limits the maintenance cost to the kernel, greatly reducing the cost of developers and maintenance team. However, in order to be fully compatible with the standard TCP application, SMC introduces the instruction overhead and copy overhead of switching between user mode and kernel in implementation, and compared with the light and thin data path of user mode verbs, the data path of SMC which emphasizes generality is relatively complex, which leads to a large performance gap between SMC-based communication and user mode verbs-based communication.
[0044] Therefore, the embodiments of the present disclosure provide a socket interface-based communication method to wholly or partially solve the above technical problems. The application scenarios of the embodiments of the present disclosure include but are not limited to: latency-sensitive data query and processing (such as high-performance data query and processing scenarios of in-memory databases Redis, distributed in-memory object caching systems Memcached, relational databases PostgreSQL, etc.), high-throughput data transmission.
[0045] As shown in FIG. 1, the above-mentioned socket interface-based communication method includes:
[0046] S102, in the case that the local node and the remote node support shared memory communication SMC protocol and the target link is reachable, register the local memory address applied by the user state to the kernel to obtain local address registration information, wherein the target link corresponds to the type of the underlying hardware device of the SMC.
[0047] It should be noted that the above-mentioned local node and remote node can be a local host and a remote host, and the operating system of the local host and the remote host includes a user state, a kernel state and an underlying hardware device. Before establishing SMC communication between the local host and the remote host, the local host protocol stack can first establish a TCP connection with the remote host in the kernel, use a special TCP option to indicate that it supports SMC in the handshake process, and confirm that the remote host also supports SMC. In addition, the local host and the remote host SMC-R protocol stack will create new or reuse existing RDMA resources to establish available RDMA RC links, so that network transmission will be completed based on RDMA network, that is, the target link is reachable. The above-mentioned underlying hardware device can include an internal shared memory ISM device and a remote direct memory access RDMA device. Correspondingly, the above-mentioned target link can include a link implemented based on RDMA technology and a link implemented based on direct memory access DMA technology. Correspondingly, the kernel module can be an SMC-R module and an SMC-D module. The above-mentioned local address registration information can include a local address registration ID.
[0048] S104, send the local address registration information to the remote node, and receive remote address registration information sent by the remote node.
[0049] Optionally, in the embodiments of the present disclosure, the manner of sending the local address registration information to the remote node includes but is not limited to: manner one, copying the local address registration information to the buffer of the kernel, reading the local address registration information from the kernel buffer by direct memory access, and sending the local address registration information to the remote node. That is, the local address registration information is sent by using the SMC general data path. Manner two, establishing a TCP connection to send the local address registration information. Correspondingly, after receiving the local address registration information sent by the local node, the remote node sends the remote address registration information of the remote node to the local node by the same manner as the sending end.
[0050] S106, after writing the target data into the space of the local memory address in the user mode, reading the target data from the user mode by direct memory access and transmitting the target data into the space of the remote memory address corresponding to the remote address registration information. It should be noted that the above-mentioned target data can include application data, user-defined control data, etc.
[0051] As can be seen from the above, the socket interface is extended in the embodiments of the present disclosure. The extended socket interface registers the local memory address applied by the user state in the kernel to obtain the local address registration information under the condition that the local node and the remote node support the shared memory communication SMC protocol and the target link is reachable, wherein the target link corresponds to the type of the underlying hardware device of the SMC. The local address registration information is sent to the remote node, and the remote address registration information of the remote node is obtained. After writing the target data into the space of the local memory address in the user state, the target data is read from the user state by direct memory access and transmitted into the space of the remote memory address corresponding to the remote address registration information. That is, the extended socket interface of the embodiments of the present disclosure can allow the application to directly use the user state memory area for data communication without any operation of the CPU on the communication data path, thereby solving the technical problem that the CPU needs to participate in the memory copying and semantic conversion between the kernel state and the user state in the related art based on the SMC protocol communication, and reducing the communication performance, and further achieving the technical effect of improving the communication performance.
[0052] In a possible implementation, the reading of the target data from the user mode and the transmission of the target data to the space of the remote memory address corresponding to the remote address registration information by the direct memory access mode comprises: S11, mapping the target data to the kernel to obtain a data mapping relationship; and S12, enabling the underlying hardware device to directly read the target data of the user mode and to transmit the target data to the space of the remote memory address corresponding to the remote address registration information through a network corresponding to the underlying hardware device based on the data mapping relationship. Optionally, in the embodiment of the present disclosure, the implementation of S11 can be based on mmap memory mapping to map the target data to the kernel. Since the local memory address applied for by the user mode is registered to the kernel to obtain the local address registration information, the target data can be mapped to the space corresponding to the local address registration information based on the local address registration information to obtain the mapping relationship between the target data and the space corresponding to the local address registration information. Optionally, the mapping relationship can comprise a start address of data mapping, a data mapping length, and the like. In the SMC, the underlying hardware reads data from the kernel buffer by the DMA technology, and the embodiment of the present disclosure determines the mapping relationship, so that the underlying hardware can directly access the target data of the user mode and bypass the CPU. Through the steps S11-S12, the SMC protocol is compatible, the user mode memory region is allowed to be directly used for data communication by the application, the memory copying and semantic conversion between the kernel mode and the user mode are avoided, the CPU does not need to perform any operation on the data on the communication data path, and the communication performance is greatly improved.
[0053] Optionally, the manner of sending the local address registration information to the remote node can comprise: S21, copying the local address registration information to the buffer of the kernel; and S22, reading the local address registration information from the buffer of the kernel by the direct memory access mode and sending the local address registration information to the remote node. That is, in the embodiment of the present disclosure, the SMC general data path can be used to transmit the local address registration information and the remote address registration information. It should be noted that the SMC general data path can be that the local node application program (APP) copies the data to be sent to the ring buffer allocated by the SMC protocol stack for data transmission through the socket interface, and the SMC protocol stack directly and efficiently writes the data into the ring buffer of the remote node by the RDMA write operation.
[0054] In addition to directly exchanging application data on the user memory, the embodiments of the present disclosure can also implement information notification. Specifically, the target data can include application data and user-defined control data in the user state, wherein the user-defined control data includes at least one of the following: remote address registration information, write offset information, write length information, read offset information, and read length information. Optionally, the application data and the user-defined control data in the user state can be read from the user state by using the direct memory access mode, and transmitted to the space of the remote memory address corresponding to the remote address registration information. That is, the extended socket interface provided by the embodiments of the present disclosure allows users to exchange custom control message data in addition to directly exchanging application data, which further improves performance and greatly improves the flexibility of user coding.
[0055] The embodiments of the present disclosure will be described below in conjunction with specific examples. It should be noted that in the present example, SMC-R is taken as an example for description.
[0056] FIG. 2 is the overall design framework of the present example. It includes the user state, the kernel state, and hardware (including RDMA devices). SMC-R is a kernel module for implementing the SMC-R protocol. SMC-R works in the kernel space, supports the network behavior described by the socket interface of the user program (APP) upward, and uses the IB verbs interface to implement the RDMA network transmission downward. Send_buf is the ring buffer allocated by the SMC-R kernel protocol stack for connection data transmission. The receiving buffer is omitted in FIG. 2. The extended socket interface provided by the present example allows users to actively create a user memory area mapping to provide SMC for direct data exchange, and data transmission no longer depends on the kernel state and user state copying. On this basis, in the process of data exchange, the extended socket interface also allows users to exchange custom control messages, which further improves performance and greatly improves the flexibility of user coding. In FIG. 2, the left side is the data transmission path proposed in the present example, and the right side is the data transmission path of SMC-R in the related art.
[0057] In the design framework, taking a complete inter-host communication as an example, the method comprises: handshake connection establishment (using a standard socket interface to create an SMC connection); resource preparation and registration (the sending end applies for a piece of local memory local_addr in a local address space; using an extended socket interface, the local address memory local_addr is registered in the SMC connection, and local address registration information local_id is obtained; using an SMC-R general data path, the local address registration information local_id is sent to a remote end; waiting for event notification, and obtaining remote memory address registration information remote_id); sending data (directly writing application data into the local memory address local_addr in the user state, using the extended socket interface to carry the data corresponding to the local_addr address to a remote address space corresponding to the remote_id address information; if it is needed to notify the opposite end of the current write, using the SMC-R general data path to notify the opposite end, and delivering the current write information, including address information (remote_id), write offset, write length, etc.). Receiving data (waiting for event notification, and obtaining opposite end write event information such as local address information (local_id), write offset, write length, etc. Directly reading and processing the data of the local_addr local address corresponding to the local_id), as shown in S301-S311 in FIG. 3. The example uses a socket-based interface for programming, greatly reducing the learning cost and development cost, and meanwhile, the creation or destruction of RDMA-related resources is completely handled by the kernel SMC, and the user process no longer needs to handle complex RDMA verbs operations. The extended socket interface allows the user to bypass the SMC ring buffer data path, directly exchange data and information on the user-defined user state memory, and saves the memory copy and semantic conversion between the kernel state and the user state, greatly improving the communication performance on the basis of the native SMC.
[0058] In summary, the embodiment of the disclosure places the use of RDMA in the kernel SMC module based on the kernel protocol stack, greatly reducing the development cost of the developer and the management and maintenance cost of the huge RDMA software stack. In most scenarios, the latency and throughput yield close to the user state verbs can be obtained, which not only avoids the cost of directly using the user state RDMA verbs, but also well solves the problem that the performance of SMC in the high-performance scenario is not much different from ibverbs. In addition, by using the SMC protocol, the control plane is compatible with the socket interface, the application based on TCP does not need to be modified, the data plane adds a very simple interface based on the SMC socket, the learning cost is low, the implementation in the kernel state is realized, the reusability is strong, and different code logics do not need to be implemented for different scenarios.
[0059] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present disclosure are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.
[0060] The technical solutions of the present disclosure and how the technical solutions of the present disclosure solve the foregoing technical problems will be described in detail below with specific embodiments. Several specific embodiments listed can be combined with each other, and the same or similar concepts or processes can not be described again in some embodiments. The embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0061] Corresponding to the application scenarios and methods of the method provided by the embodiments of the present disclosure, the embodiments of the present disclosure also provide a socket interface. As shown in FIG. 4, it is a socket interface structure block diagram of an embodiment of the present disclosure. The interface can include:
[0062] The first sub-interface 42 is configured to register the local memory address applied by the user state to the kernel to obtain local address registration information in the case that the local node and the remote node support shared memory communication SMC protocol and the target link is reachable, wherein the target link corresponds to the underlying hardware device type of the SMC, the local address registration information is sent to the remote node, and the remote address registration information sent by the remote node is received;
[0063] The second sub-interface 44 is configured to read the target data from the user state by a direct memory access mode and transmit the target data to the space of the remote memory address corresponding to the remote address registration information after the target data is written into the space of the local memory address by the user state.
[0064] In a case that the local node and the remote node support a shared memory communication (SMC) protocol and a target link is reachable through the extended socket interface shown in FIG. 4, a local memory address applied by a user state is registered in a kernel to obtain local address registration information, wherein the target link corresponds to a type of underlying hardware device of the SMC; the local address registration information is sent to the remote node, and remote address registration information of the remote node is obtained; after target data is written into a space of the local memory address in the user state, the target data is read from the user state in a direct memory access manner and transmitted into a space of a remote memory address corresponding to the remote address registration information. That is, the extended socket interface of the embodiment of the present disclosure can allow an application to directly use a user state memory region for data communication without any operation of a CPU on a communication data path, thereby solving the technical problem that in the related art, a CPU needs to participate in memory copying and semantic conversion between a kernel state and a user state in SMC protocol-based communication, leading to reduced communication performance, and thereby achieving the technical effect of improving communication performance.
[0065] Optionally, the target data includes application data and user state customized control data, wherein the user state customized control data includes at least one of the remote address registration information, write offset information, write length information, read offset information, and read length information.
[0066] Corresponding to the application scenario and method of the method provided by the embodiment of the present disclosure, the embodiment of the present disclosure further provides a socket interface-based communication device. As shown in FIG. 5, a structure block diagram of a socket interface-based communication device according to an embodiment of the present disclosure, the device can include:
[0067] The registration module 52 is configured to register, in a kernel, a local memory address applied for by a user state to a local node in a case where the local node and a remote node support a shared memory communication (SMC) protocol and a target link is reachable, to obtain local address registration information, where the target link corresponds to a type of underlying hardware device of the SMC. It should be noted that the local node and the remote node can be a local host and a remote host, and the operating system of the local host and the remote host includes a user state, a kernel state, and an underlying hardware device. Before the local host and the remote host establish SMC communication, the local host protocol stack can first establish a TCP connection with the remote host in the kernel, and use a special TCP option in a handshake process to indicate that the local host supports the SMC and confirms that the remote host also supports the SMC. In addition, the local host and the remote host SMC-R protocol stack will create new or reuse existing RDMA resources to establish an available RDMA RC link, so that network transmission will be completed based on an RDMA network, that is, the target link is reachable. The underlying hardware device can include an internal shared memory (ISM) device and a remote direct memory access (RDMA) device. Correspondingly, the target link can include a link implemented based on an RDMA technology and a link implemented based on a direct memory access (DMA) technology. Correspondingly, the kernel module can be an SMC-R module and an SMC-D module. The local address registration information can include a local address registration ID.
[0068] The processing module 54 is configured to send the local address registration information to the remote node and receive remote address registration information sent by the remote node. Optionally, in the embodiment of the present disclosure, the manner of sending the local address registration information to the remote node includes but is not limited to the following two manners. Manner one: copying the local address registration information to a buffer of the kernel, reading the local address registration information from the kernel buffer by a direct memory access manner, and sending the local address registration information to the remote node. That is, the local address registration information is sent by using a general data path of the SMC. Manner two: establishing a TCP connection to send the local address registration information. Correspondingly, after receiving the local address registration information sent by the local node, the remote node sends remote address registration information of the remote node to the local node by the same manner as the sending end.
[0069] The communication module 56 is configured to read, from the user state, target data by a direct memory access manner and transmit the target data into a space of a remote memory address corresponding to the remote address registration information after the target data is written into a space of the local memory address in the user state. It should be noted that the target data can include application data and user state self-defined control data.
[0070] The socket interface is extended by the device shown in FIG. 5. In the case that the local node and the remote node support a shared memory communication (SMC) protocol and a target link is reachable, the extended socket interface registers a local memory address applied for by a user state in a kernel to obtain local address registration information, wherein the target link corresponds to a type of underlying hardware device of the SMC; sends the local address registration information to the remote node and obtains remote address registration information of the remote node; after target data is written into a space of the local memory address in the user state, reads the target data from the user state by a direct memory access mode and transmits the target data into a space of a remote memory address corresponding to the remote address registration information. That is, the extended socket interface of the embodiment of the present disclosure can allow an application to directly perform data communication using a user state memory region without any operation of a CPU on a communication data path, thereby solving the technical problem that in the related art, a CPU needs to participate in memory copying and semantic conversion between a kernel state and a user state in SMC protocol-based communication, resulting in reduced communication performance, and thereby achieving the technical effect of improving communication performance.
[0071] In one possible implementation, the communication module 56 includes: a mapping unit configured to map the target data into the kernel to obtain a data mapping relationship; and a communication unit configured to cause the underlying hardware device to directly read the target data of the user state through the data mapping relationship and transmit the target data through a network corresponding to the underlying hardware device into a space of a remote memory address corresponding to the remote address registration information. Optionally, in the embodiment of the present disclosure, the implementation of S11 can be based on mmap memory mapping to map the target data into the kernel. Since the local memory address applied for by the user state is registered in the kernel to obtain the local address registration information, the target data can be mapped into a space corresponding to the local address registration information based on the local address registration information to obtain a mapping relationship between the target data and the space corresponding to the local address registration information. Optionally, the mapping relationship can include a start address of data mapping, a data mapping length, and the like. In the SMC, the underlying hardware reads data from a kernel buffer through a DMA technology, and the embodiment of the present disclosure determines the mapping relationship, so that the underlying hardware can directly access the target data of the user state and bypass the CPU. Through steps S11-S12, the SMC protocol is compatible, and the application is allowed to directly perform data communication using the user state memory region, thereby avoiding memory copying and semantic conversion between the kernel state and the user state, achieving that the CPU does not need to perform any operation on the data on the communication data path, and greatly improving the communication performance.
[0072] The processing module 54 comprises: a copying unit, configured to copy the local address registration information into the buffer of the kernel; and a processing unit, configured to read the local address registration information from the kernel buffer by using a direct memory access mode, and send the local address registration information to the remote node. That is, in the embodiment of the present disclosure, the SMC general data path can be used to transmit the local address registration information and the remote address registration information. It should be noted that the SMC general data path can be that the local node application program (APP) copies the data to be sent to the ring buffer allocated by the SMC protocol stack for data sending through a socket interface, and the SMC protocol stack directly and efficiently writes the data into the ring buffer of the remote node by using a RDMA write operation.
[0073] In addition to the application data exchange on the user state memory, the above device can also realize information notification. Specifically, the target data can comprise: application data, and user state custom control data, wherein the user state custom control data comprises at least one of the following: remote address registration information, write offset information, write length information, read offset information, and read length information. Optionally, the application data and the user state custom control data can be read from the user state by using a direct memory access mode, and transmitted to the space of the remote memory address corresponding to the remote address registration information. That is, the extended socket interface provided by the embodiment of the present disclosure can not only directly exchange application data, but also allow the user to exchange custom control message data, thereby further improving the performance and greatly improving the flexibility of user coding.
[0074] The functions of each module in each device of the embodiments of the present disclosure can be referred to the corresponding description in the above method, and have the corresponding beneficial effects, which will not be described here again.
[0075] Corresponding to the application scenarios and methods of the method provided by the embodiments of the present disclosure, the embodiments of the present disclosure also provide a socket interface-based communication system. As shown in FIG. 6, the structure block diagram of the socket interface-based communication system according to an embodiment of the present disclosure, the system can comprise:
[0076] The local node 62 is configured to register a local memory address applied by a user state into a kernel to obtain local address registration information in a case that the local node and a remote node support a shared memory communication (SMC) protocol and a target link is reachable, the target link corresponds to a type of underlying hardware device of the SMC; send the local address registration information to the remote node, and receive remote address registration information sent by the remote node; after target data is written into a space of the local memory address by the user state, read the target data from the user state by a direct memory access mode and transmit the target data into a space of a remote memory address corresponding to the remote address registration information. It should be noted that the local node and the remote node can be a local host and a remote host, and an operating system of the local host and the remote host includes a user state, a kernel state and an underlying hardware device. Before the local host and the remote host establish SMC communication, a protocol stack of the local host can first establish a TCP connection with the remote host in the kernel, and a special TCP option is used in a handshake process to indicate that the local host supports SMC and to confirm that the remote host also supports SMC. In addition, the local host and the remote host SMC-R protocol stack create new or reuse existing RDMA resources to establish an available RDMA RC link, so that network transmission is completed based on an RDMA network, that is, the target link is reachable. The underlying hardware device can include an internal shared memory (ISM) device and a remote direct memory access (RDMA) device. Correspondingly, the target link can include a link implemented based on an RDMA technology and a link implemented based on a direct memory access (DMA) technology. Correspondingly, the kernel module can be an SMC-R module and an SMC-D module. The local address registration information can include a local address registration ID. Alternatively, in the embodiment of the present disclosure, a manner of sending the local address registration information to the remote node includes but is not limited to the following two manners. Manner one: copy the local address registration information into a buffer of the kernel, read the local address registration information from the kernel buffer by a direct memory access mode, and send the local address registration information to the remote node. That is, the local address registration information is sent by using a general data path of SMC. Manner two: establish a TCP connection to send the local address registration information. Correspondingly, after the remote node receives the local address registration information sent by the local node, the remote address registration information of the remote node is sent to the local node by the same manner as the sending end.
[0077] The remote node 64 is configured to determine remote address registration information, send the remote address registration information to the local node, and write target data into a remote memory address space corresponding to the remote address registration information after receiving the target data.
[0078] In the system shown in FIG. 6, the local node 62 and the remote node 64 support a shared memory communication SMC protocol, and a target link is reachable, in which case, a local memory address applied for by a user state is registered in a kernel to obtain local address registration information, in which the target link corresponds to a type of underlying hardware device of the SMC; the local address registration information is sent to the remote node 64, and remote address registration information of the remote node 64 is obtained; after target data is written into a space of the local memory address in the user state, the target data is read from the user state in a direct memory access mode and transmitted into a space of a remote memory address corresponding to the remote address registration information. That is, the socket interface is extended in the embodiment of the present disclosure, which can allow an application to directly communicate data using a user state memory region without any operation of a CPU on a communication data path, thereby solving the technical problem that the CPU needs to participate in memory copying and semantic conversion between a kernel state and a user state in related art communication based on the SMC protocol, and reducing communication performance, and further achieving the technical effect of improving communication performance.
[0079] The functions of each module in each system of the embodiments of the present disclosure can be referred to the corresponding description in the above method, and has the corresponding beneficial effects, which will not be repeated here.
[0080] FIG. 7 is a block diagram of an electronic device for implementing the embodiments of the present disclosure. As shown in FIG. 7, the electronic device includes a memory 701 and a processor 702, and the memory 701 stores a computer program executable on the processor 702. The processor 702 implements the method in the above embodiments when executing the computer program. The number of the memory 701 and the processor 702 can be one or more.
[0081] The electronic device further includes:
[0082] The communication interface 703 is configured to communicate with external devices and transmit data.
[0083] If the memory 701, the processor 702 and the communication interface 703 are implemented independently, the memory 701, the processor 702 and the communication interface 703 can be connected to each other through a bus and complete communication between each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in FIG. 7, but it does not mean that there is only one bus or only one type of bus.
[0084] Optionally, in a specific implementation, if the memory 701, the processor 702 and the communication interface 703 are integrated on a chip, the memory 701, the processor 702 and the communication interface 703 can complete communication between each other through an internal interface.
[0085] The embodiment of the present disclosure provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the method provided in the embodiment of the present disclosure.
[0086] The embodiment of the present disclosure also provides a chip, which includes a processor, is used for calling and running instructions stored in a memory, so that a communication device installed with the chip executes the method provided in the embodiment of the present disclosure.
[0087] The embodiment of the present disclosure also provides a chip, which includes an input interface, an output interface, a processor and a memory, the input interface, the output interface, the processor and the memory are connected through an internal connection path, and the processor is used for executing code in the memory, when the code is executed, the processor is used for executing the method provided in the embodiment of the present disclosure.
[0088] It is to be understood that the above-mentioned processor can be a central processing unit (CPU), and can 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, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. It is to be noted that the processor can be a processor supporting an advanced RISC machine (ARM) architecture.
[0089] Further, the memory can include a read-only memory and a random access memory, optionally. The memory can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. The non-volatile memory can include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically EPROM (EEPROM), or a flash memory, for example. The volatile memory can include a random access memory (RAM) used as an external cache. Many forms of RAM are available by way of example but not limitation. For example, a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous DRAM (SDRAM), a double data rate SDRAM (DDR SDRAM), an enhanced SDRAM (ESDRAM), a SyncLink DRAM (SLDRAM), and a direct Rambus RAM (DR RAM) can be used.
[0090] In the above-described embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded on a computer, all or part of the processes or functions according to the present disclosure are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another computer-readable storage medium.
[0091] In the description of the present disclosure, the description of the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" and the like means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present disclosure. Moreover, the specific features, structures, materials, or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples. In addition, different embodiments or examples described in the present disclosure and features of different embodiments or examples can be combined and combined by those skilled in the art without contradiction.
[0092] In addition, the terms "first", "second", etc. are used only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the technical features indicated. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "a plurality of" is two or more, unless otherwise explicitly specified.
[0093] Any process or method described in the flowchart or otherwise described herein can be understood as a representation of code including one or more executable instructions for implementing specific logical functions or processes. Moreover, the scope of the preferred embodiments of the present disclosure includes additional implementations in which the functions can be performed in an order different from that shown or discussed, including functions performed in a substantially simultaneous manner, or in reverse order.
[0094] The logic and / or steps described in the flowchart or otherwise described herein, for example, can be considered a list of executable instructions for implementing the logic function, which can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, a processor-based system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions, or in conjunction with such an instruction execution system, apparatus, or device.
[0095] It should be understood that each part of the present disclosure can be implemented in hardware, software, firmware or a combination thereof. In the above embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above-mentioned embodiment method can be completed by a program instructing the relevant hardware, which can be stored in a computer readable storage medium, and the program includes one of the steps of the method embodiment or a combination thereof when executed.
[0096] In addition, each functional unit in various embodiments of the present disclosure can be integrated into one processing module, or each unit can exist physically independently, or two or more units can be integrated into one module. The above integrated module can be realized in the form of hardware or in the form of a software functional module. The above integrated module, if realized in the form of a software functional module and sold or used as an independent product, can also be stored in a computer readable storage medium. The storage medium can be a read-only memory, a magnetic disk or an optical disk, etc.
[0097] The above is only exemplary embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art can easily think of various changes or replacements within the technical range disclosed in the present disclosure, which should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.
Claims
1. A socket interface based communication method, comprising: registering, in a case where a local node and a remote node support a shared memory communication (SMC) protocol and a target link is reachable, a local memory address applied for by a user state into a kernel to obtain local address registration information, wherein the target link corresponds to a type of underlying hardware device of the SMC; sending the local address registration information to the remote node and receiving remote address registration information sent by the remote node; after writing target data into a space of the local memory address in the user state, reading the target data from the user state by a direct memory access mode and transmitting the target data into a space of a remote memory address corresponding to the remote address registration information.
2. The method of claim 1, wherein, reading the target data from the user state by the direct memory access mode and transmitting the target data into the space of the remote memory address corresponding to the remote address registration information comprises: mapping the target data into the kernel to obtain a data mapping relationship; by the data mapping relationship, causing the underlying hardware device to directly read the target data of the user state and transmit the target data to the space of the remote memory address corresponding to the remote address registration information through a network corresponding to the underlying hardware device.
3. The method of claim 2, wherein, mapping the target data into the kernel to obtain the data mapping relationship comprises: obtaining the local address registration information; mapping the target data into a space corresponding to the local address registration information to obtain a mapping relationship between the target data and the space corresponding to the local address registration information.
4. The method according to any one of claims 1 to 3, wherein, sending the local address registration information to the remote node comprises: copying the local address registration information into a kernel buffer; reading the local address registration information from the kernel buffer by the direct memory access mode and sending the local address registration information to the remote node.
5. The method according to any one of claims 1 to 4, wherein, The target data comprises application data and user state customized control data, wherein the user state customized control data comprises at least one of remote address registration information, write offset information, write length information, read offset information and read length information.
6. The method according to any one of claims 1 to 5, wherein, The underlying hardware device comprises an internal shared memory (ISM) device or a remote direct memory access (RDMA) device.
7. The method of claim 6, wherein, In a case where the underlying hardware device is the ISM device, the target link is a direct memory access (DMA) link, and in a case where the underlying hardware device is the RDMA device, the target link is an RDMA link. 8.A socket interface, comprising: a first sub-interface configured to, in a case where a local node and a remote node support a shared memory communication (SMC) protocol and a target link is reachable, register a local memory address applied for by a user state into a kernel to obtain local address registration information, wherein the target link corresponds to a type of underlying hardware device of the SMC, send the local address registration information to the remote node, and receive remote address registration information sent by the remote node; a second sub-interface, configured to read the target data from the user mode by a direct memory access mode and transmit the target data into a space of a remote memory address corresponding to the remote address registration information after the target data is written into the space of the local memory address in the user mode.
9. The socket interface of claim 8, wherein, The target data comprises application data and user mode customized control data, wherein the user mode customized control data comprises at least one of remote address registration information, write offset information, write length information, read offset information and read length information. 10.A socket interface-based communication system, comprising: a local node, configured to register a local memory address applied by a user mode into a kernel to obtain local address registration information in a case that the local node and a remote node support a shared memory communication (SMC) protocol and a target link is reachable, wherein the target link corresponds to a type of underlying hardware device of the SMC; send the local address registration information to the remote node and receive remote address registration information sent by the remote node; read target data from the user mode by a direct memory access mode and transmit the target data into a space of a remote memory address corresponding to the remote address registration information after the target data is written into a space of the local memory address in the user mode; a remote node, configured to determine remote address registration information and send the remote address registration information to the local node, and write the target data into a space of a remote memory address corresponding to the remote address registration information after the target data is received.
11. The system of claim 10, wherein, The underlying hardware device comprises an internal shared memory (ISM) device or a remote direct memory access (RDMA) device, the target link is a direct memory access (DMA) link when the underlying hardware device is the ISM device, and the target link is an RDMA link when the underlying hardware device is the RDMA device. 12.An electronic device, comprising a memory, a processor and a computer program stored in the memory, wherein the processor implements the method in any one of claims 1-7 when executing the computer program. 13.A computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program implements the method in any one of claims 1-7 when executed by a processor. 14.A computer program product, comprising computer instructions, wherein the computer instructions implement the method in any one of claims 1-7 when executed by a processor.
Citation Information
Patent Citations
Method and device for communication between kernel mode and user mode and terminal
CN108062253A
Data transmission method and device based on RDMA (Remote Direct Memory Access) under Linux operating system
CN112948318A
Zero-copy data transmission method based on Rsocket protocol
CN113064846A
Array structure suitable for pure user mode far-end direct memory access and optimization method
CN113448897A
Data interaction method and device for Linux kernel mode and user mode
CN114356598A