Disclosure of Invention
In view of this, the embodiment of the invention provides a method and a device for managing a queue page table based on remote direct memory access, so as to eliminate or improve one or more defects existing in the prior art, and solve the problem of high page table access overhead in the existing remote direct memory access queue access process.
In one aspect, the present invention provides a method for managing a queue page table based on remote direct memory access, where the method is executed on a remote direct memory access network card, and includes the following steps:
The remote direct memory access user mode driver allocates a queue buffer in a user mode and creates a queue; the remote direct memory access user mode driver initiates a registration request of the queue to a kernel mode driver based on a preset function;
The remote direct memory access kernel mode driver acquires a physical page linked list allocated to the queue from an operating system kernel, and allocates a section of memory as a queue page table for the queue;
The remote direct memory access kernel mode driver traverses each item in the physical page list and writes each item of information into the queue page list in turn;
and the remote direct memory access kernel mode driver writes the base address of the queue page table into a queue register, writes the pointer of the queue page table into the queue register, and sets an initial value.
In some embodiments of the present invention, the method for managing a queue page table based on remote direct memory access further includes:
the remote direct memory access kernel mode driver allocates a continuous and physically page-aligned memory as a queue page table for the queue.
In some embodiments of the present invention, the remote direct memory access kernel mode driver traverses each item in the physical page table and writes each item of information into the queue page table in turn, further comprising:
each item of the queue page table is 8 bytes, the lower 12 bits are the number of physical pages mapped by the item, and the upper 52 bits are the upper 52 bits of the initial physical page address corresponding to the item;
If the item mapping of the physical page linked list exceeds 4096 physical pages, splitting the physical page linked list into a plurality of queue page table items for storage.
In some embodiments of the present invention, the method for managing a queue page table based on remote direct memory access further includes:
The remote direct memory access kernel mode driver writes the base address of the queue page table and the queue page table pointer to the queue register based on PCIe protocol standards.
In some embodiments of the present invention, the remote direct memory access kernel mode driver writes a base address of the queue page table to a queue register, writes a queue page table pointer to the queue register, and sets an initial value, the method further comprises:
The remote direct memory access kernel mode driver returns queue creation completion information to the remote direct memory access user mode driver;
and the remote direct memory access user mode driver receives the queue creation completion information, and the queue creation process is ended.
In some embodiments of the invention, after completion of the queue creation, the method further comprises:
The remote direct memory access kernel mode driver judges the number of the queue page table entries;
If the number of the first item and the second item of the queue page table is greater than or equal to two items, writing the first item and the second item of the queue page table into a first cache item and a second cache item of the queue register in sequence, and modifying initial values of the first cache item and the second cache item;
And the remote direct memory access kernel mode driver sets the initial value of the buffer entry pointer of the queue register.
In some embodiments of the present invention, when the current cache entry pointer points to the first cache entry and the queue page table entry is greater than or equal to two entries, the remote direct memory access network card accesses the queue, the method further includes:
the remote direct memory access network card initiates a direct memory access read queue basic block based on the physical address of the first cache entry;
The method comprises the steps of judging the remaining length of a physical page mapped by a first cache item, if the remaining length is a queue basic block, initiating a queue page table item prefetching request by a remote direct memory access network card, checking the valid bit of a second cache item, if the valid bit is valid, pointing a current cache item pointer to the second cache item, and initializing the remaining length.
In some embodiments of the present invention, if the remaining length is a queue basic block, the remote direct memory access network card initiates a queue page table entry prefetch request, and further includes:
Initiating the queue page table entry prefetch request based on the current cache entry pointer to read a next page table entry;
and returning a prefetched page table entry obtained based on the queue page table entry prefetching request, and replacing the consumed page table entry with the prefetched page table entry.
In another aspect, the present invention provides a queue page table management device based on remote direct memory access, where the device is applied to a remote direct memory access network card, and the device includes:
the queue access module is used for realizing the reading and writing functions of each queue;
The queue information storage module is used for storing a base address of a queue page table, a pointer of the queue page table, a valid bit value of a first cache item, a valid bit value of a second cache item and a pointer of the cache item;
And the page table entry cache maintenance module is used for receiving and executing the queue page table entry prefetching request initiated by the queue access module.
In another aspect, the invention also provides a computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of a method as described in any one of the above-mentioned.
The invention has the advantages that:
The invention provides a queue page table management method and device based on remote direct memory access, wherein the remote direct memory access user state driver distributes a queue buffer area in a user state and creates a queue, the remote direct memory access user state driver initiates a registration request of the queue to a kernel state based on a preset function, the remote direct memory access kernel state driver acquires a physical page linked list distributed to the queue from an operating system kernel and distributes memory as a queue page table for the queue, the remote direct memory access kernel state driver traverses each item in the physical page linked list and sequentially writes information of each item into the queue page table, and the remote direct memory access kernel state driver writes a base address of the queue page table into a queue register, writes a pointer of the queue page table into the queue register and sets an initial value. The method provided by the invention can efficiently and conveniently store and manage the queue page table, and greatly reduce the access delay and the storage overhead of the remote direct memory access queue page table.
Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objectives and other advantages of the invention may be realized and attained by the structure particularly pointed out in the written description and drawings.
It will be appreciated by those skilled in the art that the objects and advantages that can be achieved with the present invention are not limited to the above-described specific ones, and that the above and other objects that can be achieved with the present invention will be more clearly understood from the following detailed description.
Detailed Description
The present invention will be described in further detail with reference to the following embodiments and the accompanying drawings, in order to make the objects, technical solutions and advantages of the present invention more apparent. The exemplary embodiments of the present invention and the descriptions thereof are used herein to explain the present invention, but are not intended to limit the invention.
It should be noted here that, in order to avoid obscuring the present invention due to unnecessary details, only structures and/or processing steps closely related to the solution according to the present invention are shown in the drawings, while other details not greatly related to the present invention are omitted.
It should be emphasized that the term "comprises/comprising" when used herein is taken to specify the presence of stated features, elements, steps or components, but does not preclude the presence or addition of one or more other features, elements, steps or components.
It is also noted herein that the term "coupled" may refer to not only a direct connection, but also an indirect connection in which an intermediate is present, unless otherwise specified.
Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
It should be emphasized that the references to steps below are not intended to limit the order of the steps, but rather should be understood to mean that the steps may be performed in a different order than in the embodiments, or that several steps may be performed simultaneously.
In order to solve the problem of high page table access overhead in the existing remote direct memory access queue access process, the invention provides a queue page table management method based on remote direct memory access, which is executed on a remote direct memory access RDMA network card, as shown in fig. 2, and comprises the following steps S101-S104:
step S101, a remote direct memory access user mode driver distributes a queue buffer area in a user mode and creates a queue, and the remote direct memory access user mode driver initiates a registration request of the queue to a kernel mode driver based on a preset function.
Step S102, the remote direct memory access kernel mode driver acquires a physical page list allocated to the queue from the operating system kernel, and allocates a section of memory as a queue page table for the queue.
Step S103, the remote direct memory access kernel mode drive traverses each item in the physical page list and writes each item of information into the queue page list in turn.
Step S104, the remote direct memory access kernel mode driver writes the base address of the queue page table into the queue register, writes the pointer of the queue page table into the queue register, and sets an initial value.
In step S101, the remote direct memory access user mode driver allocates a memory space in a user mode as a queue buffer for storing queue data, control information, etc., and creates a queue, and may specify a size and other related parameters of the queue when creating the queue.
The remote direct memory access user mode driver calls a preset function provided by the remote direct memory access kernel mode driver, and initiates a queue registration request to the kernel mode driver. The kernel mode driver allocates resources to the queue and initializes the queue according to the parameters passed by the user mode driver.
In step S102, the remote direct memory access kernel mode driver obtains the physical page link list SCATTER LIST of the queue through an interface provided by the operating system kernel. The physical page linked list includes information of all physical pages related to the queue, and illustratively includes information of a start address, a size, access rights and the like of the physical pages, and other related information of a memory area, a node and the like of the physical pages.
The remote direct memory access kernel mode driver allocates a section of memory as a queue page table for the queue. Wherein the queue page table is an array, and each element (i.e., the queue page table entry) corresponds to address mapping information of a physical page.
In some embodiments, the remote direct memory access kernel mode driver allocates a continuous and physically page-aligned segment of memory for the queue as a queue page table.
In step S103, the remote direct memory access kernel mode driver traverses each item in the physical page table in turn, and writes the corresponding physical page address mapping information into the queue page table in turn.
In some embodiments, each entry of the queue page table, i.e., each queue page table entry, contains 8 bytes, with the lower 12 bits being the number of physical pages mapped by this entry and the upper 52 bits being the upper 52 bits of the initial physical page address corresponding to this entry.
In some embodiments, if the current physical page table entry maps over 4096 physical pages, then it may be necessary to split into multiple queue page table entries for storage.
In step S104, the remote direct memory access kernel mode driver writes the base address of the queue page table into a queue register for storing the queue information related to the remote direct memory access network card, writes the queue page table pointer into the queue register for storing the queue information related to the remote direct memory access network card, and sets an initial value of the queue page table pointer, and exemplarily, sets the initial value to 0.
In some embodiments, the remote direct memory access kernel mode driver writes the base address of the queue page table and the queue page table pointer to the queue register based on PCIe protocol standards.
In some embodiments, after step S104, the following steps are further included:
after the queue creating process is completed, the remote direct memory access kernel mode driver returns control rights to the remote direct memory access user mode driver, and returns queue creating completion information to the remote direct memory access user mode driver.
After receiving the queue creation completion information returned by the kernel mode driver, the remote direct memory access user mode driver creates a process result of the queue. At this time, the application program can access the queue to perform operations such as data transmission through the interface provided by the remote direct memory access user mode driver.
Based on the above description, compared with the prior art, the method provided by the invention can map a continuous physical page by using a queue page table item, and for convenience of understanding and embodying the technical effects, the following is exemplified and compared:
the existing remote direct memory access queue page table storage mechanism adopts a mapping mechanism taking pages as units, so that the remote direct memory access network card is ensured to inquire corresponding page table items within constant time complexity.
For example, defining that the BASE address of the remote direct memory access queue in the process virtual address space is va_base, the BASE block virtual address of the remote direct memory access queue to be accessed currently is va_current, the 4KB PAGE offset page_shift is 12, > > represents a logical right SHIFT operation, and then the corresponding queue PAGE table entry index pt_idx= (va_current > > page_shift) -va_base > > page_shift may be directly located to the corresponding queue PAGE table entry according to pt_idx for the mapping manner shown in fig. 1.
However, when the operating system allocates the storage space of the remote direct memory access queue, there are cases where a plurality of physical pages are consecutive, as shown in fig. 3, 6 virtual pages correspond to three consecutive physical page blocks, the first block includes 1 physical page, the second block includes 2 physical pages, and the third block includes 3 physical pages. For the queue memory distribution situation shown in fig. 3, using the existing conventional queue page table storage mechanism, 6 queue page table entry storage spaces are required to be consumed, and in the running process, the remote direct memory access network card needs 6 PCIe DMA read queue page table entries to completely access the queue once.
If one queue page table entry is used to map a continuous physical page, as shown in fig. 3, the queue page table entry_0 maps 1 physical page, the queue page table entry_1 maps 2 physical pages, and the queue page table_2 maps 3 physical pages. Even if the queue page table management mode provided by the invention is used, only 3 queue page table entry storage spaces are consumed for storing the queue page table information shown in fig. 3, and only 3 PCIe DMA read queue page table entries are required for the remote direct memory access network card to completely access the queue once.
Meanwhile, considering that the queue page table management mechanism provided by the invention cannot directly use the queue basic block VA to determine PT_IDX, in the invention, for each queue, a page table item read pointer is maintained to point to the next queue page table item to be read, and the initial value is 0, because the remote direct memory access network card accesses the queue strictly according to the sequence, after each time the queue page table is accessed by using the page table item read pointer, the queue page table item read pointer is incremented to be used as the next queue page table item pointer to be accessed.
In some embodiments, the invention further provides a table tennis table entry caching and prefetching mechanism based on the queue creation management method of the steps S101-S104. Among them, ping-Pong Operation (Ping-Pong Operation) is a common technique used in computer systems to reduce the need for main memory access and improve the efficiency of data transmission.
Two queue page table cache entries are maintained in the queue information, namely a first cache entry (denoted as cache entry 0) and a second cache entry (denoted as cache entry 1), whether the cache entry is Valid or not is recorded by using two Valid bits (Valid 0 and Valid 1), and a currently used cache entry identifier is recorded by using a current cache entry pointer (0/1), as shown in fig. 4, specifically:
After creating the queue page table based on steps S101 to S104, the remote direct memory access kernel mode driver judges the number of the queue page table entries, if the number is greater than or equal to two, the first entry and the second entry of the queue page table are sequentially written into the first cache entry and the second cache entry of the queue register, and initial values of the first cache entry and the second cache entry are modified, namely, the first entry of the queue page table is written into the cache entry 0, the second entry of the queue page table is written into the cache entry 1, and Valid0 and Valid1 are initialized to 1, and if the number is less than two, the entry (the only one entry) is written into the first cache entry, and the initial values of the first cache entry are modified, namely, the entry is written into the cache entry 0, and Valid0 is initialized to 1.
The remote direct memory access kernel mode driver initializes the cache entry pointer of the queue register to 0.
In some embodiments, the remote direct memory access kernel mode drivers all write information over PCIe.
Considering that the remote direct memory access network card accesses the queue strictly in sequence, when the remote direct memory access network card accesses the queue for the first time, the first cache entry is directly used without reading the page table entry of the queue through PCIe DMA.
In some embodiments, the present invention proposes to maintain a variable, the remaining length, in the queue information. The surplus length is used for recording the surplus length of the continuous physical page of the currently used cache item mapping, and the surplus length is expressed in bytes. As shown in fig. 5, assume that the current cache entry pointer is 0, that is, when the current cache entry pointer points to the first cache entry and the queue page table entry is greater than or equal to two entries, specifically:
The remote direct memory access network card initiates a direct memory access read queue basic block based on the physical address of the first cache entry. The method comprises the steps of judging the remaining length of a physical page mapped by a first cache item, if the remaining length is a queue basic block, initiating a queue page table item prefetching request by a remote direct memory access network card, checking the valid bit of a second cache item, if the valid bit is valid, pointing a pointer of a current cache item to the second cache item, and initializing the remaining length.
The remaining length is a queue basic block, which indicates that the page table item pointed by the current cache item pointer is consumed after the current access is completed, so that after the current PCIe DMA access queue request is completed, the valid bit of another cache page table item is checked, if the cache page table item is valid, the current cache item pointer is updated to point to the cache page table item, and the cache page table item is used for subsequent accesses to the queue.
In some embodiments, if the remaining length is a queue basic block, the remote direct memory access network card initiates a queue page table entry prefetch request, as shown in fig. 6, specifically:
if the page table item pointed by the current cache item pointer is consumed after the current access is completed, triggering page table item prefetching, and initiating a PCIe DMA request to prefetch the next page table item based on the current queue page table pointer. When a PCIe DMA requests a prefetch page table entry return, the prefetch page table entry is used to replace the already consumed page table entry.
One cached page table entry may support multiple PCIe DMA queue accesses, illustratively a queue basic block size of 64 bytes, and in the worst case, one page table entry maps only one 4KB physical page, then one page table entry mapped physical page may accommodate 64 queue basic blocks. Thus, one cache page table entry may support 64 queue accesses, requiring 64 PCIe DMA reads, while a prefetch of one cache page table entry requires only 1 PCIe DMA read. Typically, a page table entry prefetched by a PCIe DMA is returned and updated before the current cached page table entry runs out. In the invention, in the process of accessing the network card access queue by the remote direct memory access, a currently available cache item is necessarily existed, and the situation that waiting for the effective page table item blocks the PCIe DMA read queue does not occur, so the invention can be considered to reduce the address translation overhead to 0 in the process of accessing the large-scale remote direct memory access queue.
The invention also provides a queue page table management device based on remote direct memory access, as shown in fig. 7, which comprises:
and the queue access module is used for realizing the reading and writing functions of each queue.
The queue information storage module is used for storing a base address of a queue page table, a pointer of the queue page table, a valid bit value of a first cache item, a valid bit value of a second cache item and a pointer of the cache item.
And the page table entry cache maintenance module is used for receiving and executing the queue page table entry prefetching request initiated by the queue access module.
In some embodiments, both the queue access and the access to the queue page table are implemented through a PCIe bus interface.
The present invention also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of a method of queue page table management based on remote direct memory access.
Accordingly, the present invention also provides an apparatus comprising a computer apparatus including a processor and a memory, the memory having stored therein computer instructions for executing the computer instructions stored in the memory, the apparatus implementing the steps of the method as described above when the computer instructions are executed by the processor.
The embodiments of the present invention also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the edge computing server deployment method described above. The computer readable storage medium may be a tangible storage medium such as Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, floppy disks, hard disk, a removable memory disk, a CD-ROM, or any other form of storage medium known in the art.
In summary, the invention provides a queue page table management method and device based on remote direct memory access, which comprises the steps that a remote direct memory access user state driver allocates a queue buffer area in a user state and creates a queue, the remote direct memory access user state driver initiates a registration request of the queue to a kernel state driver based on a preset function, the remote direct memory access kernel state driver obtains a physical page linked list allocated to the queue from an operating system kernel and allocates memory as a queue page table for the queue, the remote direct memory access kernel state driver traverses each item in the physical page linked list and sequentially writes information of each item into the queue page table, and the remote direct memory access kernel state driver writes a base address of the queue page table into a queue register, writes a pointer of the queue page table into the queue register and sets an initial value. The method provided by the invention can efficiently and conveniently store and manage the queue page table, and greatly reduce the access delay and the storage overhead of the remote direct memory access queue page table.
Those of ordinary skill in the art will appreciate that the various illustrative components, systems, and methods described in connection with the embodiments disclosed herein can be implemented as hardware, software, or a combination of both. The particular implementation is hardware or software dependent on the specific application of the solution and the design constraints. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, a plug-in, a function card, or the like. When implemented in software, the elements of the invention are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine readable medium or transmitted over transmission media or communication links by a data signal carried in a carrier wave.
It should be understood that the invention is not limited to the particular arrangements and instrumentality described above and shown in the drawings. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and shown as examples. The method processes of the present invention are not limited to the specific steps described and shown, but various changes, modifications and additions, or the order between steps may be made by those skilled in the art after appreciating the spirit of the present invention.
In this disclosure, features that are described and/or illustrated with respect to one embodiment may be used in the same way or in a similar way in one or more other embodiments and/or in combination with or instead of the features of the other embodiments.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, and various modifications and variations can be made to the embodiments of the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.