Page table sharing method and page fault exception processing method
By allocating shadow virtual memory regions to processes to share page tables, the problem of poor scalability caused by memory reservation in the ultra-large page cache method is solved, and page table sharing with high universality and high coverage is achieved, reducing memory costs in cloud computing scenarios.
Patent Information
- Application Number
- CN202311396538.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-25
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2043-10-25
AI Technical Summary
In existing technologies, the ultra-large page caching method requires memory to be reserved in advance, resulting in poor memory scalability, low universality of page table sharing, low coverage, and low efficiency of the sharing design, making it unsuitable for large-scale application in cloud environments.
By allocating shadow virtual memory regions to processes and sharing target page tables, memory reservation in advance is avoided, the location of shared page tables is simplified, and coverage and universality are improved.
It reduces the page table overhead of shared memory, improves the universality and coverage of page table sharing, and significantly reduces memory costs, especially in cloud computing scenarios.
Smart Images

Figure CN119883956B_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification relate to the field of computer technology, and in particular to a page table sharing method. Background Technology
[0002] With the development of computer technology, page table sharing has gradually become a research focus in order to save on the page table overhead of the operating system. A page table is a special data structure that records the correspondence between pages and page frames. Page tables are the foundation for non-contiguous memory allocation, enabling the translation from logical addresses to physical addresses.
[0003] Currently, Huge Translation Lookaside Buffers (HLBs) are commonly used to save page table overhead and support page table sharing. However, the use of HLBs requires pre-reserving memory, which cannot be reclaimed for use by other applications, significantly impacting memory scalability and resulting in low universality of page table sharing. Therefore, a more universally applicable page table sharing method is urgently needed. Summary of the Invention
[0004] In view of this, embodiments of this specification provide a page table sharing method. One or more embodiments of this specification also relate to a page fault handling method, a page table sharing device, a page fault handling apparatus, a computing device, a computer-readable storage medium, and a computer program, to address the technical deficiencies existing in the prior art.
[0005] According to a first aspect of the embodiments of this specification, a page table sharing method is provided, comprising:
[0006] In response to the memory access request from the first process, allocate multiple virtual memory regions for the first process;
[0007] For a target virtual memory region among multiple virtual memory regions, a shadow virtual memory region is allocated, wherein the shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the target virtual memory region;
[0008] Determine the target shared page table corresponding to the shadow virtual memory region.
[0009] According to a second aspect of the embodiments of this specification, a page fault handling method is provided, comprising:
[0010] In response to a page fault exception triggered by the first process during memory access, the abnormal virtual memory region where the page fault occurred is identified.
[0011] Locate the shadow virtual memory region allocated for the abnormal virtual memory region, and obtain the target shared page table corresponding to the shadow virtual memory region. The shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the abnormal virtual memory region.
[0012] Use the target shared page table to map physical memory to the virtual memory of the first process.
[0013] According to a third aspect of the embodiments of this specification, a page table sharing device is provided, comprising:
[0014] The first allocation module is configured to allocate multiple virtual memory regions for the first process in response to the first process's memory access request;
[0015] The second allocation module is configured to allocate a shadow virtual memory region for a target virtual memory region in multiple virtual memory regions, wherein the shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the target virtual memory region.
[0016] The first determining module is configured to determine the target shared page table corresponding to the shadow virtual memory region.
[0017] According to a fourth aspect of the embodiments of this specification, a page fault handling apparatus is provided, comprising:
[0018] The second determination module is configured to determine the abnormal virtual memory region where the page fault occurred in response to a page fault information triggered by the first process during memory access.
[0019] The lookup module is configured to look up the shadow virtual memory region allocated for the abnormal virtual memory region and obtain the target shared page table corresponding to the shadow virtual memory region. The shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the abnormal virtual memory region.
[0020] The mapping module is configured to map physical memory to the virtual memory of the first process using the target shared page table.
[0021] According to a fifth aspect of the embodiments of this specification, a computing device is provided, comprising:
[0022] Memory and processor;
[0023] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the method provided by the first aspect or the second method described above.
[0024] According to a sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of the method provided in the first aspect or the second method described above.
[0025] According to a seventh aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the method provided in the first aspect or the second method described above.
[0026] This specification provides a page table sharing method according to one embodiment. In response to a memory access request from a first process, it allocates multiple virtual memory regions for the first process; for a target virtual memory region among the multiple virtual memory regions, it allocates a shadow virtual memory region, wherein the shadow virtual memory region is used to share a virtual memory region of a second process with the same attributes as the target virtual memory region; and it determines the target shared page table corresponding to the shadow virtual memory region. By introducing page table sharing into ordinary shared memory, page table sharing functionality can be used by processes without pre-reserving memory, improving the universality of page table sharing. By allocating multiple virtual memory regions to the first process, the page table sharing coverage is improved, and the introduction of the shadow virtual memory region simplifies the location of shared page tables and reduces the page table overhead of shared memory. Attached Figure Description
[0027] Figure 1 This is a flowchart of a page table sharing method;
[0028] Figure 2 This is an architecture diagram of a page table sharing system provided in one embodiment of this specification;
[0029] Figure 3 This is an architecture diagram of another page table sharing system provided in one embodiment of this specification;
[0030] Figure 4 This is a flowchart illustrating a page table sharing method provided in one embodiment of this specification;
[0031] Figure 5 This is a flowchart illustrating a page fault handling method provided in one embodiment of this specification;
[0032] Figure 6 This is a flowchart illustrating the processing procedure of a page table sharing method provided in one embodiment of this specification;
[0033] Figure 7 This is a schematic diagram of a page table sharing device provided in one embodiment of this specification;
[0034] Figure 8This is a schematic diagram of the structure of a page fault handling device provided in one embodiment of this specification;
[0035] Figure 9 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0036] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0037] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0038] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0039] Furthermore, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0040] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0041] TLB: Translation Lookaside Buffer (TLB), also known as page table cache, is mainly used to accelerate the translation from virtual address to physical address and reduce memory read operations by the core processor (CPU).
[0042] Virtual memory areas: A process's virtual address space is managed in virtual memory areas (VMAs), which include the code segment virtual memory area and the data segment virtual memory area.
[0043] 4K page: A management unit used to manage various types of data in the operating system.
[0044] Page Table Entry (PTE): A page table entry describes the physical address and some attribute information of a page frame in the page table. Each process has its own page table, and each page table entry corresponds to a memory page frame.
[0045] Page Middle Directory (PMD): Each PMD contains four page table entries, used to index larger memory areas. The size of the PMD depends on the processor architecture and operating system implementation.
[0046] User mode: User mode is the basic state in which a process runs within the operating system. In user mode, a process can only access resources it owns, and the operations it performs are restricted by the operating system. In user mode, a process cannot access kernel data structures, nor can it execute kernel code.
[0047] Kernel mode: Kernel mode is the privileged execution mode in an operating system, and only the kernel can be in this state. In kernel mode, the operating system can access and modify all system resources, including hardware devices and memory data structures. In kernel mode, the operating system can execute kernel code, thereby controlling and managing the system's operation.
[0048] Currently, operating systems already employ methods to reduce page table overhead by using very large page caches, and this method also supports page table sharing. See also Figure 1 , Figure 1A flowchart of a page table sharing method is shown. The page table sharing of the massive page cache (MPCache) is based on the MPCache design and requires pre-reserving memory before use. Specifically, the MPCache is set up and memory is reserved in user space, and a MPCache memory pool is set up in kernel space. When an application accesses memory in kernel space from user space, a page fault occurs. The application finds the reactive mapping data structure `i_mmap` through the virtual memory region, traverses all relevant virtual memory regions, and if a page table has already been allocated at the corresponding location in any virtual memory region, that page table is used directly; otherwise, a new page table is allocated. Figure 1 As shown, when a page fault occurs, page tables at all levels and the target page are allocated. Further checks are made to determine if the addresses at both ends of the virtual memory region are 1GB aligned: if not, a new intermediate page table is allocated to the massive page cache pool; if so, the virtual memory regions pointing to the same file are traversed to see if an intermediate page table has already been allocated: if not, a new intermediate page table is allocated to the massive page cache pool; if so, the same intermediate page table is used. It should be noted that 1GB address alignment means aligning the data address to a 1GB boundary. This is a common memory alignment method that can improve memory access efficiency, reduce memory fragmentation, and increase program execution speed.
[0049] However, the above solution has several problems: First, it requires reserving a large amount of memory in advance. This reserved memory cannot be used by other applications, which limits the server's computing power to some extent, significantly impacts memory scalability, and results in a lack of transparency to applications, making it unsuitable for large-scale use in cloud environments. Second, the page table sharing design has flaws. Page table sharing requires the addresses at both ends of the massive page cache to be aligned to 1GB. Currently, the massive page cache implementation does not automatically align virtual memory regions, resulting in low page table sharing coverage. Third, the demand for massive page cache page table sharing is small, making its promotion difficult. The massive page cache itself can support 2MB or 1GB large pages, and the benefits of using massive page cache page table sharing are not significant when large pages are supported. Fourth, massive page cache page table sharing has performance defects. When searching for shared page tables, the massive page cache needs to traverse the virtual memory regions pointing to the same file to see if page intermediate directory page tables have been allocated. This method is inefficient, and for applications with a large number of child processes, the time complexity of this traversal is significant.
[0050] To address the aforementioned issues, this specification proposes a page table sharing method that reduces page table overhead in multi-process applications at the operating system layer and improves application performance. The main idea of this method is to redesign the page table, which was originally private to each parent and child process, into a shared page table at the last level. Specifically, in response to a memory access request from a first process, multiple virtual memory regions are allocated to the first process; for a target virtual memory region among these regions, a shadow virtual memory region is allocated, where the shadow virtual memory region is used to share a virtual memory region of the second process with the same attributes as the target virtual memory region; and the target shared page table corresponding to the shadow virtual memory region is determined. By introducing page table sharing into ordinary shared memory, page table sharing functionality can be used by processes without pre-reserving memory, improving the universality of page table sharing. Allocating multiple virtual memory regions to the first process increases page table sharing coverage, and the introduction of the shadow virtual memory region simplifies shared page table location and reduces page table overhead in shared memory.
[0051] It is worth noting that for applications sharing large amounts of memory, such as databases, where shared memory can reach hundreds of bytes and the number of child processes can reach hundreds, the page table sharing method based on 4K pages provided in the embodiments of this specification can save an average of about 90% of page table overhead, significantly reducing memory costs in cloud computing scenarios. Furthermore, the page table sharing scheme proposed in the embodiments of this specification can minimize the page table overhead of shared memory for applications without the system being aware of it and with minimal application modifications, and it can be used without pre-reserving memory. In addition, the page table sharing method proposed in the embodiments of this specification has been implemented on the Linux kernel and has passed standard testing benchmarks, ensuring the reliability of the scheme.
[0052] This specification provides a page table sharing method, and also relates to a page fault handling method, a page table sharing device, a page fault handling device, a computing device, a computer-readable storage medium, and a computer program, which will be described in detail in the following embodiments.
[0053] See Figure 2 , Figure 2 This specification illustrates an architecture diagram of a page table sharing system according to an embodiment of the present specification. The page table sharing system may include a client 100 and a server 200.
[0054] Client 100 is used to send an access request for the first process to access memory to server 200; server 200 is used to respond to the access request for the first process to access memory by allocating multiple virtual memory regions for the first process; for the target virtual memory region among the multiple virtual memory regions, a shadow virtual memory region is allocated, wherein the shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the target virtual memory region; and the target shared page table corresponding to the shadow virtual memory region is determined.
[0055] The scheme implemented in this specification, by introducing page table sharing into ordinary shared memory, allows processes to use page table sharing functionality without prior memory reservation, thus improving the universality of page table sharing. By allocating multiple virtual memory regions to the first process, the page table sharing coverage is improved. Furthermore, the introduction of shadow virtual memory regions simplifies the location of shared page tables and reduces the page table overhead of shared memory.
[0056] See Figure 3 , Figure 3 This specification illustrates an architecture diagram of another page table sharing system provided in one embodiment. The page table sharing system may include multiple clients 100 and a server 200. The multiple clients 100 can establish communication connections through the server 200. In the page table sharing scenario, the server 200 is used to provide page table sharing services among the multiple clients 100. The multiple clients 100 can act as either senders or receivers, communicating through the server 200.
[0057] Users can interact with server 200 through client 100 to receive data sent by other clients 100, or send data to other clients 100, etc. In a page table sharing scenario, users can publish data streams to server 200 through client 100, and server 200 can determine the target shared page table based on the data stream and push the target shared page table to other clients that have established communication.
[0058] In this system, client 100 and server 200 establish a connection via a network. The network provides the medium for communication between client 100 and server 200. The network can include various connection types, such as wired or wireless communication links or fiber optic cables. Data transmitted by client 100 may need to undergo encoding, transcoding, compression, or other processing before being published to server 200.
[0059] Client 100 can be a browser, an app (application), a web application such as an H5 (HyperText Markup Language 5) application, a lightweight application (also known as a mini-program), or a cloud application. Client 100 can be developed based on the software development kit (SDK) of the corresponding service provided by server 200, such as a real-time communication (RTC) SDK. Client 100 can be deployed on electronic devices and depends on the device or certain apps on the device to run. Electronic devices may have displays and support information browsing, such as personal mobile terminals like mobile phones, tablets, and personal computers. Various other types of applications can also be configured on electronic devices, such as human-computer interaction applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, and social media platform software.
[0060] Server 200 may include servers providing various services, such as servers providing communication services to multiple clients, or servers processing data sent by clients. It should be noted that server 200 can be implemented as a distributed server cluster composed of multiple servers, or as a single server. The server can also be a server in a distributed system, or a server integrated with blockchain. The server can also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.
[0061] It is worth noting that the page table sharing method and page fault handling method provided in the embodiments of this specification are generally executed by the server. However, in other embodiments of this specification, the client may also have similar functions to the server, thereby executing the page table sharing method and page fault handling method provided in the embodiments of this specification. In other embodiments, the page table sharing method and page fault handling method provided in the embodiments of this specification may also be executed jointly by the client and the server.
[0062] See Figure 4 , Figure 4 This specification illustrates a flowchart of a page table sharing method according to an embodiment, which specifically includes the following steps:
[0063] Step 402: In response to the memory access request of the first process, allocate multiple virtual memory regions for the first process.
[0064] In one or more embodiments of this specification, in response to a first process's request to access memory, multiple virtual memory regions can be allocated to the first process.
[0065] Specifically, the first process is the parent process that created the child process. The parent process can send signals to the child process, control the execution of the child process, and obtain the output of the child process. Access requests can be requests for memory access sent by the target application in user space.
[0066] In practical applications, there are various ways to allocate multiple virtual memory regions for the first process, and the specific method chosen depends on the actual situation. This specification does not impose any limitations on this approach. One possible implementation of this specification is to allocate multiple virtual memory regions for the first process using static allocation. Specifically, virtual memory regions are allocated when the first process is created to reduce memory fragmentation and improve memory utilization. Another possible implementation of this specification is to allocate multiple virtual memory regions for the first process using dynamic allocation. Specifically, virtual memory regions are allocated as needed during the first process's runtime to better meet the dynamic requirements of the first process and improve the system's flexibility and adaptability. Yet another possible implementation of this specification is to allocate multiple virtual memory regions for the first process using stack allocation. Specifically, a contiguous block of memory is allocated for the first process as a stack to store the process's local variables and function call information, ensuring the continuity and integrity of the stack and improving access efficiency.
[0067] Step 404: For the target virtual memory region among multiple virtual memory regions, allocate a shadow virtual memory region, wherein the shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the target virtual memory region.
[0068] In one or more embodiments of this specification, after allocating multiple virtual memory regions to the first process in response to the first process's memory access request, a shadow virtual memory area (Shadow VMA) can be further allocated for a target virtual memory region among the multiple virtual memory regions.
[0069] Specifically, the target virtual memory region can be any one of multiple virtual memory regions, or it can be a virtual memory region shared by page tables in multiple virtual memory regions. The second process is a child process of the first process. The child process can send signals to the parent process, request resources from the parent process, and report its status to the parent process.
[0070] In one optional embodiment of this specification, before allocating a shadow virtual memory region for a target virtual memory region among multiple virtual memory regions, the following steps may be included:
[0071] Select the target virtual memory region from multiple virtual memory regions, where the target virtual memory region is a virtual memory region shared by page tables.
[0072] It should be noted that before allocating a shadow virtual memory region to the target virtual memory region, the target virtual memory region can be selected from multiple virtual memory regions to facilitate the allocation of the shadow virtual memory region. Furthermore, to improve the allocation efficiency of the shadow virtual memory region, only the virtual memory region shared by the page tables of multiple virtual memory regions can be used as the target virtual memory region.
[0073] In practical applications, there are various methods for selecting the target virtual memory region with shared page tables from multiple virtual memory regions. The specific method should be chosen based on the actual situation, and the embodiments in this specification do not impose any limitations on this. In one possible implementation of this specification, the target virtual memory region with shared page tables can be manually selected from multiple virtual memory regions. In another possible implementation of this specification, the target virtual memory region can be selected from multiple virtual memory regions based on the page table sharing identifier corresponding to each of the multiple virtual memory regions.
[0074] The scheme described in this specification's embodiments filters out a target virtual memory region from multiple virtual memory regions, wherein the target virtual memory region is a page-table-shared virtual memory region. By filtering out the page-table-shared target virtual memory region from multiple virtual memory regions, redundant allocation of shadow virtual memory regions for virtual memory regions with non-shared page tables is avoided, thus improving the allocation efficiency of shadow virtual memory regions.
[0075] In one optional embodiment of this specification, the above-described method of selecting a target virtual memory region from multiple virtual memory regions may include the following steps:
[0076] Obtain the page table sharing identifiers corresponding to multiple virtual memory regions;
[0077] The target virtual memory region is selected from multiple virtual memory regions based on the page table sharing identifier.
[0078] Specifically, the page table sharing identifier is used to identify whether the corresponding virtual memory region supports page table sharing. For example, the page table sharing identifier for virtual memory region A is "supports page table sharing", and the page table sharing identifier for virtual memory region B is "does not support page table sharing". Alternatively, if the page table sharing identifier for virtual memory region A is "Y", it means that the virtual memory region supports page table sharing, and the page table sharing identifier for virtual memory region B is "N", it means that the virtual memory region does not support page table sharing.
[0079] In practical applications, there are multiple ways to obtain the page table sharing identifiers corresponding to multiple virtual memory regions. The specific method chosen depends on the actual situation, and this specification does not impose any limitations on this method. In one possible implementation of this specification, the virtual memory regions carry page table sharing identifiers, allowing direct acquisition of the page table sharing identifiers corresponding to multiple virtual memory regions. In another possible implementation of this specification, the page table sharing identifiers corresponding to multiple virtual memory regions can be read from other data acquisition devices or databases.
[0080] It should be noted that after obtaining the page table sharing identifiers corresponding to multiple virtual memory regions, it is possible to further filter out the page table sharing identifiers that support page table sharing, and use the virtual memory regions corresponding to the page table sharing identifiers that support page table sharing as the target virtual memory regions.
[0081] By applying the scheme of the embodiments in this specification, page table sharing identifiers corresponding to multiple virtual memory regions are obtained; based on the page table sharing identifiers, a target virtual memory region is selected from the multiple virtual memory regions. By using page table sharing identifiers to select the target virtual memory region from multiple virtual memory regions, the accuracy of the target virtual memory region is ensured.
[0082] Step 406: Determine the target shared page table corresponding to the shadow virtual memory region.
[0083] In one or more embodiments of this specification, in response to an access request from a first process to access memory, multiple virtual memory regions are allocated to the first process; after allocating a shadow virtual memory region for a target virtual memory region among the multiple virtual memory regions, the target shared page table corresponding to the shadow virtual memory region can be further determined.
[0084] Specifically, a shared page table refers to the page table structure of shared memory. In a multiprocessor system, each processor has its own page table used to map virtual addresses to physical addresses. A shared page table allows multiple processors to share the same page table, thereby reducing memory usage and improving system efficiency.
[0085] In practical applications, there are multiple ways to determine the target shared page table corresponding to the shadow virtual memory region. The specific method should be selected based on the actual situation, and this specification does not impose any limitations on this method. In one possible implementation of this specification, the allocated page table can be directly obtained from the second process as the target shared page table corresponding to the shadow virtual memory region. In another possible implementation of this specification, the target shared page table corresponding to the shadow virtual memory region can be created in the shadow management region.
[0086] The scheme implemented in this specification, by introducing page table sharing into ordinary shared memory, allows processes to use page table sharing functionality without prior memory reservation, thus improving the universality of page table sharing. By allocating multiple virtual memory regions to the first process, the page table sharing coverage is improved. Furthermore, the introduction of shadow virtual memory regions simplifies the location of shared page tables and reduces the page table overhead of shared memory.
[0087] In one optional embodiment of this specification, the determination of the target shared page table corresponding to the shadow virtual memory region may include the following steps:
[0088] Obtain the pre-allocated shared page table for the second process;
[0089] Use the shared page table of the second process as the target shared page table corresponding to the shadow virtual memory region.
[0090] It should be noted that there are multiple ways to obtain the pre-allocated shared page table of the second process, and the specific method should be selected according to the actual situation. This specification does not impose any limitations on this method in the embodiments. In one possible implementation of this specification, the second process carries the shared page table, which can be directly obtained from the pre-allocated shared page table of the second process. In another possible implementation of this specification, the pre-allocated shared page table of the second process can be read from other data acquisition devices or databases.
[0091] By applying the scheme of the embodiments in this specification, the pre-allocated shared page table of the second process is obtained; the shared page table of the second process is used as the target shared page table corresponding to the shadow virtual memory region, thereby realizing the sharing of page tables between the first process and the second process.
[0092] In another optional embodiment of this specification, the determination of the target shared page table corresponding to the shadow virtual memory region may include the following steps:
[0093] Allocate a shadow management region for the shadow virtual memory region;
[0094] Create the target shared page table corresponding to the shadow virtual memory region in the shadow management region.
[0095] It should be noted that since the shared page table of the second process may not be allocated to the shadow virtual memory region, a shadow management region (Shadow Memory Management) can be allocated for the shadow virtual memory region, and the target shared page table corresponding to the shadow virtual memory region can be created in the shadow management region.
[0096] In practical applications, a normal process typically has one management region and multiple virtual memory regions. A virtual memory region represents an accessible address space, managed by the management region. When using page table sharing, users create a virtual memory region along with a shadow virtual memory region and a shadow management region. The purpose of creating the shadow management region is to avoid conflicts when placing the shadow virtual memory region into the existing virtual memory region within the management region. When allocating a shadow management region to a shadow virtual memory region, it can be allocated based on the virtual memory region, and the shadow management region is shared with the virtual memory region of the second process.
[0097] By applying the scheme of the embodiments in this specification, a shadow management region is allocated to the shadow virtual memory region; a target shared page table corresponding to the shadow virtual memory region is created in the shadow management region, thereby realizing page table sharing between the first process and the second process.
[0098] See Figure 5 , Figure 5 This specification shows a flowchart of a page fault handling method according to an embodiment, which specifically includes the following steps:
[0099] Step 502: In response to the page fault information triggered by the first process during memory access, determine the abnormal virtual memory region where the page fault occurred.
[0100] In one or more embodiments of this specification, in response to a page fault exception triggered by a first process during memory access, the abnormal virtual memory region where the page fault occurred is determined.
[0101] It should be noted that page faults may occur in the virtual memory region for various reasons. Therefore, there are multiple page fault exception messages triggered by the first process during memory access. These page fault exception messages include, but are not limited to, insufficient physical memory corresponding to the virtual memory region, physical memory corresponding to the virtual memory region being occupied by other processes, and loss of the mapping relationship between the virtual address and physical address of the virtual memory region.
[0102] Specifically, insufficient physical memory for a virtual memory region means that when there is insufficient physical memory for the corresponding virtual memory region, the operating system may choose to swap out some memory pages to make room for allocating memory for the new virtual memory region. In this case, a page fault may occur in the swapped-out virtual memory region.
[0103] When the physical memory corresponding to a virtual memory region is occupied by another process, the operating system may choose to swap out some memory pages to make room for allocating memory for the new virtual memory region. In this case, a page fault may occur in the swapped-out virtual memory region.
[0104] The loss of the virtual address-physical address mapping in a virtual memory region refers to the situation where this mapping is lost. In this case, the operating system may swap out some memory pages to establish a new virtual address-physical address mapping. A page fault may then occur in the swapped-out virtual memory region.
[0105] In practical applications, in response to a page fault exception triggered by the first process during memory access, when determining the abnormal virtual memory region where the page fault occurred, the page fault exception information can be obtained and parsed, and the virtual memory region corresponding to the page fault exception information can be identified as the abnormal virtual memory region.
[0106] Step 504: Locate the shadow virtual memory region allocated for the abnormal virtual memory region, and obtain the target shared page table corresponding to the shadow virtual memory region. The shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the abnormal virtual memory region.
[0107] In one or more embodiments of this specification, in response to a page fault exception triggered by the first process during memory access, after determining the abnormal virtual memory region where the page fault occurred, the shadow virtual memory region allocated for the abnormal virtual memory region can be searched to obtain the target shared page table corresponding to the shadow virtual memory region.
[0108] In one optional embodiment of this specification, before finding the shadow virtual memory region allocated for the abnormal virtual memory region and obtaining the target shared page table corresponding to the shadow virtual memory region, the following steps may be included:
[0109] Determine whether the abnormal virtual memory region is a virtual memory region shared by page tables;
[0110] The above-mentioned method of finding the shadow virtual memory region allocated for the abnormal virtual memory region and obtaining the target shared page table corresponding to the shadow virtual memory region may include the following steps:
[0111] If the abnormal virtual memory region is a page table-shared virtual memory region, locate the shadow virtual memory region allocated for the abnormal virtual memory region and obtain the target shared page table corresponding to the shadow virtual memory region.
[0112] In practical applications, there are multiple ways to determine whether an abnormal virtual memory region is a page table-shared virtual memory region. The specific method should be selected based on the actual situation, and this specification does not impose any limitations on this method. In one possible implementation, the abnormal virtual memory region can be manually determined to be a page table-shared virtual memory region. In another possible implementation, the page table sharing identifier corresponding to the abnormal virtual memory region can be obtained; the page table sharing identifier is then used to determine whether the abnormal virtual memory region is a page table-shared virtual memory region. The implementation method for "obtaining the page table sharing identifier corresponding to the abnormal virtual memory region" is the same as the implementation method for "obtaining the page table sharing identifiers corresponding to multiple virtual memory regions respectively," and will not be described again in this specification.
[0113] It should be noted that if the abnormal virtual memory region is not a page table-shared virtual memory region, the abnormal virtual memory region is determined to be a normal virtual memory region, and page table sharing is not performed; if the abnormal virtual memory region is a page table-shared virtual memory region, the shadow virtual memory region allocated for the abnormal virtual memory region is searched, and the target shared page table corresponding to the shadow virtual memory region is obtained.
[0114] By applying the scheme of the embodiments in this specification, it is determined whether the abnormal virtual memory region is a page table-shared virtual memory region; if the abnormal virtual memory region is a page table-shared virtual memory region, the shadow virtual memory region allocated for the abnormal virtual memory region is searched, and the target shared page table corresponding to the shadow virtual memory region is obtained, thereby realizing page table sharing for abnormal virtual memory regions that support page table sharing.
[0115] In practical applications, there are multiple ways to find the shadow virtual memory region allocated for the abnormal virtual memory region and obtain the target shared page table corresponding to the shadow virtual memory region. The specific method should be selected according to the actual situation. This specification does not limit the specific methods used in this embodiment.
[0116] In one possible implementation of this specification, the above-mentioned method of finding the shadow virtual memory region allocated for the abnormal virtual memory region and obtaining the target shared page table corresponding to the shadow virtual memory region may include the following steps:
[0117] Locate the shadow virtual memory region allocated for the abnormal virtual memory region;
[0118] If the target shared page table has already been allocated in the shadow virtual memory region, obtain the target shared page table.
[0119] It should be noted that after finding the shadow virtual memory region allocated for the abnormal virtual memory region, it is possible to determine whether the target shared page table has been allocated in the shadow virtual memory region. If so, it means that the target shared page table has been stored in the shadow virtual memory region, and at this time, the target shared page table can be obtained directly.
[0120] The scheme described in this specification is used to locate the shadow virtual memory region allocated for the abnormal virtual memory region; if the target shared page table has been allocated in the shadow virtual memory region, the target shared page table is obtained, the target shared page table is accurately obtained, and the page table overhead of shared memory and the page fault handling overhead are reduced based on the target shared page table.
[0121] In another possible implementation of this specification, the above-mentioned method of finding the shadow virtual memory region allocated for the abnormal virtual memory region and obtaining the target shared page table corresponding to the shadow virtual memory region may include the following steps:
[0122] Locate the shadow virtual memory region allocated for the abnormal virtual memory region;
[0123] If no target shared page table is allocated for the shadow virtual memory region, allocate a target shared page table for the shadow virtual memory region.
[0124] It should be noted that after finding the shadow virtual memory region allocated for the abnormal virtual memory region, it can be determined whether the target shared page table has been allocated to the shadow virtual memory region. If not, it means that the target shared page table has not yet been stored in the shadow virtual memory region. At this time, the target shared page table can be allocated to the shadow virtual memory region.
[0125] The scheme in the embodiments of this specification is used to locate the shadow virtual memory region allocated for the abnormal virtual memory region; if no target shared page table is allocated for the shadow virtual memory region, the target shared page table is allocated for the shadow virtual memory region, and the page table overhead of shared memory and the page fault handling overhead are reduced based on the target shared page table.
[0126] In one optional embodiment of this specification, the allocation of a target shared page table for the shadow virtual memory region described above may include the following steps:
[0127] Obtain the pre-allocated shared page table for the second process;
[0128] Use the shared page table of the second process as the target shared page table corresponding to the shadow virtual memory region.
[0129] It should be noted that the implementation of "obtaining the pre-allocated shared page table of the second process; using the shared page table of the second process as the target shared page table corresponding to the shadow virtual memory region" is the same as described above. Figure 4The implementation of "obtaining the pre-allocated shared page table of the second process; using the shared page table of the second process as the target shared page table corresponding to the shadow virtual memory region" in the provided page table sharing method is the same, and will not be described again in the embodiments of this specification.
[0130] By applying the scheme of the embodiments in this specification, the pre-allocated shared page table of the second process is obtained; the shared page table of the second process is used as the target shared page table corresponding to the shadow virtual memory region, thereby realizing the sharing of page tables between the first process and the second process.
[0131] In another optional embodiment of this specification, the allocation of the target shared page table for the shadow virtual memory region described above may include the following steps:
[0132] Allocate a shadow management region for the shadow virtual memory region;
[0133] Create the target shared page table corresponding to the shadow virtual memory region in the shadow management region.
[0134] It should be noted that the implementation of "allocating a shadow management region for the shadow virtual memory region; creating the target shared page table corresponding to the shadow virtual memory region within the shadow management region" is the same as described above. Figure 4 The implementation of "allocating a shadow management region for the shadow virtual memory region and creating a target shared page table corresponding to the shadow virtual memory region in the shadow management region" in the provided page table sharing method is the same, so the embodiments in this specification will not be described again.
[0135] By applying the scheme of the embodiments of this specification, a shadow management region is allocated for the shadow virtual memory region; a target shared page table corresponding to the shadow virtual memory region is created in the shadow management region, thereby realizing page table sharing between the first process and the second process.
[0136] Step 506: Use the target shared page table to map physical memory to the virtual memory of the first process.
[0137] In one or more embodiments of this specification, in response to a page fault exception triggered by a first process during memory access, the abnormal virtual memory region where the page fault occurred is determined; after finding the shadow virtual memory region allocated for the abnormal virtual memory region and obtaining the target shared page table corresponding to the shadow virtual memory region, the target shared page table can be further used to map physical memory to the virtual memory of the first process.
[0138] It should be noted that since page tables are used to store the mapping relationship between virtual addresses and physical addresses of virtual memory regions, after obtaining the target shared page table, the virtual memory of the first process can be mapped to physical memory according to the mapping relationship between virtual addresses and physical addresses stored in the target shared page table.
[0139] The scheme implemented in this specification, by introducing page table sharing into ordinary shared memory, allows processes to use page table sharing functionality without prior memory reservation, thus improving the universality of page table sharing. By allocating multiple virtual memory regions for the first process, the page table sharing coverage is increased. Introducing a shadow virtual memory region simplifies shared page table location, and by utilizing the target shared page table to map physical memory to the first process's virtual memory, the page table overhead of shared memory and the overhead of handling page faults are reduced.
[0140] The following is in conjunction with the appendix Figure 6 The page fault handling method is further explained below. Figure 6 This specification illustrates a flowchart of a page table sharing method according to an embodiment, which specifically includes:
[0141] In response to the memory access request from the first process, multiple virtual memory regions are allocated for the first process. In user mode, when calling mmap() to create a mapping, a page table sharing identifier is passed to determine whether the target virtual memory region is a normal virtual memory region or a page table-shared virtual memory region. In kernel mode, if the target virtual memory region is a page table-shared virtual memory region, a shadow virtual memory region and a shadow management region are allocated. The attributes of the shadow virtual memory region are the same as those of the virtual memory regions.
[0142] In response to a page fault exception triggered by the first process of the application during memory access, the abnormal virtual memory region where the page fault occurred is identified, and the allocation of page tables at all levels and the target page begins. It is then determined whether the abnormal virtual memory region is a page table-shared virtual memory region: if not, the abnormal virtual memory region is determined to be a normal virtual memory region; if so, the shadow virtual memory region allocated for the abnormal virtual memory region is searched, and the target shared page table of the shadow virtual memory region is traversed to see if it is allocated: if yes, the target shared page table is used directly; if not, a target shared page table is allocated for the shadow virtual memory region. Subsequent page faults in other child processes will not require the allocation of a target shared page table for the shadow virtual memory region; instead, the same page table entry-level target shared page table will be used.
[0143] The shared page table method provided in the embodiments of this specification is based on 4K pages, ensuring the universality of the shared page table. It introduces a shadow virtual memory region to automatically align the virtual memory region, ensuring a very high page table sharing coverage and enabling fast location of the shared page table. The page table sharing method is simple to use, using pages that are exactly the same as normal memory allocation, eliminating the need for pre-reserved memory and solving the problem that other applications cannot use reserved memory in scenarios with large shared memory. By allocating separate shadow virtual memory regions and shadow management regions to manage the shareable page tables, it can quickly determine whether a shared page table has been allocated when a page fault occurs, solving the problem of high overhead in finding shared page tables in scenarios with a large number of concurrent processes and increasing the robustness of the solution.
[0144] In practical applications, the shared page table method provided in the embodiments of this specification was tested under a microprocessor architecture, with the process concurrency of the test application set to 100. During the testing process, refer to Table 1 below. The test application used page table overhead in shared memory scenarios of 20G, 50G, 100G, 200G, and 400G respectively. Detailed test data can be found in the test data table.
[0145] Table 1 Test Data Table
[0146]
[0147] It should be noted that for applications with a process concurrency of 50, theoretical calculations show that page table overhead can be reduced by about 50%.
[0148] Therefore, the page table sharing method provided in the embodiments of this specification introduces page table sharing design for ordinary shared memory, allowing any process to use the page table sharing function without reserving memory in advance; the introduction of shadow virtual memory region and shadow management region simplifies the location of shared page tables, and for any process concurrency, the location of shared memory can be located in O(1) time complexity; the virtual memory region can be automatically aligned to 2M, and the page table sharing coverage is very high; a rollback mechanism is supported, and a user-mode control switch is provided for the user to choose whether to use the page table sharing function for shared memory. When the switch is off, the behavior is consistent with the original Linux kernel.
[0149] Corresponding to the above-described page table sharing method embodiments, this specification also provides page table sharing device embodiments. Figure 7 A schematic diagram of a page table sharing device according to one embodiment of this specification is shown. Figure 7 As shown, the device includes:
[0150] The first allocation module 702 is configured to allocate multiple virtual memory regions for the first process in response to the first process's memory access request;
[0151] The second allocation module 704 is configured to allocate a shadow virtual memory region for a target virtual memory region in multiple virtual memory regions, wherein the shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the target virtual memory region.
[0152] The first determining module 706 is configured to determine the target shared page table corresponding to the shadow virtual memory region.
[0153] Optionally, the device further includes a filtering module configured to filter out a target virtual memory region from a plurality of virtual memory regions, wherein the target virtual memory region is a virtual memory region shared by page tables.
[0154] Optionally, the filtering module is further configured to obtain page table sharing identifiers corresponding to multiple virtual memory regions respectively; and to filter out the target virtual memory region from the multiple virtual memory regions based on the page table sharing identifiers.
[0155] Optionally, the first determining module 706 is further configured to obtain the pre-allocated shared page table of the second process; and use the shared page table of the second process as the target shared page table corresponding to the shadow virtual memory region.
[0156] Optionally, the first determining module 706 is further configured to allocate a shadow management region for the shadow virtual memory region; and to create a target shared page table corresponding to the shadow virtual memory region in the shadow management region.
[0157] The scheme implemented in this specification, by introducing page table sharing into ordinary shared memory, allows processes to use page table sharing functionality without prior memory reservation, thus improving the universality of page table sharing. By allocating multiple virtual memory regions to the first process, the page table sharing coverage is improved. Furthermore, the introduction of shadow virtual memory regions simplifies the location of shared page tables and reduces the page table overhead of shared memory.
[0158] The above is a schematic scheme of a page table sharing device according to this embodiment. It should be noted that the technical solution of this page table sharing device and the technical solution of the page table sharing method described above belong to the same concept. For details not described in detail in the technical solution of the page table sharing device, please refer to the description of the technical solution of the page table sharing method described above.
[0159] Corresponding to the above-described embodiments of page fault handling methods, this specification also provides embodiments of page fault handling devices. Figure 8 A schematic diagram of a page fault handling device according to one embodiment of this specification is shown. Figure 8 As shown, the device includes:
[0160] The second determining module 802 is configured to determine the abnormal virtual memory region where the page fault occurred in response to the page fault information triggered by the first process during memory access.
[0161] The lookup module 804 is configured to look up the shadow virtual memory region allocated for the abnormal virtual memory region and obtain the target shared page table corresponding to the shadow virtual memory region. The shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the abnormal virtual memory region.
[0162] Mapping module 806 is configured to map physical memory to the virtual memory of the first process using the target shared page table.
[0163] Optionally, the device further includes: a judgment module configured to determine whether the abnormal virtual memory region is a page table-shared virtual memory region; and a search module 804 further configured to, in the case that the abnormal virtual memory region is a page table-shared virtual memory region, search for a shadow virtual memory region allocated for the abnormal virtual memory region and obtain the target shared page table corresponding to the shadow virtual memory region.
[0164] Optionally, the lookup module 804 is further configured to look up a shadow virtual memory region allocated for the abnormal virtual memory region; and if a target shared page table has been allocated to the shadow virtual memory region, to obtain the target shared page table.
[0165] Optionally, the lookup module 804 is further configured to look up a shadow virtual memory region allocated for the abnormal virtual memory region; and to allocate a target shared page table for the shadow virtual memory region if no target shared page table is allocated for the shadow virtual memory region.
[0166] Optionally, the lookup module 804 is further configured to obtain the pre-allocated shared page table of the second process; and use the shared page table of the second process as the target shared page table corresponding to the shadow virtual memory region.
[0167] Optionally, the lookup module 804 is further configured to allocate a shadow management region for the shadow virtual memory region; and to create a target shared page table corresponding to the shadow virtual memory region within the shadow management region.
[0168] The scheme implemented in this specification, by introducing page table sharing into ordinary shared memory, allows processes to use page table sharing functionality without prior memory reservation, thus improving the universality of page table sharing. By allocating multiple virtual memory regions for the first process, the page table sharing coverage is increased. Introducing a shadow virtual memory region simplifies shared page table location, and by utilizing the target shared page table to map physical memory to the first process's virtual memory, the page table overhead of shared memory and the overhead of handling page faults are reduced.
[0169] The above is a schematic scheme of a page fault handling device according to this embodiment. It should be noted that the technical solution of this page fault handling device and the technical solution of the page fault handling method described above belong to the same concept. For details not described in detail in the technical solution of the page fault handling device, please refer to the description of the technical solution of the page fault handling method described above.
[0170] Figure 9 A structural block diagram of a computing device according to one embodiment of this specification is shown. The components of the computing device 900 include, but are not limited to, a memory 910 and a processor 920. The processor 920 is connected to the memory 910 via a bus 930, and a database 950 is used to store data.
[0171] The computing device 900 also includes an access device 940, which enables the computing device 900 to communicate via one or more networks 960. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 940 may include one or more of any type of wired or wireless network interface (e.g., Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Networks (WLAN) interface, a Wi-MAX (World Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0172] In one embodiment of this specification, the above-described components of the computing device 900 and Figure 9 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 9 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0173] The computing device 900 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 900 can also be a mobile or stationary server.
[0174] The processor 920 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the above-described page table sharing method or page fault handling method.
[0175] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device belongs to the same concept as the technical solutions of the page table sharing method and the page fault handling method described above. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solutions of the page table sharing method or the page fault handling method described above.
[0176] An embodiment of this specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the page table sharing method or the page fault handling method described above.
[0177] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the page table sharing method and page fault handling method described above. Details not described in detail in the technical solution of the storage medium can be found in the descriptions of the page table sharing method or page fault handling method described above.
[0178] An embodiment of this specification also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described page table sharing method or page fault handling method.
[0179] The above is an illustrative scheme of a computer program according to this embodiment. It should be noted that the technical solution of this computer program belongs to the same concept as the technical solutions of the page table sharing method and the page fault handling method described above. For details not described in detail in the technical solution of the computer program, please refer to the description of the technical solutions of the page table sharing method or the page fault handling method described above.
[0180] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0181] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0182] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0183] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0184] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A page table sharing method, comprising: In response to the memory access request of the first process, allocate multiple virtual memory regions for the first process; For the target virtual memory region among the plurality of virtual memory regions, a shadow virtual memory region is allocated, wherein the shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the target virtual memory region, and the target virtual memory region is a virtual memory region shared by page tables; Determining the target shared page table corresponding to the shadow virtual memory region includes: obtaining the pre-allocated shared page table of the second process; and using the shared page table of the second process as the target shared page table corresponding to the shadow virtual memory region.
2. The method according to claim 1, further comprising, before allocating a shadow virtual memory region for a target virtual memory region among the plurality of virtual memory regions: Select the target virtual memory region from the plurality of virtual memory regions.
3. The method according to claim 2, wherein selecting the target virtual memory region from the plurality of virtual memory regions comprises: Obtain the page table sharing identifiers corresponding to the multiple virtual memory regions respectively; The target virtual memory region is selected from the plurality of virtual memory regions based on the page table sharing identifier.
4. The method according to claim 1, wherein determining the target shared page table corresponding to the shadow virtual memory region further comprises: Allocate a shadow management region to the shadow virtual memory region; Create the target shared page table corresponding to the shadow virtual memory region in the shadow management region.
5. A page fault handling method, comprising: In response to a page fault exception triggered by the first process during memory access, the abnormal virtual memory region where the page fault occurred is identified. Determine whether the abnormal virtual memory region is a virtual memory region shared by page tables; In the case that the abnormal virtual memory region is a page table-shared virtual memory region, the shadow virtual memory region allocated for the abnormal virtual memory region is searched to obtain the target shared page table corresponding to the shadow virtual memory region. The shadow virtual memory region is used to share the virtual memory region of the second process with the same attributes as the abnormal virtual memory region. Using the target shared page table, physical memory is mapped to the virtual memory of the first process.
6. The method according to claim 5, wherein finding the shadow virtual memory region allocated for the abnormal virtual memory region and obtaining the target shared page table corresponding to the shadow virtual memory region includes: Locate the shadow virtual memory region allocated for the abnormal virtual memory region; If a target shared page table has been allocated in the shadow virtual memory region, the target shared page table is obtained.
7. The method according to claim 5, wherein finding the shadow virtual memory region allocated for the abnormal virtual memory region and obtaining the target shared page table corresponding to the shadow virtual memory region includes: Locate the shadow virtual memory region allocated for the abnormal virtual memory region; If no target shared page table is allocated in the shadow virtual memory region, allocate a target shared page table for the shadow virtual memory region.
8. The method according to claim 7, wherein allocating a target shared page table to the shadow virtual memory region comprises: Obtain the pre-allocated shared page table of the second process; The shared page table of the second process is used as the target shared page table corresponding to the shadow virtual memory region.
9. The method according to claim 7, wherein allocating a target shared page table to the shadow virtual memory region comprises: Allocate a shadow management region to the shadow virtual memory region; Create the target shared page table corresponding to the shadow virtual memory region in the shadow management region.
10. A computing device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1 to 4 or any one of claims 5 to 9.
11. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 4 or any one of claims 5 to 9.
Citation Information
Patent Citations
On demand shareability conversion in a heterogeneous shared virtual memory
IN201627040709A
Systems and methods implementing shared page tables for sharing memory resources managed by a main operating system with accelerator devices
US20110161620A1