A large page mapping implementation method and system for large-capacity BAR space
The large-page page table is created in the large-capacity BAR space through the large-page management module, which solves the problems of high page table overhead and low performance in traditional technology, and enables efficient resource access to large-capacity PCIe devices.
Patent Information
- Application Number
- CN202311261290.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-27
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2043-09-27
AI Technical Summary
When traditional technology maps large-capacity BAR space to the host, it causes problems such as high system page table overhead and performance degradation.
The large page management module is used to obtain basic information of the PCIe device through the mmap interface, create a large page page table, and provide a program call interface to support large page mapping and release, reducing the number of page table entries and improving access efficiency.
It effectively reduces page table overhead, improves access performance to large-capacity PCIe devices, and meets high-performance data processing requirements.
Smart Images

Figure CN117290263B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of address space management, and in particular to a large page mapping implementation method and system for a large-capacity BAR space. Background Art
[0002] BAR (Base Address Register) space is the hardware resource provided by PCI devices to computer software. The operating system maps these resources to the computer's address space so that software can operate the hardware like operating memory. In the PCI configuration space, the six 32-bit BAR registers from 0x10 to 0x24 are used to define the size of the configuration space required by PCI and the address space occupied by the configuration PCI device.
[0003] The BAR space of traditional PCIe devices is often not large, but with the rise of DPU technology, in order to implement more complex functions on the DPU, such as large model training and reasoning, multi-task parallel processing and high-performance data transmission, PCIe devices often have larger storage resources. At the same time, in order to match the flexibility of the solution, these resources may need to be mapped to the host side host in the form of BAR space, so that the host side host can directly access these resources to efficiently implement complex functions.
[0004] The BAR space corresponding to the large-capacity storage resources on the PCIe device based on DPU technology is referred to as the large-capacity BAR space. Large-page technology is required to map large-capacity storage resources to the host. In the current situation, to map the BAR space to the host, it is necessary to establish a corresponding page table on the host side. The larger the BAR space, the more page table entries there are. This brings two main disadvantages: (1) the system page table overhead is too large; (2) too many page table entries lead to performance degradation.
[0005] Therefore, how to provide a large page mapping implementation method for a large-capacity BAR space that can overcome the above defects of the prior art is a technical problem that needs to be solved urgently. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides a large page mapping implementation method and system for a large-capacity BAR space to eliminate or improve one or more defects in the prior art.
[0007] One aspect of the present invention provides a large page mapping implementation method and system for a large-capacity BAR space, the method comprising the following steps:
[0008] A large page management module for PCIe devices with large-capacity BAR space running in kernel space receives a call instruction for the PCIe device and obtains basic information of the PCIe device to be mapped through the mmap interface, wherein the basic information of the PCIe device includes a BDF address, a mapping flag, a start address, and a mapping length;
[0009] The large page management module creates a large page table storing PCIe device mapping data based on the call instruction and basic information of the PCIe device obtained based on the mmap interface, and feeds back the virtual address corresponding to the created large page table to the caller who issued the call instruction;
[0010] When the large page management module receives the call release instruction sent by the caller, the large page management module releases the corresponding large page table based on the call release instruction;
[0011] When the caller accesses based on the virtual address, the memory management unit in the operating system can convert the virtual address into a corresponding physical address based on the corresponding large page table.
[0012] In some embodiments of the present invention, the setting options supported by the PCIe device mapping data include non-cacheable mode, merge write mode, write-through cache mode and write-back cache mode.
[0013] In some embodiments of the present invention, the large page management module provides a program calling interface for accessing large page mapping for a user mode driver running in a user space.
[0014] In some embodiments of the present invention, the user-mode driver's access operation to the large page management module based on the program call interface includes opening a large page table, closing a large page table, creating an mmap mapping, and contacting an mmap mapping.
[0015] In some embodiments of the present invention, a kernel driver running in kernel space can map a large-capacity BAR space of a PCIe device based on a large page management module and a program call interface, so that the kernel driver supports the ioremmap function.
[0016] In some embodiments of the present invention, the large page management module provides a mapping interface to the application layer in the form of a standard device file.
[0017] In some embodiments of the present invention, the creation and release of the large page table by the large page management module is implemented based on the kernel interface.
[0018] In some embodiments of the present invention, the PCIe device basic information also includes BAR.
[0019] Another aspect of the present invention provides a large page mapping system for a large-capacity BAR space, comprising a processor and a memory, wherein the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the system implements the steps of the method described in any one of the above embodiments.
[0020] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any one of the above embodiments.
[0021] The large page mapping implementation method and system for large-capacity BAR space of the present invention implements mapping based on a created large page management module, and can receive call instructions and call release instructions from a caller, thereby creating or releasing a large page table for storing PCIe device mapping data. The caller accesses based on a virtual address, thereby implementing resource access to a large-capacity PCIe device.
[0022] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically indicated in the specification and the accompanying drawings.
[0023] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of the present application, and do not constitute a limitation of the present invention. In the drawings:
[0025] Figure 1 The flowchart of the large page mapping implementation method in one embodiment of the present invention.
[0026] Figure 2 FIG. 4 is a system architecture diagram including a large page management module according to an embodiment of the present invention.
[0027] Figure 3 FIG. 4 is a system architecture diagram including a large page management module in another embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0029] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.
[0030] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.
[0031] It should also be noted that, unless otherwise specified, the term “connection” herein may refer not only to a direct connection but also to an indirect connection involving an intermediate.
[0032] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0033] DPU (Data Processing Unit) technology is a data processing unit, a chip dedicated to data processing. The emergence of DPU is to solve the performance bottleneck of traditional CPU in data processing. Due to its business characteristics, DPU's BAR space is often larger than the common PCIe devices on the market. In the process of mapping based on BAR space, it is necessary to establish a page table on the host side. The traditional page table mapping method has the disadvantages of too much system page table overhead and too many page table entries leading to performance degradation. Then, the IO Memory of the external DPU device is accessed based on the large-capacity BAR space. The page table is a data structure used in the virtual memory system in the computer operating system, which stores the mapping between virtual addresses and physical addresses. The virtual address is unique in the access process, while the physical address is unique in the hardware. When using virtual memory, the code and data of the process are mapped to different locations in the physical memory. The page table is used to convert the virtual address to the physical address so that the process can access its code and data. The page table is usually in the form of a two-dimensional array, and each page table entry stores a mapping from a virtual address to a physical address. The virtual address is divided into two parts: the page number and the offset within the page. The page number is used to look up the page table, and the offset within the page is used to determine the offset in the physical address.
[0034] In order to overcome the above technical problems, the core lies in how to describe the large-capacity BAR (Base Address Register) space with as few page table entries as possible. Since the large-capacity BAR space (also known as IO-Memory) is essentially a continuous access space with physical addresses, this solution chooses to introduce large page mapping technology into the large-capacity BAR space mapping process of the external DPU device (traditional large page mapping is only used for host memory mapping). For PCIE devices, the existence of IO space is to inherit the PCI specification to be compatible with some traditional devices. IO-MEMORY space is usually used for data transmission, and most PCIE devices also have a part of Memory space for register access. BAR is a register in the configuration space of the PCI device, which is used to store the starting address and size of the device address space.
[0035] This solution provides a large page mapping implementation method for large-capacity BAR space. Figure 1 This is a flow chart of a method for implementing large page mapping in an embodiment of the present invention. The method implements large page mapping based on a large page management module and specifically includes the following steps:
[0036] Step S110: a large page management module for a PCIe device with a large BAR space running in the kernel space receives a call instruction for the PCIe device, and obtains basic information of the PCIe device to be mapped through an mmap interface, wherein the basic information of the PCIe device includes a BDF address, a mapping flag, a start address, and a mapping length;
[0037] Among them, large page mapping refers to expanding the memory page size from the default 4KB to a larger size, such as 2MB, 1GB, etc. Large page mapping can improve the efficiency of memory management. Traditional large page mapping is the host mapping its own memory. This solution introduces large page mapping technology into the memory mapping of PCIe devices (especially DPU devices) with large-capacity BAR space, where the large-capacity BAR space is associated with IO Memory (Input / Output Memory, the memory used by PCIe devices for input and output operations), thereby improving the access efficiency to PCIe devices with large-capacity BAR space. In the specific implementation process, large page mapping is based on the Hugetlb mechanism. It should be explained that IO-Memory can be divided into memory mapping and port mapping. The content of this part is common knowledge in the field and is not further limited.
[0038] Step S120: the large page management module creates a large page table storing PCIe device mapping data based on the calling instruction and the basic information of the PCIe device obtained based on the mmap interface, and feeds back the virtual address corresponding to the created large page table to the caller who issued the calling instruction;
[0039] In the specific implementation process, the mmap interface is used for memory mapping, and the memory is mapped in pages. Mmap is a method of memory mapping files, that is, mapping a file or other object to the address space of the process, realizing a one-to-one correspondence between the file disk address and a virtual address in the process virtual address space.
[0040] Step S130: When the large page management module receives the call release instruction sent by the caller, the large page management module releases the corresponding large page table based on the call release instruction. When the caller accesses based on the virtual address, the memory management unit in the operating system can convert the virtual address into a corresponding physical address based on the corresponding large page table.
[0041] In the specific implementation process, the memory management unit (MMU) is a circuit unit in computer hardware that is responsible for processing memory access requests from the central processing unit. The main function of the MMU is to convert virtual addresses into physical addresses and provide memory protection functions.
[0042] The large page mapping implementation method for large-capacity BAR space proposed in the present invention implements mapping based on the created large page management module, and can receive call instructions and call release instructions from the caller, thereby creating or releasing a large page table for storing PCIe device mapping data. The caller accesses based on the virtual address, thereby realizing resource access to large-capacity PCIe devices. Compared with the prior art, this solution introduces the large page technology originally used to access the host memory into the IO-Memory for accessing the host external PCIe hardware device. Compared with the ordinary page table used in the industry, it reduces the page table overhead and improves the processing performance.
[0043] In some embodiments of the present invention, the setting options supported by the PCIe device mapping data include uncacheable mode (Uncacheable), write combining mode (Write Combining), write-through cache mode (Write-through) and write-back cache mode (Write-back).
[0044] By adopting the above embodiment, while introducing the large page technology to the memory mapping of the PCIe device with large capacity BAR space, most of the functional options of the original ordinary page mapping are retained, so as to avoid unexpected functional anomalies as much as possible during the transition process of different mapping implementation methods. At the same time, the above setting options also ensure the flexibility in the design of PCIe device solutions including DPU, allowing PCIe devices to expose larger capacity storage resources to software.
[0045] In some embodiments of the present invention, the large page management module provides a program call interface for accessing large page mappings for a user-mode driver running in user space. Further, in some embodiments of the present invention, the user-mode driver's access operations to the large page management module based on the program call interface include opening large page tables, closing large page tables, creating mmap mappings, and contacting mmap mappings. Among them, the user space is the memory area where the user process is located, and the user process runs in the user state; the kernel space is the memory area where the kernel process is located, and the kernel process runs in the kernel state. The kernel space is the operating space of the Linux kernel, and the kernel space and the user space run independently of each other. The kernel space can call any resource and execute any command. The user space can only perform simple calculations and cannot directly call system resources. It must issue instructions to the kernel through the system interface (system call).
[0046] By adopting the above embodiment, based on the program call interface, the kernel state driver (also referred to as the kernel driver) can access the large page management module by calling the program call interface (API), thereby creating, modifying and releasing the page table. The large page management module modifies the page table entry based on the call modification instruction received from the caller. This embodiment can reduce the page table overhead and improve the processing performance for the user state driver of the PCIe device with large capacity IO-MEMORY.
[0047] In some embodiments of the present invention, a kernel driver running in kernel space can map a large-capacity BAR space of a PCIe device based on a large page management module and a program call interface, so that the kernel driver supports the ioremmap function.
[0048] Among them, the ioremmap function is based on a register processing function ioremmap. After the physical address is mapped to the virtual address through the ioremap function, the kernel can correctly access the physical address in the form of "virtual address->mmu page table mapping->physical address" through the virtual address returned by ioremap.
[0049] In some embodiments of the present invention, the large page management module provides a mapping interface to the application layer in the form of a standard device file. By adopting this embodiment, better compatibility can be guaranteed. The large page management module provides an API for accessing large page mapping to the user-state driver, so that the kernel driver can map IO-MEMORY through large pages and meet the various functions of the original ioremap, reduce page table overhead, and meet the needs of high-performance data processing. Furthermore, by independently running a large page management module in the kernel space, a mapping interface is provided to the application layer in the form of a standard device file, so that when the user-state driver directly accesses IO-MEMORY, it can also avoid the disadvantage of excessive page table overhead.
[0050] In some embodiments of the present invention, the creation and release of the large page table by the large page management module is implemented based on the kernel interface.
[0051] In some embodiments of the present invention, the basic information of the PCIe device further includes BAR. The basic information of the PCIe device includes BAR, which refers to a base address register in the configuration space, but this register represents the BAR space.
[0052] In the specific implementation process, the basic information of PCIe devices at least includes BDF (including Bus, Device and Function) information. BDF is a number used to uniquely identify a PCIe device. Bus represents the bus number, Device represents the device number, and Function represents the function number. Furthermore, PCIe devices should also include device types. For PCIe devices with large-capacity BAR space, functional devices - DPU devices are mainly considered. Different DPU devices may also include device ID and manufacturer ID for identifying devices. The basic information of PCIe devices also includes configuration space and BAR. The configuration space of PCIe devices is an area used to store PCIe device configuration information. The configuration space can be accessed through the PCIe configuration bus. The BAR of a PCIe device is a register used to store the base address of the PCIe device memory or I / O space (also known as IO Memory). The BAR can be accessed through the PCIe configuration bus.
[0053] Figure 2The system architecture diagram including the huge page management module in one embodiment of the present invention shows the software architecture of using huge pages to map large-capacity BAR space, the core of which is the huge page management module (IO-Memory Hugepage Module). The huge page management module (also called io-hugetlb) working in kernel state proposed in the embodiment of the present invention obtains the BDF address, BAR, mapping flag, starting address, length, etc. of the PCIe device to be mapped by the caller through the mmap interface. Among them, the BDF address is an identifier for uniquely identifying the PCIe device. BDF represents the bus number, device number and function number, and the combination of the three numbers can identify a specific PCIe device. The huge page management module calls the kernel interface to create a huge page page table and returns the corresponding virtual address of the page table to the caller. When the user calls the release page table interface, the huge page management module calls the kernel interface to release the huge page page table. When the user uses the returned virtual address for address access, the MMU will convert it into the corresponding physical address, which is also called the io-memory address. In layman's terms, it is the memory address of the external PCIe device. In actual application, the user-state driver accesses the PCIe device driver module (PCIe DeviceDriver) located in the kernel space based on the mmap interface. The PCIe device driver module transmits the access or call from the user-state driver to the large page management module. The large page management module responds to the access or call from the user-state driver and feeds back the corresponding virtual address of the queried PCIe device to the user-state driver based on the large page table managed by the large page management module, thereby realizing the user-state driver's access to the PCIe Memory (large-capacity BAR space) of the PCIe device.
[0054] It should be noted that the memory management unit (MMU) is an indispensable part of the modern CPU architecture. The main functions of the MMU include virtual-to-real address translation, access permission control, and extended physical memory management. The kernel includes the process scheduler (SCHED), memory management unit (MMU), virtual file system (VFS), network interface (NET), and inter-process communication subsystem (IPC).
[0055] Figure 3This is a system architecture diagram including a huge page management module in another embodiment of the present invention. It shows another software architecture that uses huge pages to map large-capacity BAR space, the core of which is the huge page management module (IO-Memory HugepageModule), whose specific access entry is io-hugetlb.ko, which is an entry in the TLB (Translation Lookaside Buffer) pointing to HugePage. Users can use the huge page table (HugePage) through mmap or SYSV shared memory (shmget / shmat), where TLB is a cache (Cache) for converting virtual addresses to physical addresses, and contains the mapping relationship of part of the page surface (page table), which is used to quickly realize the conversion of virtual addresses to physical addresses. The user-state driver can open (open), close (close), mmap operation and mmap release operation (unmmap) of the page table based on the program call interface, and the kernel driver can perform ioremap operation and unioremap operation based on the mapping interface.
[0056] Corresponding to the above method, the present invention also provides a large page mapping system for a large-capacity BAR space, the system comprising a computer device, the computer device comprising a processor and a memory, the memory storing computer instructions, the processor being used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the system implements the steps of the method described above.
[0057] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method described above are implemented. The computer-readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0058] Based on the large page mapping implementation method and system for large-capacity BAR space proposed by the present invention, mapping is implemented based on the created large page management module, which can receive call instructions and call release instructions from the caller, thereby creating or releasing a large page table for storing PCIe device mapping data, and the caller accesses based on the virtual address, thereby realizing resource access to large-capacity PCIe devices. Compared with the prior art, this solution introduces the large page technology originally used to access the host memory into the IO-Memory for accessing the host external PCIe hardware device. Compared with the ordinary page table used in the industry, it reduces the page table overhead and improves the processing performance.
[0059] Furthermore, based on the large page management module, a program call interface for accessing large page mapping is provided for the user-state driver running in the user space, and the large page management module provides a mapping interface to the application layer in the form of a standard device file. The large page management module provides an API for accessing large page mapping to the user-state driver, so that the kernel driver can map IO-MEMORY through large pages and meet the various functions of the original ioremap, reduce page table overhead, and meet the needs of high-performance data processing. By providing a mapping interface to the application layer in the form of a standard device file, the user-state driver can also avoid the disadvantage of excessive page table overhead when directly accessing IO-MEMORY.
[0060] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0061] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0062] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.
[0063] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A large page mapping implementation method for a large capacity BAR space, characterized in that: The method comprises the following steps: A large page management module for PCIe devices with large-capacity BAR space running in kernel space receives a call instruction for the PCIe device and obtains basic information of the PCIe device to be mapped through an mmap interface, wherein the basic information of the PCIe device includes a BDF address, a mapping flag, a start address and a mapping length; wherein the mmap interface is used to perform memory mapping in units of pages, and mmap is a method of memory mapping files, which maps a file or other object to the address space of a process; The large page management module creates a large page table storing PCIe device mapping data based on the call instruction and basic information of the PCIe device obtained based on the mmap interface, and feeds back the virtual address corresponding to the created large page table to the caller who issued the call instruction; When the large page management module receives the call release instruction sent by the caller, the large page management module releases the corresponding large page table based on the call release instruction; The large page management module provides a program call interface for accessing large page mappings for the user state driver running in the user space. The user state driver's access operations to the large page management module based on the program call interface include opening large page table, closing large page table, creating mmap mapping and releasing mmap mapping. The kernel driver running in the kernel space can map the large capacity BAR space of the PCIe device based on the large page management module and the program call interface, so that the kernel driver supports the ioremmap function. When the caller accesses based on the virtual address, the memory management unit in the operating system can convert the virtual address into a corresponding physical address based on the corresponding large page table.
2. The method according to claim 1, characterized in that The setting options supported by the PCIe device mapping data include non-cacheable mode, merge write mode, write-through cache mode and write-back cache mode.
3. The method according to claim 1, characterized in that The large page management module provides a mapping interface to the application layer in the form of a standard device file.
4. The method according to claim 1, characterized in that: The creation and release of large page tables by the large page management module are implemented based on the kernel interface.
5. The method according to claim 1, characterized in that The PCIe device basic information also includes BAR.
6. A large page mapping system for a large capacity BAR space, comprising a processor and a memory, characterized in that: The memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the system implements the steps of the method as claimed in any one of claims 1 to 5.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Page partition management device and method based on composite scale page
CN106528453A
Large page memory compression recovery system and method
CN106980541A
Method for accessing table entry in translation lookaside buffer (TLB) and processing chip
CN108139981A
KVM system supporting novel large-page frame
CN108628663A
Memory management method and device, electronic equipment and storage medium
CN112445767A
