Method for accelerating interconnection bus network communication
Through distributed memory management and semantic perception memory page migration technology, the problems of insufficient memory management capabilities and high data copying times in interconnected bus network communication are solved, and efficient memory utilization and big data transmission efficiency are achieved.
Patent Information
- Application Number
- CN202411025645.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-15
AI Technical Summary
When using the interconnected bus to communicate directly, there are problems such as insufficient memory management capabilities, many data copy times, and performance bottlenecks. Especially in a multi-process/multi-machine environment, it is impossible to efficiently utilize shared memory and Reduce data copying.
Using distributed memory management method, the shared memory is divided into thread management area and segment management area, the memory mapped address is recorded through the TLS structure area, and the semantic-aware memory page migration technology can achieve zero copy of data and reduce traditional network transmission. Copying process.
It effectively solves the competition problem of multi-process/multi-machine shared memory applications and the problem of non-universal virtual addresses, improves network transmission efficiency, and significantly improves the efficiency of big data transmission through zero-copy technology.
Smart Images

Figure CN118964061A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of network communication applications, and in particular relates to a method for accelerating interconnect bus network communication. Background Art
[0002] For network communication, there is currently a method of using an interconnect bus to enable machines and virtual machines in the same rack to communicate by directly reading and writing shared memory. This method can remove the conversion of data from user state to kernel state during network transmission to improve the efficiency of network communication. Even though some research methods have moved the data conversion during network transmission to user state, the final data transmission still needs to be transmitted through the network card, which still depends on the transmission speed limit of the network, and the data needs to be copied many times during this period. This shows that using the interconnect bus to directly read and write memory to replace the traditional network is a very advantageous method. The traditional method of using shared memory to transfer data is to divide a shared area as a message queue, and then write the data into the memory block requested from the shared memory, write the address of this block into the message queue, and the reader takes this address from the message queue for reading.
[0003] Although directly using the interconnect bus to read and write memory to communicate instead of the traditional network can improve communication efficiency, if each time data needs to be stored in the shared memory, a piece of memory is simply allocated from the shared memory in a simple linear incremental method without any memory management capabilities, the memory in the shared memory will no longer be used further over time, and the released memory cannot be efficiently reused. Since the devices using the shared memory based on the interconnect bus can be different processes, and can even be distributed in different host machines, the traditional memory management scheme is for a single process, so a special memory management method for the shared memory of the interconnect bus is needed, so as to further optimize the communication method based on the interconnect bus.
[0004] In the communication method based on direct reading and writing of memory on the interconnect bus, the data flow is divided into three parts. The write end writes the data to be sent into the local buffer (local DRAM), and then copies it from the local DRAM to the interconnect bus shared memory; the read end copies the data from the interconnect bus shared memory to the local DRAM (the buffer requested by the program). It can be seen from this that when writing data, the same data needs to be copied twice. When the data is large, this will also become a performance bottleneck. If automatic page migration can be performed so that the data can be written directly to the interconnect bus shared memory when it is written to the user buffer, then one copy can be reduced, and zero copy technology can be implemented, so that performance is improved. Summary of the invention
[0005] In view of the above deficiencies in the prior art, the purpose of the invention is to provide a method for accelerating interconnection bus network communication, a distributed memory management method in an electronic device and a storage medium, which not only solves the competition problem when multiple processes / multiple machines apply for memory from a shared memory at the same time, but also solves the problem that virtual addresses are not universal when reading and writing the same memory block between each other. It is very suitable for managing the shared memory of the Internet, and effectively improves the efficiency of network transmission using the Internet; and the semantically-aware memory page migration method can achieve zero copy of data when transmitting large data, which significantly improves the efficiency of transmitting large data during interconnection bus communication.
[0006] A first aspect of the present invention provides a method for accelerating interconnect bus network communication, which is applied to distributed shared memory management, comprising:
[0007] Map the shared memory to each thread and divide the shared memory into a thread management area and a segment management area;
[0008] Each thread seizes the TLS structure area of each thread in the thread management area, and records the mapping head address of the shared memory in each thread into the TLS structure area;
[0009] Each thread applies for a memory block in the segment management area, and determines whether the memory block of the first thread needs to be used by other threads except the first thread;
[0010] If the judgment result is that the memory block of the first thread needs to be used by other threads except the first thread, the difference between the memory block of the first thread and the first address of the shared memory is sent to the other threads except the first thread;
[0011] After receiving the difference between the memory block of the first thread and the shared memory first address, the other threads except the first thread determine the virtual address of the memory block used in each thread according to the difference and the mapping first address of each thread.
[0012] Furthermore, in the above method for accelerating interconnect bus network communication, each thread preempts the TLS structure area of each thread in the thread management area, including:
[0013] In the thread memory management area, by jumping the TLS structure size in sequence, the thread ID is preempted to fill in the specific position in the TLS structure in the CAS manner, marking the TLS structure area of each thread that is preempted;
[0014] The TLS structure area is used to store some memory allocation information of each thread.
[0015] Furthermore, in the above method for accelerating interconnect bus network communication, each thread applies for a memory block in the segment management area, and the method also includes:
[0016] Grab a byte in the segment management area and determine the segment ID based on the position of the byte in the segment management area;
[0017] Determine the starting address of the segment to be applied for this time based on the total size of the thread management area and the segment management area and the segment ID;
[0018] Divide the requested segment into multiple pages;
[0019] Multiple pages are provided by dividing them into unused blocks according to the block size.
[0020] Furthermore, in the above method for accelerating interconnect bus network communication, dividing a plurality of pages into unused blocks according to block size includes:
[0021] Divide pages larger than 8 bytes and smaller than 1520 bytes into small blocks;
[0022] Divide pages larger than 1520 bytes and smaller than 65507 bytes into large chunks.
[0023] Furthermore, in the above method for accelerating interconnect bus network communication, the starting address of the segment applied for this time is determined according to the total size of the thread management area and the segment management area and the segment ID, which is determined by the following formula:
[0024] The total size of the thread management area and the segment management area + segment ID * the size of each segment.
[0025] A second aspect of the present invention further provides a method for accelerating interconnect bus network communication, which is applied to semantically aware memory page migration, comprising:
[0026] The sendmsg function is intercepted for the first time to copy the data in DRAM to the first shared memory block;
[0027] Apply for a second shared memory block of the same size as the first shared memory block from the shared memory, and modify the corresponding physical address in the page table of the original memory block to the physical address of the second shared memory block;
[0028] Add the virtual address and physical address of the original memory block to the pre-applied linked list header, and set the status of the original memory block information in the linked list to used;
[0029] Add the physical address and virtual address of the second shared memory block to the linked list, and set the state of the second shared memory block to be used;
[0030] Intercept the sendmsg function again, obtain the second shared memory block in the state of being used from the linked list, modify the page table of the second shared memory block to ROW, and register the address of the second shared memory block to the userfaultd function to monitor the copy-on-write event;
[0031] The receiver receives the data after obtaining the address of the second shared memory block. After reading the data, the ROW of the page table of the second shared memory block is removed, and the state is changed to be ready for use.
[0032] Furthermore, the above method for accelerating interconnect bus network communication further includes:
[0033] If the receiver has not read the data in the shared memory, the application writes data to the original shared memory block again, triggering the copy-on-write situation and entering the userfaultfd event processing function, re-applying for the third shared memory block from the shared memory, and changing the corresponding physical address in the page table of the original memory block to the physical address of the third shared memory block;
[0034] The physical address and the virtual address of the third shared memory block are added to the linked list, the state of the third shared memory block is set to be used, and the state of the second shared memory block in the linked list is set from used to deletable.
[0035] Furthermore, the above method for accelerating interconnect bus network communication further includes:
[0036] If the original memory block is released in the application, check from the linked list whether the shared memory block corresponding to the virtual address of the original memory block is in the used / deletable state;
[0037] If there is no used / deletable state, all memory blocks can be released, the corresponding physical address in the original memory block page table is modified to the original physical address, the linked list of the original memory block is cleaned up, and the free function in the original libc is called to release the original memory block;
[0038] If there is a used / deletable status, the status of the original memory block is changed to deleted, the corresponding physical address in the original memory block page table is changed to the original physical address, the linked list of the original memory block is cleaned up, and the free function in the original libc is called to release the original memory block. When the receiver reads the data, it is found that the shared memory block status corresponding to the virtual address of the original memory block is deleted. At the same time, after determining that there is no used / deletable memory block on the linked list, the original memory block and the shared memory block information on the linked list are cleaned up.
[0039] According to a third aspect of the present invention, an electronic device is provided, comprising: a processor and a memory;
[0040] The processor is used to execute a method for accelerating interconnect bus network communication as described in any of the above items by calling the program or instruction stored in the memory.
[0041] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a program or instruction, wherein the program or instruction enables a computer to execute a method for accelerating interconnect bus network communication as described in any one of the above items.
[0042] The beneficial effects of the present invention are as follows: the distributed memory management method in the present invention not only solves the competition problem when multiple processes / multiple machines apply for memory from the shared memory at the same time, but also solves the problem that the virtual addresses are not universal when reading and writing the same memory block between each other. It is very suitable for managing the shared memory of the Internet, and effectively improves the efficiency of network transmission using the Internet; and the semantically aware memory page migration method modifies the page table of the virtual address of the large memory that is used multiple times, so that when the program writes data to the virtual address, it can be directly written to the interconnect bus memory, thus omitting the process of copying data from the local DRAM to the interconnect bus memory, thereby reducing one copy process, achieving zero copy, and significantly improving the efficiency of data transmission during interconnect bus communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings are only used to illustrate specific embodiments and are not considered to limit the present invention. In the entire drawings, the same reference symbols represent the same components. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings.
[0044] Figure 1 A method for accelerating interconnect bus network communication provided by an embodiment of the present invention Figure 1 ;
[0045] Figure 2 A method for accelerating interconnect bus network communication provided by an embodiment of the present invention Figure 2 ;
[0046] Figure 3 A method for accelerating interconnect bus network communication provided by an embodiment of the present invention Figure 3 ;
[0047] Figure 4 A schematic diagram of a structure for accelerating interconnect bus network communication provided by an embodiment of the present invention;
[0048] Figure 5 A method for accelerating interconnect bus network communication provided by an embodiment of the present invention Figure 4 ;
[0049] Figure 6 A schematic block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work should fall within the scope of protection of the present invention.
[0051] Furthermore, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts disclosed in the present invention.
[0052] In the description of the present invention, the terms "first", "second", and "third" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be internal communication between two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0053] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of methods and systems consistent with some aspects of the present invention as detailed in the appended claims.
[0054] Before introducing the embodiments of the present invention, the professional terms involved in the present invention are first introduced.
[0055] CAS (compare and swap) compares and exchanges, which is generally used to assign the set value to the memory only when the value in the specified memory is equal to the expected value, and is used as a lock-free resource competition method.
[0056] Compute Express Link (CXL) is an industry-supported cache-coherent interconnect technology standard protocol that is an open industrial standard between processors and devices such as accelerators, memory buffers, intelligent network interfaces, persistent memory, and solid-state drives.
[0057] DRAM (dynamic random access memory) is a random access memory that uses dynamic storage units.
[0058] The present invention proposes a method, device, electronic device and distributed memory management method in a storage medium for accelerating interconnect bus network communication, which not only solves the competition problem when multiple processes / multiple machines apply for memory from shared memory at the same time, but also solves the problem that virtual addresses are not universal when reading and writing the same memory block between each other. It is very suitable for managing shared memory of the Internet and effectively improves the efficiency of network transmission using the Internet. The semantically-aware memory page migration method can achieve zero copy of data when transmitting large data, which significantly improves the efficiency of transmitting large data during interconnect bus communication.
[0059] Method Embodiment
[0060] Figure 1 A method for accelerating interconnect bus network communication provided by an embodiment of the present invention Figure 1 .
[0061] In the first aspect of the present invention, a method for accelerating interconnect bus network communication is proposed, which is applied to distributed shared memory management, combined with Figure 1 , including five steps from S1 to S5:
[0062] S1: Map the shared memory to each thread and divide the shared memory into a thread management area and a segment management area.
[0063] Specifically, in the embodiment of the present invention, the shared memory here is an area that all nodes must access. The shared memory is divided into areas with different functions to obtain a thread management area and a segment management area, so that each thread can have its own exclusive memory. This can reduce the concurrency problem of each thread when applying for memory, and therefore the use of locks can be eliminated.
[0064] S2: Each thread seizes the TLS structure area of each thread in the thread management area, and records the mapping head address of the shared memory in each thread into the TLS structure area.
[0065] Specifically, in an embodiment of the present invention, when each thread allocates a memory block of a certain size in the shared memory for the first time, it is necessary to preempt the TLS structure area of each thread in the thread memory management area. The preemption method is described in detail below. After preempting the TLS structure area of each thread, it is necessary to record the mapping first address of the shared memory in the current thread into the TLS structure area for subsequent use.
[0066] S3: Each thread applies for a memory block in the segment management area, and determines whether the memory block of the first thread needs to be used by other threads except the first thread.
[0067] Specifically, in the embodiment of the present invention, when applying for a memory block, each thread only applies in batches from the system for the first time. After applying for the memory block, when determining whether the memory block needs to be used by other threads, the first thread here is any thread among the threads.
[0068] S4: If the judgment result is that the memory block of the first thread needs to be used by other threads except the first thread, the difference between the memory block of the first thread and the first address of the shared memory is sent to the other threads except the first thread.
[0069] Specifically, in an embodiment of the present invention, if the judgment result is whether this memory block needs to be used by other threads, what is transmitted is the difference between this memory block and the first address of the shared memory, so that other threads obtain the difference between this memory block and the first address of the shared memory.
[0070] S5: After receiving the difference between the memory block of the first thread and the first address of the shared memory, the other threads except the first thread determine the virtual address of the memory block used in each thread according to the difference and the mapping first address of each thread.
[0071] Specifically, in the embodiment of the present invention, after the thread obtains the difference between the memory block and the first address of the shared memory, it adds the first address virtual address recorded in its own TLS to obtain the virtual address of the block in the shared memory that can be used in the current thread.
[0072] It should be understood that distributed memory management requires access to the same shared memory across different processes or even across multiple hosts. Therefore, virtual addresses cannot be used alone to manage memory. Instead, the difference between the memory block of the first thread and the first address of the shared memory needs to be used. After each thread seizes the TLS structure area of the current thread from the thread memory management area, the mapping first address of the interconnect bus shared memory in the current thread needs to be recorded in TLS. After applying for the memory block, if this memory block needs to be used by other threads, the difference between this memory block and the first address of the shared memory is passed. In this way, other threads obtain the difference and add the first address virtual address recorded in their own TLS to obtain the virtual address of this block in the shared memory that can be used in the current thread.
[0073] Furthermore, in the above method for accelerating interconnect bus network communication, each thread preempts the TLS structure area of each thread in the thread management area, including:
[0074] In the thread memory management area, by jumping the TLS structure size in sequence, the thread ID is preempted to fill in the specific position in the TLS structure in the CAS manner, marking the TLS structure area of each thread that is preempted;
[0075] Among them, the TLS structure area is used to store some memory allocation information of each thread.
[0076] Figure 2 A method for accelerating interconnect bus network communication provided by an embodiment of the present invention Figure 2 .
[0077] Furthermore, in the above method for accelerating interconnect bus network communication, each thread applies for a memory block in the segment management area, and the method also includes four steps S21 to S24:
[0078] S21: Seize a byte in the segment management area and determine the segment ID according to the position of the byte in the segment management area.
[0079] S22: Determine the starting address of the segment requested this time according to the total size of the thread management area and the segment management area and the segment ID.
[0080] S23: Divide the requested segment into multiple pages.
[0081] S24: Divide the plurality of pages into unused blocks according to the block size and provide them.
[0082] Specifically, the starting address of the segment applied for this time is obtained, and this segment is privately used by this thread. The applied segment is divided into pages one by one, and the available pages in the segment private to this thread are divided into unused blocks according to the block size for provision. Through steps S23 to S24, each thread can manage the memory separately within the thread by using page-block division.
[0083] Furthermore, in the above method for accelerating interconnect bus network communication, dividing a plurality of pages into unused blocks according to block size includes:
[0084] Divide pages larger than 8 bytes and smaller than 1520 bytes into smaller blocks.
[0085] Divide pages larger than 1520 bytes and smaller than 65507 bytes into large chunks.
[0086] Specifically, in the embodiment of the present invention, the block size starts from 8 bytes, followed by 16 bytes, and then increases by 16 bytes to 1520 bytes. Because 8 bytes need to be allocated when the memory block address needs to be stored, starting from 8 bytes, considering the problem of socket transmission fragmentation, the memory requested for sending the message will not be too large. Due to the electrical limitations of Ethernet transmission, the maximum transmission cannot exceed 1518 bytes, so 1520 bytes are selected as the maximum value of the small block. Blocks exceeding 1520 bytes are called large blocks, which increase by 1k in sequence according to 2k, 3k, etc. until 64k. The page size also needs to be selected as 64k and multiples of 64k. The reason why the large block is selected as 64k is that the theoretical maximum length of the UDP data packet is 2^16-1-8-20=65507 bytes, so these memory block sizes are commonly used in network communications. If there is a subsequent demand to expand the transmission size, it can also be changed accordingly according to different needs.
[0087] Furthermore, in the above method for accelerating interconnect bus network communication, the starting address of the segment applied for this time is determined according to the total size of the thread management area and the segment management area and the segment ID, which is determined by the following formula:
[0088] The total size of the thread management area and the segment management area + segment ID * the size of each segment.
[0089] The above article introduces the distributed memory management method, and the following article introduces the semantic-aware memory page migration method.
[0090] Figure 3 A method for accelerating interconnect bus network communication provided by an embodiment of the present invention Figure 3 .
[0091] Figure 4 A schematic diagram of a structure for accelerating network communication provided by an embodiment of the present invention.
[0092] In a second aspect of the present invention, a method for accelerating interconnect bus network communication is also proposed, which is applied to semantically aware memory page migration, combined with Figure 3 , including five steps from S31 to S35:
[0093] S31: intercepting the sendmsg function for the first time to copy the data in the DRAM to the first shared memory block.
[0094] Specifically, in the embodiment of the present invention, combined with Figure 4 , intercept the sendmsg function as shown in circle 1 in the figure, and copy the data in DRAM to the first shared memory block A.
[0095] S32: applying for a second shared memory block of the same size as the first shared memory block from the shared memory, and modifying the corresponding physical address in the original memory block page table to the physical address of the second shared memory block.
[0096] Specifically, in the embodiment of the present invention, combined with Figure 4 As shown in circle 2 in the figure, a second shared memory block B with the same size as the first shared memory block A is applied from the shared memory, and the page table of the original memory block Buffer1 is modified to the physical address of the newly applied second shared memory block B.
[0097] S33: Add the virtual address and physical address of the original memory block to the pre-applied linked list header, and set the status of the original memory block information in the linked list to used.
[0098] Specifically, in the embodiment of the present invention, combined with Figure 4 , as shown in circle 3 in the figure, the virtual address and physical address of the original memory block Buffer1 are added to the linked list header that this thread initially applies for from the shared memory, and the status of the original memory block Buffer1 information in the linked list is set to used.
[0099] S34: Add the physical address and the virtual address of the second shared memory block to the linked list, and set the state of the second shared memory block to be used.
[0100] Specifically, in the embodiment of the present invention, combined with Figure 4 , as shown in circle 4 in the figure, the physical address and virtual address of the second shared memory block B are added to the linked list, and the state of the second shared memory block B is set to be used. It should be understood that when the program returns to the application and copies the data to the original memory block Buffer1 again, the data will be written directly to the second shared memory block B because the page table has been modified.
[0101] S35: intercept the sendmsg function again, obtain the second shared memory block in the ready-to-use state from the linked list, modify the page table of the second shared memory block to ROW, and register the address of the second shared memory block to the userfaultd function to monitor the copy-on-write event.
[0102] Specifically, in the embodiment of the present invention, the program intercepts the sendmsg function again, obtains the second shared memory block B in the to-be-used state from the linked list, modifies its page table to ROW, and registers this address in userfaultd to monitor the copy-on-write event.
[0103] S36: After the receiver obtains the address of the second shared memory block, it receives the data. After reading the data, it removes the ROW of the page table of the second shared memory block and changes the state to ready for use.
[0104] Specifically, in the embodiment of the present invention, the receiver receives data after obtaining the address of the second shared memory block B. After reading the data, the ROW flag of the page table of the second shared memory block is removed and the state is changed to ready for use so that the next round of data writing can be performed.
[0105] Figure 5 A method for accelerating interconnect bus network communication provided by an embodiment of the present invention Figure 4 .
[0106] Furthermore, the above method for accelerating interconnect bus network communication is combined with Figure 5 , and also includes two steps S51 to S52:
[0107] S51: If the receiver has not read the data in the shared memory, the application writes data to the original shared memory block again, triggering the write-time copy situation to enter the event processing function of userfaultfd, re-apply for the third shared memory block from the shared memory, and change the corresponding physical address in the page table of the original memory block to the physical address of the third shared memory block.
[0108] Specifically, in the embodiment of the present invention, combined with Figure 4 As shown in circle 5 in the figure, when the receiver has not read the data in the shared memory, the application writes data to the original shared memory block Buffer1 again, triggering the copy-on-write situation to enter the event processing function of userfaultfd, and re-apply for the third shared memory block C from the shared memory, and modify the corresponding physical address in the page table of the original memory block buffer1 to the physical address of the third shared memory block C.
[0109] S52: adding the physical address and the virtual address of the third shared memory block to the linked list, setting the status of the third shared memory block to be used, and setting the status of the second shared memory block in the linked list from used to deletable.
[0110] Specifically, in the embodiment of the present invention, combined with Figure 4 As shown in circle 6 in the figure, the physical address and virtual address of the third shared memory block C are added to the linked list, the status of the third shared memory block C is set to be used, and the status of the second shared memory block B in the linked list is set from used to deletable. Then, the next time when the application is returned to write data to the original memory block Buffer1, the data will actually be written directly to the third shared memory block C. After reading the data, the receiver finds that the status of the second shared memory block B is deletable, so the memory of the second shared memory block B is released.
[0111] Furthermore, the above method for accelerating interconnect bus network communication further includes:
[0112] If the original memory block is released in the application, check from the linked list whether the shared memory block corresponding to the virtual address of the original memory block is in the used / deletable state;
[0113] If there is no used / deletable state, all memory blocks can be released, the corresponding physical address in the original memory block page table is modified to the original physical address, the linked list of the original memory block is cleaned up, and the free function in the original libc is called to release the original memory block;
[0114] If there is a used / deletable status, the status of the original memory block is changed to deleted, the corresponding physical address in the original memory block page table is changed to the original physical address, the linked list of the original memory block is cleaned up, and the free function in the original libc is called to release the original memory block. When the receiver reads the data, it is found that the shared memory block status corresponding to the virtual address of the original memory block is deleted. At the same time, after determining that there is no used / deletable memory block on the linked list, the original memory block and the shared memory block information on the linked list are cleaned up.
[0115] Specifically, in the embodiment of the present invention, the free function needs to be intercepted and modified to: if the original memory block Buffer1 is released in the application, the shared memory block corresponding to the virtual address of the original memory block is searched from the linked list to see if it is in the used / deletable state; if it is not in the used / deletable state, it proves that the receiver has taken away all the data, and all the memory blocks can be released; the page table of the original memory block Buffer1 is modified to the original physical address, the linked list of the original memory block Buffer1 is cleaned up, and then the free function in the original libc is called to release the original memory block. If it is in the used / deletable state, the corresponding physical address in the page table of the original memory block Buffer1 is modified to the original physical address, and the free function in the original libc is called to release the original memory block; after the receiver reads the data, it is found that the shared memory block corresponding to the virtual address of the original memory block Buffer1 is in the deleted state; at the same time, after judging that there is no used / deletable memory block on the linked list, the original memory block Buffer1 and the shared memory block information on the linked list are cleaned up.
[0116] According to a third aspect of the present invention, an electronic device is provided, comprising: a processor and a memory;
[0117] The processor is used to execute any one of the methods for accelerating interconnect bus network communication as described above by calling the program or instruction stored in the memory.
[0118] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a program or instruction, wherein the program or instruction enables a computer to execute any of the methods for accelerating interconnect bus network communication as described above.
[0119] Figure 6 It is a schematic block diagram of an electronic device provided by an embodiment of the present invention.
[0120] like Figure 6 As shown, the electronic device includes: at least one processor 601, at least one memory 602 and at least one communication interface 603. The various components in the electronic device are coupled together through a bus system 604. The communication interface 603 is used to transmit information between external devices. It can be understood that the bus system 604 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 604 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 6 Various buses are labeled as bus system 604 .
[0121] It can be understood that the memory 602 in this embodiment can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories.
[0122] In some implementations, the memory 602 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system and application programs.
[0123] The operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. A program that implements any method of the method for accelerating interconnect bus network communication provided in an embodiment of the present invention can be included in the application.
[0124] In an embodiment of the present invention, the processor 601 calls a program or instruction stored in the memory 602, specifically, a program or instruction stored in an application, and the processor 601 is used to execute the steps of each embodiment of a method for accelerating interconnected bus network communication provided in an embodiment of the present invention.
[0125] Map the shared memory to each thread and divide the shared memory into a thread management area and a segment management area;
[0126] Each thread seizes the TLS structure area of each thread in the thread management area, and records the mapping head address of the shared memory in each thread into the TLS structure area;
[0127] Each thread applies for a memory block in the segment management area, and determines whether the memory block of the first thread needs to be used by other threads except the first thread;
[0128] If the judgment result is that the memory block of the first thread needs to be used by other threads except the first thread, the difference between the memory block of the first thread and the first address of the shared memory is sent to the other threads except the first thread;
[0129] After receiving the difference between the memory block of a thread and the first address of the shared memory, the other threads except the first thread determine the virtual address of the memory block used in each thread according to the difference and the mapping first address of each thread.
[0130] Any method in a method for accelerating interconnected bus network communication provided in an embodiment of the present invention can be applied to the processor 601, or implemented by the processor 601. The processor 601 can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 601 or an instruction in the form of software. The above-mentioned processor 601 can be a general-purpose processor, a digital signal processor (DigitalSignal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0131] The steps of any method in the method for accelerating interconnect bus network communication provided by the embodiment of the present invention can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software units in the decoding processor. The software unit can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 602, and the processor 601 reads the information in the memory 602 and completes the steps of the method in combination with its hardware.
[0132] Those skilled in the art will appreciate that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features from different embodiments is meant to be within the scope of the present invention and to form different embodiments.
[0133] Those skilled in the art will appreciate that the description of each embodiment has its own emphasis, and for parts not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0134] Although the embodiments of the present invention are described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations all fall within the scope defined by the appended claims. The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
[0135] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for accelerating interconnect bus network communication, It is characterized in that Applied to distributed shared memory management, including: Map the shared memory to each thread and divide the shared memory into a thread management area and a segment management area; Each thread seizes the TLS structure area of each thread in the thread management area, and records the mapping head address of the shared memory in each thread into the TLS structure area; Each thread applies for a memory block in the segment management area, and determines whether the memory block of the first thread needs to be used by other threads except the first thread; If the judgment result is that the memory block of the first thread needs to be used by other threads except the first thread, the difference between the memory block of the first thread and the first address of the shared memory is sent to the other threads except the first thread; After receiving the difference between the memory block of the first thread and the shared memory first address, the other threads except the first thread determine the virtual address of the memory block used in each thread according to the difference and the mapping first address of each thread.
2. A method for accelerating interconnect bus network communication according to claim 1, It is characterized in that Each thread seizes the TLS structure area of each thread in the thread management area, including: In the thread memory management area, by jumping the TLS structure size in sequence, the thread ID is preempted to fill in the specific position in the TLS structure in the CAS manner, marking the TLS structure area of each thread that is preempted; The TLS structure area is used to store some memory allocation information of each thread.
3. A method for accelerating interconnect bus network communication according to claim 1, It is characterized in that Each thread applies for a memory block in the segment management area, which also includes: Grab a byte in the segment management area and determine the segment ID based on the position of the byte in the segment management area; Determine the starting address of the segment to be applied for this time based on the total size of the thread management area and the segment management area and the segment ID; Divide the requested segment into multiple pages; Multiple pages are provided by dividing them into unused blocks according to the block size.
4. A method for accelerating interconnect bus network communication according to claim 3, It is characterized in that Divide multiple pages into unused blocks according to the block size, including: Divide pages larger than 8 bytes and smaller than 1520 bytes into small blocks; Divide pages larger than 1520 bytes and smaller than 65507 bytes into large chunks.
5. A method for accelerating interconnect bus network communication according to claim 3, It is characterized in that The starting address of the segment applied for this time is determined according to the total size of the thread management area and the segment management area and the segment ID, and is determined by the following formula: The total size of the thread management area and the segment management area + segment ID * the size of each segment.
6. A method for accelerating interconnect bus network communication, It is characterized in that Applied to semantically aware memory page migration, including: The sendmsg function is intercepted for the first time to copy the data in DRAM to the first shared memory block; Apply for a second shared memory block of the same size as the first shared memory block from the shared memory, and modify the corresponding physical address in the page table of the original memory block to the physical address of the second shared memory block; Add the virtual address and physical address of the original memory block to the pre-applied linked list header, and set the status of the original memory block information in the linked list to used; Add the physical address and virtual address of the second shared memory block to the linked list, and set the state of the second shared memory block to be used; Intercept the sendmsg function again, obtain the second shared memory block in the state of being used from the linked list, modify the page table of the second shared memory block to ROW, and register the address of the second shared memory block to the userfaultd function to monitor the copy-on-write event; The receiver receives the data after obtaining the address of the second shared memory block. After reading the data, the ROW of the page table of the second shared memory block is removed, and the state is changed to be ready for use.
7. A method for accelerating interconnect bus network communication according to claim 6, It is characterized in that The method further comprises: If the receiver has not read the data in the shared memory, the application writes data to the original shared memory block again, triggering the copy-on-write situation and entering the userfaultfd event processing function, re-applying for the third shared memory block from the shared memory, and changing the corresponding physical address in the page table of the original memory block to the physical address of the third shared memory block; The physical address and the virtual address of the third shared memory block are added to the linked list, the state of the third shared memory block is set to be used, and the state of the second shared memory block in the linked list is set from used to deletable.
8. A method for accelerating interconnect bus network communication according to claim 6, It is characterized in that The method further comprises: If the original memory block is released in the application, check from the linked list whether the shared memory block corresponding to the virtual address of the original memory block is in the used / deletable state; If there is no used / deletable state, all memory blocks can be released, the corresponding physical address in the original memory block page table is modified to the original physical address, the linked list of the original memory block is cleaned up, and the free function in the original libc is called to release the original memory block; If there is a used / deletable status, the status of the original memory block is changed to deleted, the corresponding physical address in the original memory block page table is changed to the original physical address, the linked list of the original memory block is cleaned up, and the free function in the original libc is called to release the original memory block. When the receiver reads the data, it is found that the shared memory block status corresponding to the virtual address of the original memory block is deleted. At the same time, after determining that there is no used / deletable memory block on the linked list, the original memory block and the shared memory block information on the linked list are cleaned up.
9. An electronic device, It is characterized in that include: Processor and memory; The processor is used to execute the method for accelerating interconnect bus network communication as described in any one of claims 1 to 8 by calling the program or instruction stored in the memory.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a program or instruction, and the program or instruction enables a computer to execute a method for accelerating interconnect bus network communication as claimed in any one of claims 1 to 8.
