A memory access method and device, electronic equipment and storage medium

By establishing a mapping between indexes and addresses between kernel mode and user mode, the processing process can directly access memory, solving the problem of low memory access efficiency in existing technologies and achieving more efficient memory access.

CN118642978BActive Publication Date: 2026-02-24XINHUASAN INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410813724.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2026-02-24
Estimated Expiration
2044-06-21

AI Technical Summary

Technical Problem

In the prior art, when application software performs data read and write operations, the communication between the file system and the user-mode processing process prevents data read and write operations from being performed on the Page during the locking period, resulting in low efficiency.

Method used

By establishing a mapping between indexes and addresses between kernel mode and user mode, the processing process can directly access memory by determining the user-mode address based on the index, avoiding locking the entire page and improving memory access efficiency.

Benefits of technology

It improves memory access efficiency, avoids data read/write operations during locking, reduces memory copy time, and is suitable for various operating system environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118642978B_ABST
    Figure CN118642978B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a memory access method and device, electronic equipment and storage medium. Relate to data storage technical field, the above-mentioned method comprises: after receiving the I / O instruction sent by the application program for the position to be accessed, the file system sends the I / O request to the processing process;The processing process determines the target second index corresponding to the target first index according to the third corresponding relationship, and determines the target user mode address, the target second kernel address corresponding to the target second index according to the second corresponding relationship;According to the target user mode address, the target second kernel address and the target kernel address, the user mode address to be accessed is determined;According to the determined user mode address, access the memory. The scheme provided by the embodiments of the present application can improve the efficiency of memory access.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data storage technology, and in particular to a memory access method, apparatus, electronic device, and storage medium. Background Technology

[0002] In the field of file storage, to achieve high-performance I / O (Input / Output), it is typically necessary to implement a file system in the Linux kernel for memory management and a processing process in user space for data processing. Most of the complex and high-load processing logic is performed in the user-space processing process. Therefore, when the processing process processes data, communication is required between the kernel-space file system and the user-space processing process to achieve data or metadata I / O.

[0003] In related technologies, when application software performs data read / write operations, it first enters the kernel-mode file system via a system call, and then passes the data to the user-mode processing process. Specifically, the application software transmits the user-mode address of the data it requests to access to the file system. The file system uses address translation functions provided by the kernel to convert the received user-mode address into the kernel-mode address of a page in memory. The file system then performs a "pin" operation on this page, reserving the physical memory described by the page in the current address space, thus locking the page and preventing it from being moved or modified. Finally, the physical memory described by the page is sent to the processing process via a "send_page" operation.

[0004] However, when performing data read and write operations in the above manner, even if only a portion of the data in a page is needed, the entire page must be locked. This prevents data read and write operations from being performed on the page during the locking period, resulting in low memory access efficiency for the entire system. Summary of the Invention

[0005] The purpose of this invention is to provide a memory access method, apparatus, electronic device, and storage medium to improve memory access efficiency. The specific technical solution is as follows:

[0006] In a first aspect of the present invention, a memory access method is provided, applied to an electronic device, the electronic device including a file system in kernel mode and a processing process in user mode; the file system maintains a first correspondence between a first index and a first kernel address, the first kernel address being the kernel address of a pre-allocated memory space; the processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address; the user-mode address and the second kernel address with the second correspondence indicate the same memory space; for the same first kernel address and second kernel address, the first kernel address and the second kernel address respectively correspond to a first index and a second index, and a third correspondence exists between the first index and the second index; the method includes:

[0007] Upon receiving an input / output I / O instruction from an application for a location to be accessed, the file system sends an I / O request to the processing process; wherein, the I / O request carries the target kernel address of the location to be accessed and a target first index, the target first index being a first index that has the first correspondence with the first kernel address in the memory space where the target kernel address is located;

[0008] The processing process determines the target second index corresponding to the target first index according to the third correspondence, and determines the target user-mode address and target second kernel address corresponding to the target second index according to the second correspondence; determines the user-mode address to be accessed according to the target user-mode address, target second kernel address and target kernel address; and accesses memory according to the determined user-mode address.

[0009] In one possible embodiment, the second correspondence is determined in the following manner:

[0010] The file system registers miscellaneous device files and sends a start mapping message to the processing process;

[0011] Upon receiving the start mapping message, the processing process opens the miscellaneous device file and calls the memory mapping mmap interface to send the size of the pre-allocated memory space to the file system.

[0012] The file system feeds back the size of the indicated memory space to the processing process through the mmap interface, which is the user-space address of the memory size;

[0013] The processing process records the received user-mode address and triggers a page fault based on the user-mode address;

[0014] When the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space and sends relationship information containing the first correspondence between the kernel-mode address of the page faulty page to the processing process.

[0015] The processing process reads the data in the acquired page fault page based on the user-mode address, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page fault page, and the allocated second index based on the first correspondence represented by the relationship information.

[0016] In one possible embodiment, the page in memory is contained within a large memory page in a pre-allocated memory space. The size of the large memory page is the memory size preset by the operating system configured for the electronic device. The kernel-mode address of the page-faulting page is contained in a Page structure, and the pointer to the Page structure of the page-faulting page is obtained in the following way:

[0017] Based on the first identifier of the page fault page among all pages and the number of pages contained in each memory page, the second identifier of the memory page containing the page fault page and the order of the page fault page in the memory page are determined.

[0018] Based on the second identifier and the order, obtain the pointer to the Page structure of the missing page.

[0019] In one possible embodiment, obtaining a pointer to the Page structure of the missing page based on the second identifier and the order includes:

[0020] If the page faulty page is determined to be the first page in the memory superpage according to the order, then based on the second identifier, a pointer to the superpage structure of the memory superpage containing the page faulty page is obtained as a pointer to the Page structure of the page faulty page; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0021] In one possible embodiment, obtaining a pointer to the Page structure of the missing page based on the second identifier and the order includes:

[0022] If it is determined according to the order that the page fault page is not the first page in the memory superpage it belongs to, then based on the second identifier, a pointer to the superpage structure of the memory superpage where the page fault page belongs is obtained, and based on the obtained pointer and the order, a pointer to the Page structure of the page fault page is calculated; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0023] In one possible embodiment, the pre-allocated memory space includes large pages and small blocks of memory, and is obtained by:

[0024] The file system requests the allocation of large page memory; wherein the size of the large page memory is the preset memory size of the operating system configured in the electronic device;

[0025] The file system divides the allocated large page memory into multiple smaller memory blocks of a preset size.

[0026] In one possible embodiment, each memory block corresponds to a description structure, which includes the starting address, size, identifier of the large page memory in which the memory block is located, and the offset value of the memory block within the large page memory.

[0027] In a second aspect of the present invention, an electronic device is also provided, the electronic device including a file system in kernel mode and a processing process in user mode; the file system maintains a first correspondence between a first index and a first kernel address, the first kernel address being the kernel address of a pre-allocated memory space; the processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address; the user-mode address and the second kernel address with the second correspondence indicate the same memory space, and for the same first kernel address and second kernel address, the first kernel address and the second kernel address respectively correspond to a first index and a second index, and a third correspondence exists between the first index and the second index; the electronic device further includes a memory, a transceiver, and a processor.

[0028] A memory for storing computer programs; a transceiver for sending and receiving data under the control of the processor; and a processor for reading the computer programs from the memory and performing the following operations:

[0029] Upon receiving an input / output I / O instruction from an application for a location to be accessed, the file system sends an I / O request to the processing process; wherein, the I / O request carries the target kernel address of the location to be accessed and a target first index, the target first index being a first index that has the first correspondence with the first kernel address in the memory space where the target kernel address is located;

[0030] The processing process determines the target second index corresponding to the target first index according to the third correspondence, and determines the target user-mode address and target second kernel address corresponding to the target second index according to the second correspondence; determines the user-mode address to be accessed according to the target user-mode address, target second kernel address and target kernel address; and accesses memory according to the determined user-mode address.

[0031] In one possible embodiment, the second correspondence is determined in the following manner:

[0032] The file system registers miscellaneous device files and sends a start mapping message to the processing process;

[0033] Upon receiving the start mapping message, the processing process opens the miscellaneous device file and calls the memory mapping mmap interface to send the size of the pre-allocated memory space to the file system.

[0034] The file system feeds back the size of the indicated memory space to the processing process through the mmap interface, which is the user-space address of the memory size;

[0035] The processing process records the received user-mode address and triggers a page fault based on the user-mode address;

[0036] When the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space and sends relationship information containing the first correspondence between the kernel-mode address of the page faulty page to the processing process.

[0037] The processing process reads the data in the acquired page fault page based on the user-mode address, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page fault page, and the allocated second index based on the first correspondence represented by the relationship information.

[0038] In one possible embodiment, the page in memory is contained within a large memory page in a pre-allocated memory space. The size of the large memory page is the memory size preset by the operating system configured for the electronic device. The kernel-mode address of the page-faulting page is contained in a Page structure, and the pointer to the Page structure of the page-faulting page is obtained in the following way:

[0039] The file system determines the second identifier of the memory page containing the page fault and the order of the page fault in the memory page based on the first identifier of the page fault in all pages and the number of pages contained in each memory page.

[0040] The file system obtains a pointer to the Page structure of the missing page based on the second identifier and the order.

[0041] In one possible embodiment, the file system obtains a pointer to the Page structure of the page-missing page based on the second identifier and the order, including:

[0042] If the page faulty page is determined to be the first page in the memory superpage according to the order, the file system obtains a pointer to the superpage structure of the memory superpage containing the page faulty page based on the second identifier, and uses it as a pointer to the Page structure of the page faulty page; wherein the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0043] In one possible embodiment, the file system obtains a pointer to the Page structure of the page-missing page based on the second identifier and the order, including:

[0044] If it is determined according to the order that the page fault page is not the first page in the memory superpage it is in, then the file system obtains a pointer to the superpage structure of the memory superpage in which the page fault page is located based on the second identifier, and calculates a pointer to the Page structure of the page fault page based on the obtained pointer and the order; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0045] In one possible embodiment, the pre-allocated memory space includes large pages and small blocks of memory, and is obtained by:

[0046] The file system requests the allocation of large page memory; wherein the size of the large page memory is the preset memory size of the operating system configured in the electronic device;

[0047] The file system divides the allocated large page memory into multiple smaller memory blocks of a preset size.

[0048] In one possible embodiment, each memory block corresponds to a description structure, which includes the starting address, size, identifier of the large page memory in which the memory block is located, and the offset value of the memory block within the large page memory.

[0049] In a third aspect of the present invention, a memory access device is also provided, applied to an electronic device, the electronic device including a file system in kernel mode and a processing process in user mode; the file system maintains a first correspondence between a first index and a first kernel address, the first kernel address being the kernel address of a pre-allocated memory space; the processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address; the user-mode address and the second kernel address with the second correspondence indicate the same memory space, and for the same first kernel address and second kernel address, the first kernel address and the second kernel address respectively correspond to a first index and a second index, and a third correspondence exists between the first index and the second index, the device comprising:

[0050] The request sending module is used to send an I / O request to the processing process after receiving an input / output I / O instruction sent by the application for the location to be accessed; wherein the I / O request carries the target kernel address of the location to be accessed and a target first index, the target first index being a first index that has the first correspondence with the first kernel address in the memory space where the target kernel address is located;

[0051] The memory access module is used by the processing process to determine the target second index corresponding to the target first index according to the third correspondence, and to determine the target user-mode address and the target second kernel address corresponding to the target second index according to the second correspondence; to determine the user-mode address to be accessed according to the target user-mode address, the target second kernel address and the target kernel address; and to access memory according to the determined user-mode address.

[0052] In one possible embodiment, the second correspondence is determined in the following manner:

[0053] The file system registers miscellaneous device files and sends a start mapping message to the processing process;

[0054] Upon receiving the start mapping message, the processing process opens the miscellaneous device file and calls the memory mapping mmap interface to send the size of the pre-allocated memory space to the file system.

[0055] The file system feeds back the size of the indicated memory space to the processing process through the mmap interface, which is the user-space address of the memory size;

[0056] The processing process records the received user-mode address and triggers a page fault based on the user-mode address;

[0057] When the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space and sends relationship information containing the first correspondence between the kernel-mode address of the page faulty page to the processing process.

[0058] The processing process reads the data in the acquired page fault page based on the user-mode address, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page fault page, and the allocated second index based on the first correspondence represented by the relationship information.

[0059] In one possible embodiment, the page in memory is contained within a large memory page in a pre-allocated memory space. The size of the large memory page is the memory size preset by the operating system configured for the electronic device. The kernel-mode address of the page-faulting page is contained in a Page structure, and the pointer to the Page structure of the page-faulting page is obtained in the following way:

[0060] Based on the first identifier of the page fault page among all pages and the number of pages contained in each memory page, the second identifier of the memory page containing the page fault page and the order of the page fault page in the memory page are determined.

[0061] Based on the second identifier and the order, obtain the pointer to the Page structure of the missing page.

[0062] In one possible embodiment, obtaining a pointer to the Page structure of the missing page based on the second identifier and the order includes:

[0063] If the page faulty page is determined to be the first page in the memory superpage according to the order, then based on the second identifier, a pointer to the superpage structure of the memory superpage containing the page faulty page is obtained as a pointer to the Page structure of the page faulty page; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0064] In one possible embodiment, obtaining a pointer to the Page structure of the missing page based on the second identifier and the order includes:

[0065] If it is determined according to the order that the page fault page is not the first page in the memory superpage it belongs to, then based on the second identifier, a pointer to the superpage structure of the memory superpage where the page fault page belongs is obtained, and based on the obtained pointer and the order, a pointer to the Page structure of the page fault page is calculated; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0066] In one possible embodiment, the pre-allocated memory space includes large pages and small blocks of memory, and is obtained by:

[0067] The file system requests the allocation of large page memory; wherein the size of the large page memory is the preset memory size of the operating system configured in the electronic device;

[0068] The file system divides the allocated large page memory into multiple smaller memory blocks of a preset size.

[0069] In one possible embodiment, each memory block corresponds to a description structure, which includes the starting address, size, identifier of the large page memory in which the memory block is located, and the offset value of the memory block within the large page memory.

[0070] In another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements the steps of any of the methods described in the first aspect above.

[0071] Beneficial effects of the embodiments of the present invention:

[0072] The memory access method provided in this embodiment of the invention, after receiving an I / O instruction sent by an application for a location to be accessed, the file system sends an I / O request to the processing process. The I / O request carries the target kernel address and the target first index of the location to be accessed. Since for the same first kernel address and second kernel address, the first kernel address and the second kernel address correspond to the first index and the second index respectively, and there is a third correspondence between the first index and the second index, the processing process can determine the target second index corresponding to the target first index based on the third correspondence.

[0073] Furthermore, since the processing process maintains a second correspondence among the second index, user-mode address, and second kernel address, the processing process in user mode can determine the target user-mode address and target second kernel address corresponding to the target second index based on this second correspondence. Based on the determined target user-mode address, target second kernel address, and target kernel address, the processing process can determine the user-mode address to be accessed. Because the user-mode address and second kernel address, which have a second correspondence, indicate the same memory space, the processing process can successfully access memory based on the determined user-mode address.

[0074] Since the processing process can directly access memory based on the determined user-mode address during memory access, it does not need to lock the entire page, thus avoiding the inability to read or write data to the page during the locking period, thereby improving the efficiency of memory access.

[0075] Of course, implementing any product or method of the present invention does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0076] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0077] Figure 1 This is a schematic diagram of the first type of memory access in related technologies;

[0078] Figure 2 This is a schematic diagram of the structure of the second type of memory access in related technologies;

[0079] Figure 3 This is a schematic diagram of the third type of memory access in related technologies;

[0080] Figure 4 A flowchart illustrating a memory access method provided in an embodiment of the present invention;

[0081] Figure 5 A flowchart illustrating a second correspondence determination method provided in an embodiment of the present invention;

[0082] Figure 6 A schematic diagram of a pre-allocated memory space provided in an embodiment of the present invention;

[0083] Figure 7 This is a schematic diagram of a user-mode address determination method provided in an embodiment of the present invention;

[0084] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention;

[0085] Figure 9 This is a schematic diagram of a memory access device provided in an embodiment of the present invention. Detailed Implementation

[0086] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on the present invention are within the scope of protection of the present invention.

[0087] In related technologies, communication between the kernel-mode file system and the user-mode processing process is achieved through memory copying, shared memory, or page-based "pin operations" and "send_page operations." The following section uses the example of a processing process reading data to describe these three methods.

[0088] First method: See Figure 1 This is a schematic diagram of the first type of memory access in related technologies. From... Figure 1 As can be seen, kernel mode includes the file system, while user mode includes application software and processing processes.

[0089] Specifically, when a processing process needs to read data from memory, it first reads the data from the file system into the kernel-mode buffer through a system call, and then copies the data from the kernel-mode buffer to the address space of the user-mode process through a memory copy, thereby completing the data reading.

[0090] The second method: See Figure 2 This is a schematic diagram of the second type of memory access in related technologies. From... Figure 2 As can be seen, kernel mode includes the file system, while user mode includes application software and processing processes.

[0091] Specifically, the application software obtains the user-space address of the shared memory through the shmget(shared memory get) and shmat(shared memory attach) functions, and then writes the data of the I / O request into the shared memory. When the processing process receives an I / O request from the file system, the processing process uses the key of the shared memory sent from the file system to obtain the virtual address of the shared memory in the processing process through the shmat function, and the processing process uses the virtual address to read data from the shared memory.

[0092] The Shmget function is used to create or obtain the identifier of a shared memory segment, and the shmat function is used to connect the shared memory segment to the address space of the current processing process.

[0093] The third method: See Figure 3 This is a schematic diagram of the structure of the third type of memory access in related technologies. From Figure 3 As can be seen, kernel mode includes the file system, while user mode includes application software and processing processes.

[0094] Specifically, the application software transmits the user-space address of the data it requests to access to the file system. The file system uses address translation functions provided by the kernel to convert the received user-space address into the kernel-space address of the page in memory. The file system then performs a "pin operation" on the page, reserving the physical memory described by the page in the current address space, effectively locking the page and preventing it from being moved or modified. Finally, the file system sends the physical memory described by the page to the processing process via a "send_page operation".

[0095] However, all three methods have certain drawbacks. The memory copying in the first method is too time-consuming. The second method requires modification of the application software code, resulting in poor applicability, and the application software must place the data in shared memory when reading or writing data, placing high demands on the application software's read / write operations. In the third method, even if the application software only needs to read or write a small amount of data, the entire page must be locked, preventing any data read / write operations on that page during the locking period, thus resulting in low memory access efficiency for the entire system.

[0096] Based on this, embodiments of the present invention provide a memory access method. See also Figure 4 This is a flowchart illustrating a memory access method provided by an embodiment of the present invention, applied to an electronic device. The electronic device includes a file system in kernel mode and a processing process in user mode. The file system maintains a first correspondence between a first index and a first kernel address, where the first kernel address is the kernel address of a pre-allocated memory space. The processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address. A user-mode address and a second kernel address with a second correspondence indicate the same memory space. For the same first kernel address and second kernel address, the first kernel address and the second kernel address correspond to the first index and the second index, respectively, and a third correspondence exists between the first index and the second index. The method includes steps S401-S402.

[0097] S401: After receiving an I / O instruction from the application for the location to be accessed, the file system sends an I / O request to the processing process.

[0098] In S401, I / O instructions are divided into two types: read data instructions and write data instructions. I / O instructions can be generated by the application; specifically, they can be triggered manually by the user or automatically by the application. The location to be accessed refers to the location of memory to be accessed. This memory can be the entire page or a small block of memory within a page.

[0099] The I / O request carries the target kernel address of the location to be accessed and a target first index. The target first index is a first index that has a first correspondence with the first kernel address of the memory space where the target kernel address is located. The first index is the key value used to match entries in the first kernel address table when searching for those entries. The first kernel address is the address of the pre-allocated memory space in kernel mode. For example, the first kernel address can be the starting address of the memory space in kernel mode. In this case, the first length of the memory space also needs to be recorded. Alternatively, the first kernel address can also include the starting and ending addresses of the memory space in kernel mode.

[0100] In one possible embodiment, the first correspondence between the first index and the first kernel address of the pre-allocated memory space can be represented by a kernel-mode address table.

[0101] For example, see Table 1, which is a kernel address table provided in an embodiment of the present invention. Table 1 includes a first index, a first kernel address, and a first length, wherein the first length is the length of the pre-allocated memory space, which can be measured in bytes, bits, etc.

[0102] Table 1

[0103] First Index First kernel address First Length First Index First kernel address First Length First Index First kernel address First Length First Index First kernel address First Length First Index First kernel address First Length

[0104] Each row in the kernel-mode address table represents an entry, corresponding to a pre-allocated memory space. The first index in each entry is the index of the memory space corresponding to that entry, the first kernel address in each entry is the starting address of the memory space corresponding to that entry in kernel mode, and the first length in each entry is the length of the memory space corresponding to that entry. If there are multiple memory spaces, there will be multiple entries.

[0105] It should be noted that the kernel-mode address table is only one representation of the first correspondence between the first index and the first kernel address of the pre-allocated memory space. This embodiment of the invention does not specifically limit the representation of the first correspondence. For example, the above-mentioned first correspondence can also be stored in a file, and each line of data in the file represents a first correspondence.

[0106] S402, the processing process determines the target second index corresponding to the target first index according to the third correspondence, and determines the target user-mode address and target second kernel address corresponding to the target second index according to the second correspondence; determines the user-mode address to be accessed according to the target user-mode address, target second kernel address and target kernel address; and accesses memory according to the determined user-mode address.

[0107] In S402, for the same first kernel address and second kernel address, the first kernel address and the second kernel address correspond to the first index and the second index respectively, and there is a third correspondence between the first index and the second index.

[0108] The second index is the key value used to match entries in the user-mode address and second kernel address table. The user-mode address is the address of the pre-allocated memory space in user mode. For example, the user-mode address can be the starting address of the memory space in user mode. In this case, the second length of the memory space also needs to be recorded. Alternatively, the user-mode address can also include the starting and ending addresses of the memory space in user mode. The second kernel address is the address of the pre-allocated memory space in kernel mode. For example, the second kernel address can be the starting address of the memory space in kernel mode. In this case, the second length of the memory space also needs to be recorded. Alternatively, the second kernel address can also include the starting and ending addresses of the memory space in kernel mode. The addresses of memory locations in user mode and kernel mode are different.

[0109] In one possible embodiment, the second correspondence between the second index, the user-mode address, and the second kernel address can be represented by a user-mode address mapping table.

[0110] For example, see Table 2, which is a user-mode address mapping table provided in an embodiment of the present invention. Table 2 includes a second index, a user-mode address, a second kernel address, and a second length, wherein the second length is the length of the pre-allocated memory space, which can be measured in bytes or bits.

[0111] Table 2

[0112] Second Index User-mode address Second kernel address Second length Second Index User-mode address Second kernel address Second length Second Index User-mode address Second kernel address Second length Second Index User-mode address Second kernel address Second length Second Index User-mode address Second kernel address Second length

[0113] Each row of the aforementioned user-space address mapping table represents an entry, corresponding to a pre-allocated memory space. The second index in each entry is the index of the memory space corresponding to that entry; the user-space address in each entry is the starting address of the memory space in user space; the second kernel address in each entry is the starting address of the memory space in kernel space; and the second length in each entry is the length of the memory space corresponding to that entry. If multiple memory spaces exist, there will be multiple entries.

[0114] It should be noted that the user-space address mapping table is only one form of the second correspondence between the second index, the user-space address, and the second kernel address. This embodiment of the invention does not specifically limit the form of the second correspondence. For example, the above-mentioned second correspondence can also be stored in a file, where each line of data in the file represents a second correspondence.

[0115] The processing process determines the user-mode address to be accessed based on the target user-mode address, the target secondary kernel address, and the target kernel address as follows: Assuming the user-mode address to be accessed is Y, the target kernel address is X1, the target secondary kernel address is X2, and the target user-mode address is X3, then Y = X1 - X2 + X3. Here, X1 - X2 represents the offset of the memory to be accessed within its current page, and X3 corresponds to the same memory location as X1. Therefore, by adding the aforementioned offset to the user-mode address X3, the address of the memory to be accessed in user mode can be obtained.

[0116] Using the above embodiment, after receiving the I / O instruction sent by the application for the location to be accessed, the file system sends an I / O request to the processing process. The I / O request carries the target kernel address of the location to be accessed and the target first index. Since the same first kernel address and second kernel address correspond to the first index and the second index respectively, and there is a third correspondence between the first index and the second index, the processing process can determine the target second index corresponding to the target first index based on the third correspondence.

[0117] Furthermore, since the processing process maintains a second correspondence among the second index, user-mode address, and second kernel address, the processing process in user mode can determine the target user-mode address and target second kernel address corresponding to the target second index based on this second correspondence. Based on the determined target user-mode address, target second kernel address, and target kernel address, the processing process can determine the user-mode address to be accessed. Because the user-mode address and second kernel address, which have a second correspondence, indicate the same memory space, the processing process can successfully access memory based on the determined user-mode address.

[0118] Since the processing process can directly access memory based on the determined user-mode address during memory access, it does not need to lock the entire page, thus avoiding the inability to read or write data to the page during the locking period, thereby improving the efficiency of memory access.

[0119] Furthermore, since the processing process can directly access memory based on the determined user-mode address during memory access, it avoids memory copying between kernel mode and user mode, saving the time spent copying data from the kernel-mode buffer to the address space of the user-mode process or vice versa, thereby improving the efficiency of memory access.

[0120] Furthermore, in this embodiment of the invention, the processing process does not need to modify the application software code during memory access, nor does it place high demands on the application software's read and write operations.

[0121] In one possible embodiment, see Figure 5 The above is a flowchart illustrating a second correspondence determination method provided in an embodiment of the present invention, which includes steps S501-S506.

[0122] S501, the system registers miscellaneous device files and sends a start mapping message to the processing process.

[0123] In S501, miscellaneous device files are a special type of device file provided by the Linux kernel, which provides user-mode processes with a functional interface to access kernel modules. The device file name is a constant string agreed upon with the user-mode processes.

[0124] S502: Upon receiving the start mapping message, the processing process opens the miscellaneous device file and calls the mmap interface to send the size of the pre-allocated memory space to the file system.

[0125] In S502, the mmap (memory map) interface is the interface for memory-mapped files. It provides a mechanism for operating systems such as Linux to directly load file contents into the process address space. The mmap interface allows direct access to file data without actually copying the data, which can be used for processing large files, helping to improve performance and reduce memory consumption.

[0126] In S503, the file system uses the mmap interface to send the indicated memory space size to the processing process, which is the user-space address of the memory size.

[0127] In S503, the file system assigns the page fault handling function pointer to the vm_ops (virtual memory operations structure) field of the vma (virtual memory area) structure passed to the mmap interface, and feeds back the user-space address indicating the size of the memory space to the processing process through the mmap interface.

[0128] In the Linux kernel, `vma` is a data structure that represents a memory region in the virtual address space. Each `vma` structure represents a portion of memory in the system, which may correspond to a file mapping, device mapping, or other types of mapping. `vma` contains information such as its starting address, size, permissions, and mapped files; the kernel uses this information to manage the memory mapping relationships of processes.

[0129] The `vm_ops` field is typically of type `struct vm_operations_struct(struct virtual memoryoperations structure)`, and it is a member of each `vma` structure. `vm_ops` defines a set of operations used to implement memory mapping behavior for specific types or functions. For example, for file mappings, `vm_ops` contains pointers to functions for creating, deleting, and resizing mappings. Different memory mapping types, such as regular files, device files, and anonymous memory mappings, may have different `vm_ops` implementations to allow for customized memory management tailored to their specific characteristics.

[0130] S504: The processing process records the received user-mode address and triggers a page fault based on the user-mode address.

[0131] In S504, although the processing process receives the user-mode address fed back by the file system, the file system does not allocate actual memory space for that user-mode address. Therefore, when the processing process accesses memory based on that user-mode address, it will trigger a page fault.

[0132] A page fault occurs when a process accesses memory through a user-mode address, and the system finds that the page indicated by that address does not exist and a new page needs to be allocated.

[0133] S505: When the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space and sends the first correspondence information containing the kernel-mode address of the page faulty page.

[0134] In S505, the kernel-mode address of a page fault refers to the address of that page fault in kernel mode. The first mapping contains the kernel-mode address of the page fault and its corresponding index.

[0135] In one possible implementation, the kernel-mode address of the page fault is contained in a Page structure, and the file system assigns a pointer to the Page structure of the page fault to the vmf (virtual memory fault) parameter.

[0136] S506, the processing process reads the data in the acquired page fault page based on the user-mode address, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page fault page, and the allocated second index based on the first correspondence represented by the relation information.

[0137] In S506, since the user-mode address is the address of the page faulty page in user mode, the processing process reads the data from the acquired page faulty page based on the user-mode address, indicating that the file system has allocated actual memory space for the user-mode address. At this point, the processing process can create a second correspondence between the received user-mode address, the kernel-mode address of the page faulty page, and the second index based on the first correspondence represented by the relational information.

[0138] In the above embodiment, the file system registers a miscellaneous device file and sends a start mapping message to the processing process. Since the miscellaneous device file is an interactive file between the file system and the processing process, when the processing process receives the start mapping message, it opens the miscellaneous device file. The file system can allocate a user-space address equal to the size of the pre-allocated memory space sent by the processing process. Because the file system only provides the user-space address to the processing process but does not allocate actual memory space for that user-space address, the processing process will trigger a page fault when accessing memory based on that user-space address. When the file system determines that a page fault has occurred, it allocates actual memory space for that user-space address. When the processing process successfully reads the data from the acquired page fault page, it creates a second correspondence between the received user-space address, the kernel-space address of the page fault page, and the second index.

[0139] In the process of determining the second correspondence, if the size of the pre-allocated memory space is too large, such as 500G, the obtained page fault pages may be discontinuous, and the corresponding kernel-mode addresses may also be discontinuous. Therefore, the way the file system handles the page fault situation will also be different.

[0140] In one possible embodiment, the page in memory is contained within a large memory page in the pre-allocated memory space. The size of the large memory page is the memory size preset by the operating system configured for the electronic device. The kernel-mode address of the page fault page is contained in a Page structure, and the pointer to the Page structure of the page fault page is obtained through steps A-B.

[0141] Step A: If the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space, and determines the second identifier of the memory page containing the page faulty page and the order of the page faulty page in the memory page based on the first identifier of the page faulty page among all pages and the number of pages contained in each memory page.

[0142] In step A, when the mmap interface is called by the processing process, a virtual machine (vma) is allocated in the processing process. The allocated vma manages all pages in the memory space requested by the mmap interface.

[0143] The first identifier of a missing page among all pages refers to the position of the missing page among all pages managed by VMA, that is, which page the missing page belongs to in VMA.

[0144] It should be noted that for large memory pages, a page fault generally occurs only once. The page that is faulted can be the first page in the large memory page, or any other page in the large memory page. The memory size of the page faulted page can be 4KB or other sizes; this embodiment of the invention does not impose a specific limitation on the memory size of the page faulted page.

[0145] The number of pages contained in each memory page refers to how many pages the memory page contains. For example, assuming the memory page size is 2MB and each page size is 4KB, then the memory page contains 512 pages.

[0146] The second identifier of the memory page containing the page faulty page refers to the index of the memory page containing the page faulty page in the memory page array. By using the second identifier of the memory page containing the page faulty page, the position of the memory page containing the page faulty page in the memory page array can be determined.

[0147] The order of a page fault in a memory page refers to which page the page fault belongs to within its memory page.

[0148] For example, assuming the first identifier of the page fault page among all pages is represented by vmf.pg_off, and the number of pages contained in each memory big page is represented by PMD_NR, then the second identifier of the memory big page where the page fault page is located = vmf.pg_off / PMD_NR, and the order of the page fault page in the memory big page = vmf.pg_off - [vmf.pg_off / PMD_NR] × PMD_NR, where [vmf.pg_off / PMD_NR] represents vmf.pg_off / PMD_NR rounded down.

[0149] For example, if the total number of Pages in the memory space allocated by the mmap interface under the management of vma is 20, and the first identifier of the page faulty page in all pages is vmf.pg_off, which is 10, and the number of pages contained in the first memory page is PMD_NR, the number of pages contained in the second memory page is PMD_NR, the number of pages contained in the third memory page is PMD_NR, the number of pages contained in the fourth memory page is PMD_NR, and the number of pages contained in the fifth memory page is PMD_NR, then the second identifier of the memory page containing the page faulty page is 10 / 4, the quotient of which is 2.5. Rounding down from 2.5 gives 2, so the second identifier of the memory page containing the page faulty page is 2. Since the memory pages containing the page faulty page are counted starting from 0, the second identifier of the memory page containing the page faulty page being 2 indicates that the memory page containing the page faulty page belongs to the third memory page in the memory page array.

[0150] Furthermore, vmf.pg_off / PMD_NR = 10 / 4 = 2.5, [vmf.pg_off / PMD_NR] = 2, [vmf.pg_off / PMD_NR] × PMD_NR = 2 × 4 = 8, vmf.pg_off - [vmf.pg_off / PMD_NR] × PMD_NR = 10 - 8 = 2. That is, the page faulty page is the second page in the memory big page order, which means that the page faulty page is the second page in the third memory big page.

[0151] Step B: Based on the second identifier and the order, obtain the pointer to the Page structure of the missing page.

[0152] In step B, the position of the memory page containing the page faulty page in the memory page array can be determined by the second identifier, and the page number of the page faulty page in the memory page can be determined by the order. Therefore, based on the second identifier and the order, the pointer of the Page structure of the page faulty page can be determined.

[0153] The Page structure contains the kernel-mode address of the page that is missing.

[0154] In one possible embodiment, after obtaining the pointer to the Page structure of the page faulty page, the obtained pointer is assigned to the vmf parameter, and the file system completes the page fault interruption process.

[0155] After the file system completes the page fault handling process, it sends relational information containing the first correspondence between the kernel-mode address of the page faulty page and the processing process. Based on the user-mode address, the processing process reads the data from the acquired page faulty page, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page faulty page, and the allocated second index, based on the first correspondence represented by the relational information.

[0156] Using the above embodiment, when the size of the pre-allocated memory space is too large and the obtained page fault pages and their corresponding kernel-mode addresses are not contiguous, the second identifier of the memory page containing the page fault page and the order of the page fault page in the memory page can be determined by the first identifier of the page fault page in all pages and the number of pages contained in each memory page, thereby obtaining the pointer to the Page structure of the page fault page.

[0157] In one possible embodiment, step B above can be implemented by step B1.

[0158] Step B1: If the page faulty page is determined to be the first page in the memory superpage based on the order, then based on the second identifier, obtain the pointer to the superpage structure of the memory superpage containing the page faulty page, and use it as the pointer to the Page structure of the page faulty page.

[0159] In step B1, since the kernel address is determined by the starting address and length of the memory space, and the page fault page is the first page in the memory superpage it belongs to, the starting address of the page fault page is the same as the starting address of the memory superpage containing the page fault page. Therefore, the kernel address contained in the superpage structure of the memory superpage containing the page fault page is the same as the kernel address contained in the Page structure of the page fault page. Thus, the pointer to the superpage structure of the memory superpage containing the page fault page can be used as the pointer to the Page structure of the page fault page.

[0160] Using the above embodiment, if the page faulty page is the first page in the memory superpage it resides in, since the kernel address is determined by the starting address and length of the memory space, the kernel address of the page faulty page is the same as the kernel address of the memory superpage in which the page faulty page resides. Therefore, the pointer of the superpage structure of the memory superpage in which the page faulty page resides can be used as the pointer of the Page structure of the page faulty page.

[0161] In one possible embodiment, step B above can be implemented by step B2.

[0162] Step B2: If the order determines that the page faulty page is not the first page in the memory superpage it resides in, then based on the second identifier, obtain the pointer to the superpage structure of the memory superpage where the page faulty page resides, and based on the obtained pointer and the order, calculate the pointer to the Page structure of the page faulty page.

[0163] In step B2, if the page faulty page is not the first page in the memory superpage it resides in, then the pointer to the superpage structure of the memory superpage containing the page faulty page cannot be directly used as the pointer to the Page structure of the page faulty page.

[0164] At this point, it is necessary to determine the order of the page faulty pages in the memory big page, that is, to determine the position offset of the page faulty pages in the memory big page. Based on the pointer of the big page structure of the memory big page where the page faulty page is located and the position offset of the page faulty page in the memory big page, the pointer of the Page structure of the page faulty page can be determined.

[0165] The Page structure contains the kernel-mode address of the page faulted page, and the bigpage structure contains the kernel-mode address of the starting bigpage.

[0166] Using the above embodiments, if the page faulty page is not the first page in the memory superpage it resides in, it means that the pointer to the superpage structure of the memory superpage where the page faulty page resides cannot be directly used as the pointer to the Page structure of the page faulty page. Instead, the pointer to the Page structure of the page faulty page needs to be determined based on the pointer to the superpage structure of the memory superpage where the page faulty page resides and the order of the page faulty page in the memory superpage.

[0167] In one possible embodiment, the pre-allocated memory space includes large pages and small blocks of memory, and the pre-allocated memory space can be obtained through steps C-D.

[0168] Step C: The file system requests and allocates large page memory.

[0169] In step C, the size of the large page memory is the default memory size set by the operating system configured for the electronic device. The size of the large page memory can be 2MB or 1GB. The larger the size of the large page memory, the fewer page faults will occur.

[0170] In one possible embodiment, it is assumed that the first correspondence is represented by the kernel-mode address table and the second correspondence is represented by the user-mode address mapping table. The larger the size of the large page memory, the fewer entries there are in the kernel-mode address table and the user-mode address mapping table, and the less CPU resources are occupied by the kernel-mode address table and the user-mode address mapping table. This helps to improve the efficiency of looking up the kernel-mode address table and the user-mode address mapping table and reduce the occurrence of page faults.

[0171] Furthermore, before the system allocates actual memory space to the file system, the file system requests the allocation of large page memory from the system and establishes the relationship between large page memory and small pages. This allows the allocation of large page memory and the handling of page faults to occur earlier, thereby shortening the memory allocation time.

[0172] The Linux system manages physical memory using the Page structure. During the pre-allocation of large pages, the kernel directly requests the allocation of Pages from the system through the alloc_pages (memory block allocation) method. The Page structure is obtained during the pre-allocation process, which avoids the situation where the Linux system does not immediately allocate Pages when requesting virtual memory from user space in the normal way, further shortening the time consumed by memory allocation.

[0173] In step D, the file system divides the allocated large page memory into multiple smaller memory blocks of a preset size.

[0174] In step D, the multiple memory blocks can be the same size or different sizes. If the memory blocks are different sizes, they can be divided into different groups according to their sizes, and the memory blocks in the same group are the same size.

[0175] For example, suppose there are 10 memory blocks. Memory blocks 1 to 3 are each 1MB in size, memory blocks 4 to 7 are each 2MB in size, and memory blocks 8 to 10 are each 3MB in size. Then, memory blocks 1 to 3 are assigned to the first group, memory blocks 4 to 7 to the second group, and memory blocks 8 to 10 to the third group. If an I / O request requires 2MB of memory, a memory block can be directly obtained from the second group to complete the memory allocation.

[0176] Using the above embodiments, after the file system requests and allocates large page memory, it divides the allocated large page memory into multiple small memory blocks of a preset size. When a certain amount of memory is needed, a suitable small memory block can be directly selected, thereby improving the efficiency of memory allocation.

[0177] See Figure 6 This is a schematic diagram of a pre-allocated memory space provided in an embodiment of the present invention.

[0178] from Figure 6As can be seen, after the file system requests and allocates large page memory, the allocated 12 pages are divided into smaller memory blocks. In the first group of 2 pages, each page receives 6 smaller memory blocks; in the second group of 4 pages, each page receives 4 smaller memory blocks; and in the third group of 8 pages, each page receives 2 smaller memory blocks. Furthermore, gray rectangles represent the head of the linked list, and black rectangles represent the tail of the linked list.

[0179] Specifically, after the file system requests and allocates large page memory from the system, it divides the large page memory into multiple memory blocks of a preset size, and then groups the multiple memory blocks. The memory blocks in the same group have the same memory size, and the memory blocks in the group are linked on a unified linked list for centralized management.

[0180] In one possible embodiment, each memory block corresponds to a description structure, which includes the starting address, size, identifier of the large page memory in which the memory block is located, and the offset value of the memory block within the large page memory.

[0181] Specifically, the starting address of this memory block can also be called its kernel address. The identifier of the large page memory where the memory block resides refers to the index of the large page memory where the memory block resides, and the offset value of the memory block within the large page memory refers to its position within that large page memory.

[0182] After receiving an I / O instruction, the file system uses memory through a description structure. Specifically, the file system retrieves the description structure of the memory block from the management list to which it belongs, obtains the starting address of the memory block corresponding to the description structure, and writes data to the memory space corresponding to that starting address. The kernel module sends the description structure to the processing process through a normal message channel. After receiving the normal message, the processing process parses the description structure, performs address translation, and reads the data according to the obtained user-space address.

[0183] See Figure 7 This is a schematic diagram of a user-mode address determination method provided in an embodiment of the present invention.

[0184] from Figure 7 As can be seen, the first correspondence between the first index, the first kernel address, and the first length can be represented by the kernel-mode address table, and the first correspondence between the second index, the user-mode address, the second kernel address, and the second length can be represented by the user-mode address mapping table. The kernel-mode address table includes 5 entries, each corresponding to a description structure, and one kernel-mode address table corresponds to one entry in the user-mode address mapping table.

[0185] Wherein, the user-mode address to be accessed = the user-mode address obtained by the processing process calling the mmap interface + the memory size of the large page × the second identifier of the large page where the small memory block is located + the offset value of the small memory block within the large page.

[0186] Corresponding to the aforementioned memory access method, this embodiment of the invention also provides an electronic device. The electronic device includes a file system in kernel mode and a processing process in user mode; the file system maintains a first correspondence between a first index and a first kernel address, where the first kernel address is the kernel address of a pre-allocated memory space; the processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address; the user-mode address and the second kernel address with the second correspondence indicate the same memory space; for the same first kernel address and second kernel address, the first kernel address and the second kernel address respectively correspond to the first index and the second index, and a third correspondence exists between the first index and the second index; see also... Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device also includes a memory 801, a transceiver 802, and a processor 803.

[0187] Memory 801 is used to store computer programs; transceiver 802 is used to send and receive data under the control of processor 803; processor 803 is used to read the computer program in memory 801 and perform the following operations:

[0188] Upon receiving an I / O instruction from the application for the location to be accessed, the file system sends an I / O request to the processing process. The I / O request carries the target kernel address of the location to be accessed and a target first index. The target first index is a first index that has a first correspondence with the first kernel address in the memory space where the target kernel address is located.

[0189] The processing process determines the target second index corresponding to the target first index based on the third correspondence, and determines the target user-space address and target second kernel address corresponding to the target second index based on the second correspondence; determines the user-space address to be accessed based on the target user-space address, target second kernel address, and target kernel address; and accesses memory based on the determined user-space address.

[0190] Application software is a collection of application programs and their related documents or other dependencies.

[0191] Using the above embodiment, after receiving the I / O instruction sent by the application for the location to be accessed, the file system sends an I / O request to the processing process. The I / O request carries the target kernel address of the location to be accessed and the target first index. Since the same first kernel address and second kernel address correspond to the first index and the second index respectively, and there is a third correspondence between the first index and the second index, the processing process can determine the target second index corresponding to the target first index based on the third correspondence.

[0192] Furthermore, since the processing process maintains a second correspondence among the second index, user-mode address, and second kernel address, the processing process in user mode can determine the target user-mode address and target second kernel address corresponding to the target second index based on this second correspondence. Based on the determined target user-mode address, target second kernel address, and target kernel address, the processing process can determine the user-mode address to be accessed. Because the user-mode address and second kernel address, which have a second correspondence, indicate the same memory space, the processing process can successfully access memory based on the determined user-mode address.

[0193] Since the processing process can directly access memory based on the determined user-mode address during memory access, it does not need to lock the entire page, thus avoiding the inability to read or write data to the page during the locking period, thereby improving the efficiency of memory access.

[0194] Among them, Figure 8 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits together, represented by one or more processors (processor 803) and memory (memory 801). The bus architecture can also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides an interface. The transceiver 802 can be multiple elements, including transmitters and receivers, providing a unit for communicating with various other devices over transmission media, including wireless channels, wired channels, optical fibers, etc. The processor 803 is responsible for managing the bus architecture and general processing, and the memory 801 can store data used by the processor 803 during operation.

[0195] The processor 803 can be a central processing unit (CPU), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or a complex programmable logic device (CPLD). The processor can also adopt a multi-core architecture.

[0196] It should be noted that the electronic device provided in this embodiment of the invention can implement all the method steps implemented in the above method embodiment and achieve the same technical effect. Therefore, the parts that are the same as those in the method embodiment will not be described in detail here.

[0197] In one possible embodiment, the second correspondence is determined in the following manner:

[0198] The file system registers miscellaneous device files and sends a start mapping message to the processing process;

[0199] Upon receiving the start mapping message, the processing process opens the miscellaneous device file and calls the mmap interface to send the size of the pre-allocated memory space to the file system.

[0200] The file system uses the mmap interface to send a user-space address indicating the size of the memory space to the processing process.

[0201] The processing process records the received user-mode address and triggers a page fault based on that user-mode address;

[0202] When the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space and sends the first correspondence information containing the kernel-mode address of the page faulty page to the processing process.

[0203] The processing process reads the data from the acquired page fault page based on the user-mode address, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page fault page, and the allocated second index based on the first correspondence represented by the relation information.

[0204] In the above embodiment, the file system registers a miscellaneous device file and sends a start mapping message to the processing process. Since the miscellaneous device file is an interactive file between the file system and the processing process, when the processing process receives the start mapping message, it opens the miscellaneous device file. The file system can allocate a user-space address equal to the size of the pre-allocated memory space sent by the processing process. Because the file system only provides the user-space address to the processing process but does not allocate actual memory space for that user-space address, the processing process will trigger a page fault when accessing memory based on that user-space address. When the file system determines that a page fault has occurred, it allocates actual memory space for that user-space address. When the processing process successfully reads the data from the acquired page fault page, it creates a second correspondence between the received user-space address, the kernel-space address of the page fault page, and the second index.

[0205] In one possible embodiment, the page in memory is contained within a large memory page in a pre-allocated memory space. The size of the large memory page is the memory size preset by the operating system configured for the electronic device. The kernel-mode address of the page fault page is contained in a Page structure, and the pointer to the Page structure of the page fault page is obtained in the following way:

[0206] The file system determines the second identifier of the memory page containing the page fault and the order of the page fault within the memory page based on the first identifier of the page fault in all pages and the number of pages contained in each memory page.

[0207] The file system obtains a pointer to the Page structure of the page that is missing, based on the second identifier and the order.

[0208] Using the above embodiment, when the size of the pre-allocated memory space is too large and the obtained page fault pages and their corresponding kernel-mode addresses are not contiguous, the second identifier of the memory page containing the page fault page and the order of the page fault page in the memory page can be determined by the first identifier of the page fault page in all pages and the number of pages contained in each memory page, thereby obtaining the pointer to the Page structure of the page fault page.

[0209] In one possible embodiment, the file system obtains a pointer to the Page structure of the page-faulting page based on a second identifier and a sequence, including:

[0210] If the page fault is determined to be the first page in the memory superpage based on the order, the file system obtains a pointer to the superpage structure of the memory superpage containing the page fault based on the second identifier, and uses this pointer as a pointer to the Page structure of the page fault; the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0211] Using the above embodiment, if the page faulty page is the first page in the memory superpage it resides in, since the kernel address is determined by the starting address and length of the memory space, the kernel address of the page faulty page is the same as the kernel address of the memory superpage in which the page faulty page resides. Therefore, the pointer of the superpage structure of the memory superpage in which the page faulty page resides can be used as the pointer of the Page structure of the page faulty page.

[0212] In one possible embodiment, the file system obtains a pointer to the Page structure of the page-faulting page based on a second identifier and a sequence, including:

[0213] If the order determines that the page faulty page is not the first page in the memory superpage it belongs to, the file system obtains a pointer to the superpage structure of the memory superpage containing the page faulty page based on the second identifier. Based on the obtained pointer and the order, it calculates a pointer to the Page structure of the page faulty page. The superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0214] Using the above embodiments, if the page faulty page is not the first page in the memory superpage it resides in, it means that the pointer to the superpage structure of the memory superpage where the page faulty page resides cannot be directly used as the pointer to the Page structure of the page faulty page. Instead, the pointer to the Page structure of the page faulty page needs to be determined based on the pointer to the superpage structure of the memory superpage where the page faulty page resides and the order of the page faulty page in the memory superpage.

[0215] In one possible embodiment, the pre-allocated memory space includes large pages of memory and small blocks of memory, and is obtained by:

[0216] The file system requests allocation of large page memory; the size of the large page memory is the default memory size of the operating system configured for the electronic device.

[0217] The file system divides the allocated large page memory into multiple smaller memory blocks of a preset size.

[0218] Using the above embodiments, after the file system requests and allocates large page memory, it divides the allocated large page memory into multiple small memory blocks of a preset size. When a certain amount of memory is needed, a suitable small memory block can be directly selected, thereby improving the efficiency of memory allocation.

[0219] In one possible embodiment, each memory block corresponds to a description structure, which includes the starting address, size, identifier of the large page memory in which the memory block is located, and the offset value of the memory block within the large page memory.

[0220] By using the above embodiments, since the description structure includes the starting address, size, identifier of the large page memory in which the memory block is located, and the offset value of the memory block within the large page memory, the relevant information of the memory block can be transmitted between kernel mode and user mode through the description structure.

[0221] Corresponding to the aforementioned memory access method, this embodiment of the invention also provides a memory access device applied to an electronic device. The electronic device includes a file system in kernel mode and a processing process in user mode. The file system maintains a first correspondence between a first index and a first kernel address, where the first kernel address is the kernel address of a pre-allocated memory space. The processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address. A user-mode address and a second kernel address with a second correspondence indicate the same memory space. For the same first kernel address and second kernel address, the first kernel address and the second kernel address correspond to the first index and the second index, respectively, and a third correspondence exists between the first index and the second index. (See also...) Figure 9 This is a schematic diagram of a memory access device provided in an embodiment of this application. The device includes:

[0222] The request sending module 901 is used to send an I / O request to the processing process after receiving an I / O instruction sent by the application for the location to be accessed; wherein the I / O request carries the target kernel address of the location to be accessed and the target first index, the target first index being: a first index that has a first correspondence with the first kernel address in the memory space where the target kernel address is located;

[0223] The memory access module 902 is used to process the process to determine the target second index corresponding to the target first index according to the third correspondence, and to determine the target user-mode address and the target second kernel address corresponding to the target second index according to the second correspondence; to determine the user-mode address to be accessed according to the target user-mode address, the target second kernel address and the target kernel address; and to access memory according to the determined user-mode address.

[0224] Using the above embodiment, after receiving the I / O instruction sent by the application for the location to be accessed, the file system sends an I / O request to the processing process. The I / O request carries the target kernel address of the location to be accessed and the target first index. Since the same first kernel address and second kernel address correspond to the first index and the second index respectively, and there is a third correspondence between the first index and the second index, the processing process can determine the target second index corresponding to the target first index based on the third correspondence.

[0225] Furthermore, since the processing process maintains a second correspondence among the second index, user-mode address, and second kernel address, the processing process in user mode can determine the target user-mode address and target second kernel address corresponding to the target second index based on this second correspondence. Based on the determined target user-mode address, target second kernel address, and target kernel address, the processing process can determine the user-mode address to be accessed. Because the user-mode address and second kernel address, which have a second correspondence, indicate the same memory space, the processing process can successfully access memory based on the determined user-mode address.

[0226] Since the processing process can directly access memory based on the determined user-mode address during memory access, it does not need to lock the entire page, thus avoiding the inability to read or write data to the page during the locking period, thereby improving the efficiency of memory access.

[0227] In one possible embodiment, the second correspondence is determined in the following manner:

[0228] The file system registers miscellaneous device files and sends a start mapping message to the processing process;

[0229] Upon receiving the start mapping message, the processing process opens the miscellaneous device file and calls the mmap interface to send the size of the pre-allocated memory space to the file system.

[0230] The file system uses the mmap interface to send a user-space address indicating the size of the memory space to the processing process.

[0231] The processing process records the received user-mode address and triggers a page fault based on that user-mode address;

[0232] When the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space and sends the first correspondence information containing the kernel-mode address of the page faulty page to the processing process.

[0233] The processing process reads the data in the acquired page fault page based on the user-mode address, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page fault page, and the allocated second index based on the first correspondence represented by the relation information.

[0234] In the above embodiment, the file system registers a miscellaneous device file and sends a start mapping message to the processing process. Since the miscellaneous device file is an interactive file between the file system and the processing process, when the processing process receives the start mapping message, it opens the miscellaneous device file. The file system can allocate a user-space address equal to the size of the pre-allocated memory space sent by the processing process. Because the file system only provides the user-space address to the processing process but does not allocate actual memory space for that user-space address, the processing process will trigger a page fault when accessing memory based on that user-space address. When the file system determines that a page fault has occurred, it allocates actual memory space for that user-space address. When the processing process successfully reads the data from the acquired page fault page, it creates a second correspondence between the received user-space address, the kernel-space address of the page fault page, and the second index.

[0235] In one possible embodiment, the page in memory is contained within a large memory page in a pre-allocated memory space. The size of the large memory page is the memory size preset by the operating system configured for the electronic device. The kernel-mode address of the page fault page is contained in a Page structure, and the pointer to the Page structure of the page fault page is obtained in the following way:

[0236] Based on the first identifier of the page faulting page among all pages and the number of pages contained in each memory superpage, determine the second identifier of the memory superpage containing the page faulting page and the order of the page faulting page in the memory superpage;

[0237] Based on the second identifier and the order, obtain the pointer to the Page structure of the missing page.

[0238] Using the above embodiment, when the size of the pre-allocated memory space is too large and the obtained page fault pages and their corresponding kernel-mode addresses are not contiguous, the second identifier of the memory page containing the page fault page and the order of the page fault page in the memory page can be determined by the first identifier of the page fault page in all pages and the number of pages contained in each memory page, thereby obtaining the pointer to the Page structure of the page fault page.

[0239] In one possible embodiment, obtaining a pointer to the Page structure of the missing page based on the second identifier and the order includes:

[0240] If the page fault is determined to be the first page in the memory superpage it belongs to based on the order, then based on the second identifier, the pointer to the superpage structure of the memory superpage containing the page fault is obtained, and used as the pointer to the Page structure of the page fault; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0241] Using the above embodiment, if the page faulty page is the first page in the memory superpage it resides in, since the kernel address is determined by the starting address and length of the memory space, the kernel address of the page faulty page is the same as the kernel address of the memory superpage in which the page faulty page resides. Therefore, the pointer of the superpage structure of the memory superpage in which the page faulty page resides can be used as the pointer of the Page structure of the page faulty page.

[0242] In one possible embodiment, obtaining a pointer to the Page structure of the missing page based on the second identifier and the order includes:

[0243] If the order determines that the page faulty page is not the first page in the memory superpage it belongs to, then based on the second identifier, obtain the pointer to the superpage structure of the memory superpage where the page faulty page is located. Based on the obtained pointer and the order, calculate the pointer to the Page structure of the page faulty page; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

[0244] Using the above embodiments, if the page faulty page is not the first page in the memory superpage it resides in, it means that the pointer to the superpage structure of the memory superpage where the page faulty page resides cannot be directly used as the pointer to the Page structure of the page faulty page. Instead, the pointer to the Page structure of the page faulty page needs to be determined based on the pointer to the superpage structure of the memory superpage where the page faulty page resides and the order of the page faulty page in the memory superpage.

[0245] In one possible embodiment, the pre-allocated memory space includes large pages of memory and small blocks of memory, and is obtained by:

[0246] The file system requests allocation of large page memory; the size of the large page memory is the default memory size of the operating system configured for the electronic device.

[0247] The file system divides the allocated large page memory into multiple smaller memory blocks of a preset size.

[0248] Using the above embodiments, after the file system requests and allocates large page memory, it divides the allocated large page memory into multiple small memory blocks of a preset size. When a certain amount of memory is needed, a suitable small memory block can be directly selected, thereby improving the efficiency of memory allocation.

[0249] In one possible embodiment, each memory block corresponds to a description structure, which includes the starting address, size, identifier of the large page memory in which the memory block is located, and the offset value of the memory block within the large page memory.

[0250] By using the above embodiments, since the description structure includes the starting address, size, identifier of the large page memory in which the memory block is located, and the offset value of the memory block within the large page memory, the relevant information of the memory block can be transmitted between kernel mode and user mode through the description structure.

[0251] In another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements the steps of any of the above memory access methods.

[0252] Using the above embodiment, after receiving the I / O instruction sent by the application for the location to be accessed, the file system sends an I / O request to the processing process. The I / O request carries the target kernel address of the location to be accessed and the target first index. Since the same first kernel address and second kernel address correspond to the first index and the second index respectively, and there is a third correspondence between the first index and the second index, the processing process can determine the target second index corresponding to the target first index based on the third correspondence.

[0253] Furthermore, since the processing process maintains a second correspondence among the second index, user-mode address, and second kernel address, the processing process in user mode can determine the target user-mode address and target second kernel address corresponding to the target second index based on this second correspondence. Based on the determined target user-mode address, target second kernel address, and target kernel address, the processing process can determine the user-mode address to be accessed. Because the user-mode address and second kernel address, which have a second correspondence, indicate the same memory space, the processing process can successfully access memory based on the determined user-mode address.

[0254] Since the processing process can directly access memory based on the determined user-mode address during memory access, it does not need to lock the entire page, thus avoiding the inability to read or write data to the page during the locking period, thereby improving the efficiency of memory access.

[0255] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the memory access methods described above.

[0256] Using the above embodiment, after receiving the I / O instruction sent by the application for the location to be accessed, the file system sends an I / O request to the processing process. The I / O request carries the target kernel address of the location to be accessed and the target first index. Since the same first kernel address and second kernel address correspond to the first index and the second index respectively, and there is a third correspondence between the first index and the second index, the processing process can determine the target second index corresponding to the target first index based on the third correspondence.

[0257] Furthermore, since the processing process maintains a second correspondence among the second index, user-mode address, and second kernel address, the processing process in user mode can determine the target user-mode address and target second kernel address corresponding to the target second index based on this second correspondence. Based on the determined target user-mode address, target second kernel address, and target kernel address, the processing process can determine the user-mode address to be accessed. Because the user-mode address and second kernel address, which have a second correspondence, indicate the same memory space, the processing process can successfully access memory based on the determined user-mode address.

[0258] Since the processing process can directly access memory based on the determined user-mode address during memory access, it does not need to lock the entire page, thus avoiding the inability to read or write data to the page during the locking period, thereby improving the efficiency of memory access.

[0259] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0260] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0261] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments for electronic devices, apparatuses, and storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0262] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A memory access method, characterized in that, An electronic device is applied to an electronic device, the electronic device including a file system in kernel mode and a processing process in user mode; the file system maintains a first correspondence between a first index and a first kernel address, the first kernel address being the address of pre-allocated memory space in kernel mode; the processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address; the user-mode address is the address of pre-allocated memory space in user mode, the second kernel address is the address of pre-allocated memory space in kernel mode, the user-mode address and the second kernel address with the second correspondence indicate the same memory space, for the first kernel address and the second kernel address that are the same as the first kernel address, the first kernel address and the second kernel address correspond to the first index and the second index respectively, and there is a third correspondence between the first index and the second index, the method including: Upon receiving an input / output I / O instruction from an application for a location to be accessed, the file system sends an I / O request to the processing process; wherein, the I / O request carries the target kernel address of the location to be accessed and a target first index, the target first index being a first index that has the first correspondence with the first kernel address in the memory space where the target kernel address is located; The processing process determines the target second index corresponding to the target first index according to the third correspondence, and determines the target user-mode address and target second kernel address corresponding to the target second index according to the second correspondence; determines the user-mode address to be accessed according to the target user-mode address, target second kernel address and target kernel address; and accesses memory according to the determined user-mode address.

2. The method according to claim 1, characterized in that, The second correspondence is determined in the following manner: The file system registers miscellaneous device files and sends a start mapping message to the processing process; Upon receiving the start mapping message, the processing process opens the miscellaneous device file and calls the memory mapping mmap interface to send the size of the pre-allocated memory space to the file system. The file system feeds back the size of the indicated memory space to the processing process through the mmap interface, which is the user-space address of the memory size; The processing process records the received user-mode address and triggers a page fault based on the user-mode address; When the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space and sends relationship information containing the first correspondence between the kernel-mode address of the page faulty page to the processing process. The processing process reads the data in the acquired page fault page based on the user-mode address, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page fault page, and the allocated second index based on the first correspondence represented by the relationship information. The kernel-mode address of the page fault page is the second kernel address in the created second correspondence.

3. The method according to claim 2, characterized in that, The page in memory is contained within a large memory page in the pre-allocated memory space. The size of the large memory page is the preset memory size of the operating system configured for the electronic device. The kernel-mode address of the page fault page is contained in the Page structure. The pointer to the Page structure of the page fault page is obtained in the following way: Based on the first identifier of the page fault page among all pages and the number of pages contained in each memory page, the second identifier of the memory page containing the page fault page and the order of the page fault page in the memory page are determined. Based on the second identifier and the order, obtain the pointer to the Page structure of the missing page.

4. The method according to claim 3, characterized in that, The step of obtaining a pointer to the Page structure of the missing page based on the second identifier and the order includes: If the page faulty page is determined to be the first page in the memory superpage according to the order, then based on the second identifier, a pointer to the superpage structure of the memory superpage containing the page faulty page is obtained as a pointer to the Page structure of the page faulty page; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

5. The method according to claim 3, characterized in that, The step of obtaining a pointer to the Page structure of the missing page based on the second identifier and the order includes: If it is determined according to the order that the page fault page is not the first page in the memory superpage it belongs to, then based on the second identifier, a pointer to the superpage structure of the memory superpage where the page fault page belongs is obtained, and based on the obtained pointer and the order, a pointer to the Page structure of the page fault page is calculated; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

6. The method according to claim 1, characterized in that, The pre-allocated memory space includes large pages and small blocks of memory, and is obtained through the following methods: The file system requests the allocation of large page memory; wherein the size of the large page memory is the preset memory size of the operating system configured in the electronic device; The file system divides the allocated large page memory into multiple smaller memory blocks of a preset size.

7. The method according to claim 6, characterized in that, Each memory block corresponds to a description structure, which includes the starting address, size, identifier of the large page memory in which it is located, and the offset value of the memory block within the large page memory.

8. An electronic device, characterized in that, The electronic device includes a file system in kernel mode and a processing process in user mode. The file system maintains a first correspondence between a first index and a first kernel address, where the first kernel address is the address of pre-allocated memory space in kernel mode. The processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address. The user-mode address is the address of pre-allocated memory space in user mode, and the second kernel address is the address of pre-allocated memory space in kernel mode. User-mode addresses and second kernel addresses with the second correspondence indicate the same memory space. For a first kernel address and a second kernel address that is the same as the first kernel address, the first kernel address and the second kernel address correspond to a first index and a second index, respectively. A third correspondence exists between the first index and the second index. The electronic device also includes a memory, a transceiver, and a processor. Memory, used to store computer programs; The transceiver is used to send and receive data under the control of the processor; the processor is used to read the computer program in the memory and perform the following operations: Upon receiving an input / output I / O instruction from an application for a location to be accessed, the file system sends an I / O request to the processing process; wherein, the I / O request carries the target kernel address of the location to be accessed and a target first index, the target first index being a first index that has the first correspondence with the first kernel address in the memory space where the target kernel address is located; The processing process determines the target second index corresponding to the target first index according to the third correspondence, and determines the target user-mode address and target second kernel address corresponding to the target second index according to the second correspondence; determines the user-mode address to be accessed according to the target user-mode address, target second kernel address and target kernel address; and accesses memory according to the determined user-mode address.

9. The electronic device according to claim 8, characterized in that, The second correspondence is determined in the following manner: The file system registers miscellaneous device files and sends a start mapping message to the processing process; Upon receiving the start mapping message, the processing process opens the miscellaneous device file and calls the memory mapping mmap interface to send the size of the pre-allocated memory space to the file system. The file system feeds back the size of the indicated memory space to the processing process through the mmap interface, which is the user-space address of the memory size; The processing process records the received user-mode address and triggers a page fault based on the user-mode address; When the file system determines that a page fault has occurred, it retrieves the page faulty page from the pre-allocated memory space and sends relationship information containing the first correspondence between the kernel-mode address of the page faulty page to the processing process. The processing process reads the data in the acquired page fault page based on the user-mode address, allocates a second index, and creates a second correspondence between the received user-mode address, the kernel-mode address of the page fault page, and the allocated second index based on the first correspondence represented by the relationship information. The kernel-mode address of the page fault page is the second kernel address in the created second correspondence.

10. The electronic device according to claim 9, characterized in that, The page in memory is contained within a large memory page in the pre-allocated memory space. The size of the large memory page is the preset memory size of the operating system configured for the electronic device. The kernel-mode address of the page fault page is contained in the Page structure. The pointer to the Page structure of the page fault page is obtained in the following way: The file system determines the second identifier of the memory page containing the page fault and the order of the page fault in the memory page based on the first identifier of the page fault in all pages and the number of pages contained in each memory page. The file system obtains a pointer to the Page structure of the missing page based on the second identifier and the order.

11. The electronic device according to claim 10, characterized in that, The file system obtains a pointer to the Page structure of the missing page based on the second identifier and the order, including: If the page faulty page is determined to be the first page in the memory superpage according to the order, the file system obtains a pointer to the superpage structure of the memory superpage containing the page faulty page based on the second identifier, and uses it as a pointer to the Page structure of the page faulty page; wherein the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

12. The electronic device according to claim 10, characterized in that, The file system obtains a pointer to the Page structure of the missing page based on the second identifier and the order, including: If it is determined according to the order that the page fault page is not the first page in the memory superpage it is in, then the file system obtains a pointer to the superpage structure of the memory superpage in which the page fault page is located based on the second identifier, and calculates a pointer to the Page structure of the page fault page based on the obtained pointer and the order; wherein, the superpage structure contains the kernel-mode address of the starting point of the memory superpage.

13. The electronic device according to claim 8, characterized in that, The pre-allocated memory space includes large pages and small blocks of memory, and is obtained through the following methods: The file system requests the allocation of large page memory; wherein the size of the large page memory is the preset memory size of the operating system configured in the electronic device; The file system divides the allocated large page memory into multiple smaller memory blocks of a preset size.

14. The electronic device according to claim 13, characterized in that, Each memory block corresponds to a description structure, which includes the starting address, size, identifier of the large page memory in which it is located, and the offset value of the memory block within the large page memory.

15. A memory access device, characterized in that, An electronic device is applied to an electronic device, the electronic device including a file system in kernel mode and a processing process in user mode; the file system maintains a first correspondence between a first index and a first kernel address, the first kernel address being the address of pre-allocated memory space in kernel mode; the processing process maintains a second correspondence between a second index, a user-mode address, and a second kernel address; the user-mode address is the address of pre-allocated memory space in user mode, the second kernel address is the address of pre-allocated memory space in kernel mode, the user-mode address and the second kernel address with the second correspondence indicate the same memory space, for the first kernel address and the second kernel address that are the same as the first kernel address, the first kernel address and the second kernel address respectively correspond to the first index and the second index, and there is a third correspondence between the first index and the second index, the device comprising: The request sending module is used to send an I / O request to the processing process after receiving an input / output I / O instruction sent by the application for the location to be accessed; wherein the I / O request carries the target kernel address of the location to be accessed and a target first index, the target first index being a first index that has the first correspondence with the first kernel address in the memory space where the target kernel address is located; The memory access module is used by the processing process to determine the target second index corresponding to the target first index according to the third correspondence, and to determine the target user-mode address and the target second kernel address corresponding to the target second index according to the second correspondence; to determine the user-mode address to be accessed according to the target user-mode address, the target second kernel address and the target kernel address; and to access memory according to the determined user-mode address.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-7.

Citation Information

Patent Citations

  • Memory mapping method and memory mapping module

    CN103257936A

  • Address mapping method and device of shared memory

    CN107729159A