Page table sharing method and missing page exception processing method
By allocating multiple virtual memory areas to the process and introducing shadow virtual memory areas, page table sharing is realized without pre-reserving memory, solving the problems of poor memory expansion and low coverage in the prior art, and improving the universality and efficiency of page table sharing.
Patent Information
- Application Number
- CN202311396538.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-25
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2043-10-25
AI Technical Summary
When implementing page table sharing, the prior art requires memory reservation in advance, resulting in poor memory expansion, low universality, and low coverage and efficiency of page table sharing.
Positioning and mapping of shared page tables is simplified by allocating multiple virtual memory areas for the process and allocating shadow virtual memory areas for the target virtual memory area to share page tables with the same attributes.
Page table sharing can be realized without pre-reserving memory, which improves the universality and coverage of page table sharing, and reduces the overhead of page table overhead and page-missing exception handling of shared memory.
Smart Images

Figure CN119883956A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present specification relate to the field of computer technology, and in particular to a page table sharing method. Background Art
[0002] With the development of computer technology, in order to save the operating system's page table overhead, page table sharing has gradually become a research focus. The page table is a special data structure that records the correspondence between pages and page frames. The page table is the basis for non-contiguous memory partition allocation and realizes the conversion from logical addresses to physical addresses.
[0003] At present, huge page cache (Huge TLB, Huge Translation Lookaside Buffer) is usually used to save page table overhead and support page table sharing. However, the use of the huge page cache method requires memory to be reserved in advance. The reserved memory cannot be recycled and used by other applications, which has a great impact on memory scalability and leads to low universality of page table sharing. Therefore, a highly universal page table sharing method is urgently needed. Summary of the invention
[0004] In view of this, an embodiment of the present specification provides a page table sharing method. One or more embodiments of the present specification also relate to a page fault exception handling method, a page table sharing device, a page fault exception handling device, a computing device, a computer-readable storage medium and a computer program to solve the technical defects existing in the prior art.
[0005] According to a first aspect of an embodiment of this specification, a page table sharing method is provided, including:
[0006] In response to an access request of the first process to access the memory, allocating a plurality of virtual memory areas to the first process;
[0007] Allocating a shadow virtual memory area for a target virtual memory area among the multiple virtual memory areas, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attribute as the target virtual memory area;
[0008] Determine the target shared page table corresponding to the shadow virtual memory area.
[0009] According to a second aspect of an embodiment of this specification, a method for handling a page fault exception is provided, comprising:
[0010] In response to page fault exception information triggered by the first process during memory access, determining an abnormal virtual memory area where the page fault exception occurs;
[0011] Searching for a shadow virtual memory area allocated for the abnormal virtual memory area, and obtaining a target shared page table corresponding to the shadow virtual memory area, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attributes as the abnormal virtual memory area;
[0012] Using the target shared page table, the physical memory is mapped for the virtual memory of the first process.
[0013] According to a third aspect of an embodiment of this specification, a page table sharing device is provided, including:
[0014] A first allocation module is configured to allocate a plurality of virtual memory areas to the first process in response to an access request of the first process to access the memory;
[0015] A second allocation module is configured to allocate a shadow virtual memory area for a target virtual memory area among the multiple virtual memory areas, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attribute as the target virtual memory area;
[0016] The first determination module is configured to determine a target shared page table corresponding to the shadow virtual memory area.
[0017] According to a fourth aspect of an embodiment of this specification, a page fault exception handling device is provided, comprising:
[0018] A second determination module is configured to determine an abnormal virtual memory area where a page fault exception occurs in response to page fault exception information triggered by the first process in a process of accessing the memory;
[0019] A search module is configured to search for a shadow virtual memory area allocated for the abnormal virtual memory area, and obtain a target shared page table corresponding to the shadow virtual memory area, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attributes as the abnormal virtual memory area;
[0020] The mapping module is configured to map the physical memory for the virtual memory of the first process using the target shared page table.
[0021] According to a fifth aspect of an embodiment of this specification, a computing device is provided, including:
[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. When the computer-executable instructions are executed by the processor, the steps of the method provided by the first aspect or the second method are implemented.
[0024] According to a sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the method provided by the first aspect or the second method are implemented.
[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, the computer is caused to execute the steps of the method provided in the first aspect or the second method above.
[0026] A page table sharing method provided by an embodiment of the present specification allocates multiple virtual memory areas to the first process in response to an access request of the first process to access the memory; allocates a shadow virtual memory area for a target virtual memory area among the multiple virtual memory areas, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attributes as the target virtual memory area; and determines a target shared page table corresponding to the shadow virtual memory area. By introducing a page table sharing design for ordinary shared memory, the page table sharing function can be used for the process without reserving memory in advance, thereby improving the universality of page table sharing. By allocating multiple virtual memory areas to the first process, the page table sharing coverage is improved, and the introduction of the shadow virtual memory area simplifies the positioning of the shared page table and reduces the page table overhead of the shared memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 is a flow chart of a page table sharing method;
[0028] Figure 2 is an architecture diagram of a page table sharing system provided by an embodiment of this specification;
[0029] Figure 3 is an architecture diagram of another page table sharing system provided by an embodiment of this specification;
[0030] Figure 4 is a flow chart of a page table sharing method provided by one embodiment of this specification;
[0031] Figure 5 is a flow chart of a page fault exception handling method provided by an embodiment of this specification;
[0032] Figure 6 is a process flow chart of a page table sharing method provided by an embodiment of the present specification;
[0033] Figure 7 It is a structural schematic diagram of a page table sharing device provided by an embodiment of this specification;
[0034] Figure 8It is a structural schematic diagram of a page fault exception handling device provided by an embodiment of this specification;
[0035] Fig. 9 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0036] Many specific details are described in the following description to facilitate 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 generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0037] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" 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, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0039] In addition, 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, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0040] First, the terms involved in one or more embodiments of this specification are explained.
[0041] TLB: Translation Lookaside Buffer (TLB), also known as page table cache, is mainly used to speed up the conversion of virtual addresses to physical addresses and reduce the core processor (CPU, Central Processing Unit)'s (CPU) memory read operations.
[0042] Virtual memory area: The virtual address space of a process is managed by virtual memory area (VMA), which includes code segment virtual memory area and 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 in the page table corresponds to a memory page frame.
[0045] Page Middle Directory (PMD): Each PMD contains 4 page table entries and is used to index larger memory areas. The size of the PMD depends on the processor architecture and operating system implementation.
[0046] User state: User state is the basic state of a process when it runs in an operating system. In user state, a process can only access resources it owns, and the operations it performs are restricted by the operating system. In user state, a process cannot access kernel data structures or execute kernel code.
[0047] Kernel state: Kernel state is a privileged execution mode in the operating system. Only the kernel can be in this state. In kernel state, the operating system can access and modify all system resources, including hardware devices and memory data structures. In kernel state, the operating system can execute kernel code to control and manage the operation of the system.
[0048] Currently, operating systems already have a method to save page table overhead by using a large page cache, and this method can also support page table sharing. Figure 1 , Figure 1The flowchart of a page table sharing method is shown. The page table sharing of the super large page cache is based on the super large page cache design, and memory needs to be reserved in advance before use. Specifically, the super large page cache is set up and memory is reserved in the user state, and the super large page cache memory pool is set up in the kernel state. When the application accesses the memory in the kernel state in the user state, when a page fault exception occurs, the response mapping data structure i_mmap is found through the virtual memory area, and all related virtual memory areas are traversed. As long as there is a virtual memory area corresponding to the position where a page table has been allocated, the page table is directly used, otherwise a new page table is reallocated. Figure 1 As shown, when a page fault exception occurs, page tables and target pages at all levels are allocated, and further judgment is made as to whether the addresses at both ends of the virtual memory area are aligned with 1G: if not, a new page middle directory page table page is allocated to the super large page cache memory pool; if so, traverse the virtual memory area pointing to the same file to see if the page middle directory page table page has been allocated: if not, a new page middle directory page table page is allocated to the super large page cache memory pool; if so, the same page middle directory page table page is used. It should be noted that address 1G alignment means aligning the address of the data to the 1GB boundary. This is a common memory alignment method that can improve memory access efficiency, reduce memory fragmentation, and increase the running speed of the program.
[0049] However, the above scheme has the following problems: First, a large amount of memory needs to be reserved in advance, and the reserved memory cannot be used by other applications, which limits the computing power of the server to a certain extent and has a great impact on the memory scalability, resulting in a lack of transparency to the application and cannot be used on a large scale in the cloud environment; Second, there are defects in the design of page table sharing. Page table sharing requires the addresses at both ends of the super large page cache to be aligned to 1G. The current super large page cache implementation does not automatically align the virtual memory area, so its page table sharing coverage is low; Third, the demand for super large page cache page table sharing is small and difficult to promote. The super large page cache itself can support 2M or 1G large pages. When supporting large pages, the benefits of using super large page cache page table sharing are not obvious; Fourth, there are performance defects in super large page cache page table sharing. When searching for shared page tables, the super large page cache needs to traverse the virtual memory area pointing to the same file to see if the page has been allocated. The method of intermediate directory page table pages is not efficient enough. For applications with a large number of child processes, the time complexity of this traversal is large.
[0050] In order to solve the above problems, the embodiment of this specification proposes a page table sharing method that can reduce the page table overhead of multi-process applications at the operating system layer and improve application performance. The main idea of this method is to design the private page table entry level page table of the original parent and child processes as the last level page table entry page table shared by the parent and child processes. Specifically, in response to the access request of the first process to access the memory, multiple virtual memory areas are allocated to the first process; for the target virtual memory area in the multiple virtual memory areas, a shadow virtual memory area is allocated, wherein the shadow virtual memory area is used to share the virtual memory area of the second process with the same attributes as the target virtual memory area; and the target shared page table corresponding to the shadow virtual memory area is determined. By introducing the design of page table sharing for ordinary shared memory, the page table sharing function can be used for the process without reserving memory in advance, which improves the universality of page table sharing. By allocating multiple virtual memory areas to the first process, the page table sharing coverage is improved, and the introduction of the shadow virtual memory area simplifies the positioning of the shared page table and reduces the page table overhead of the shared memory.
[0051] It is worth noting that for applications that share a large amount of memory, such as databases, whose shared memory is as high as hundreds of bytes and the number of sub-processes can reach hundreds, after using the general page table sharing method based on 4K pages provided in the embodiments of this specification, the page table overhead can be saved by an average of about 90%, which greatly reduces the memory cost in cloud computing scenarios. In addition, the page table sharing scheme proposed in the embodiments of this specification can reduce the page table overhead of the shared memory of the application to as little as possible without the system being aware of it and the application being modified as little as possible, and the method can be used without reserving memory in advance. In addition, the page table sharing method proposed in the embodiments of this specification has been implemented on the Linux kernel and has passed the standard test benchmark to ensure the reliability of the scheme.
[0052] In this specification, a page table sharing method is provided. This specification also involves a page fault exception handling method, a page table sharing device, a page fault exception handling device, a computing device, a computer-readable storage medium and a computer program, which are described in detail one by one in the following embodiments.
[0053] See also Figure 2 , Figure 2 An architecture diagram of a page table sharing system provided by an embodiment of the present specification is shown. The page table sharing system may include a client 100 and a server 200;
[0054] The client 100 is used to send an access request for a first process to access memory to the server 200; the server 200 is used to allocate multiple virtual memory areas to the first process in response to the access request for accessing memory by the first process; allocate a shadow virtual memory area for a target virtual memory area among the multiple virtual memory areas, wherein the shadow virtual memory area is used to share a virtual memory area of a second process with the same attributes as the target virtual memory area; and determine a target shared page table corresponding to the shadow virtual memory area.
[0055] By applying the solution of the embodiment of this specification, by introducing the design of page table sharing for ordinary shared memory, the page table sharing function can be used for the process without reserving memory in advance, thereby improving the universality of page table sharing. By allocating multiple virtual memory areas to the first process, the page table sharing coverage is improved, and the introduction of the shadow virtual memory area simplifies the positioning of the shared page table and reduces the page table overhead of the shared memory.
[0056] See also Figure 3 , Figure 3 The architecture diagram of another page table sharing system provided by an embodiment of the present specification is shown, and the page table sharing system may include multiple clients 100 and a server 200. Multiple clients 100 may establish a communication connection through the server 200. In the page table sharing scenario, the server 200 is used to provide page table sharing services between multiple clients 100. Multiple clients 100 may respectively serve as a sender or a receiver, and realize communication through the server 200.
[0057] The user can interact with the server 200 through the client 100 to receive data sent by other clients 100, or send data to other clients 100, etc. In the page table sharing scenario, the user can publish a data stream to the server 200 through the client 100, and the server 200 determines the target shared page table according to the data stream, and pushes the target shared page table to other clients that establish communication.
[0058] The client 100 and the server 200 are connected via a network. The network provides a medium for a communication link between the client 100 and the server 200. The network may include various connection types, such as wired or wireless communication links or optical fiber cables, etc. The data transmitted by the client 100 may need to be encoded, transcoded, compressed, etc. before being released to the server 200.
[0059] The client 100 can be a browser, an APP (Application), or a web application such as an H5 (HyperText Markup Language 5, Hypertext Markup Language Version 5) application, or a light application (also known as a mini-program, a lightweight application) or a cloud application, etc. The client 100 can be based on the software development kit (SDK, Software Development Kit) of the corresponding service provided by the server 200, such as based on the real-time communication (RTC, Real Time Communication) SDK development and acquisition. The client 100 can be deployed in an electronic device, and needs to rely on the device to run or some APPs in the device to run. For example, the electronic device can have a display screen and support information browsing, such as a personal mobile terminal such as a mobile phone, a tablet computer, a personal computer, etc. Various other types of applications can also be configured in the electronic device, such as human-computer dialogue applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0060] The server 200 may include servers that provide various services, such as servers that provide communication services to multiple clients, and servers that process data sent by clients. It should be noted that the server 200 can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. The server can also be a server of a distributed system, or a server combined with a blockchain. The server can also be a cloud server for basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), 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 the page fault exception handling method provided in the embodiments of this specification are generally executed by the server, but in other embodiments of this specification, the client may also have similar functions to the server, thereby executing the page table sharing method and the page fault exception handling method provided in the embodiments of this specification. In other embodiments, the page table sharing method and the page fault exception handling method provided in the embodiments of this specification may also be jointly executed by the client and the server.
[0062] See also Figure 4 , Figure 4 A flow chart of a page table sharing method provided by an embodiment of the present specification is shown, which specifically includes the following steps:
[0063] Step 402: In response to a memory access request from a first process, a plurality of virtual memory areas are allocated to the first process.
[0064] In one or more embodiments of the present specification, in response to an access request of the first process to access the memory, multiple virtual memory areas may be allocated to the first process.
[0065] Specifically, the first process is a parent process that creates a child process, and 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. The access request can be a request for accessing memory sent by the target application in user mode.
[0066] In practical applications, there are many ways to allocate multiple virtual memory areas to the first process, which are selected according to actual conditions, and the embodiments of this specification do not impose any restrictions on this. In a possible implementation of this specification, multiple virtual memory areas can be allocated to the first process by static allocation. Specifically, a virtual memory area is allocated to the first process when it is created to reduce memory fragmentation and improve memory utilization. In another possible implementation of this specification, multiple virtual memory areas can be allocated to the first process by dynamic allocation. Specifically, when the first process is running, a virtual memory area is allocated to it according to demand to better meet the dynamic needs of the first process and improve the flexibility and adaptability of the system. In another possible implementation of this specification, multiple virtual memory areas can be allocated to the first process by stack allocation. Specifically, a continuous memory is allocated to the first process as a stack for storing local variables and function call information of the process to ensure the continuity and integrity of the stack and improve access efficiency.
[0067] Step 404: Allocate a shadow virtual memory area for a target virtual memory area among the multiple virtual memory areas, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attribute as the target virtual memory area.
[0068] In one or more embodiments of the present specification, in response to an access request of the first process to access memory, after allocating multiple virtual memory areas to the first process, a shadow virtual memory area (Shadow VMA, Shadow Virtual Memory Area) can be further allocated for a target virtual memory area among the multiple virtual memory areas.
[0069] Specifically, the target virtual memory area can be any virtual memory area in the multiple virtual memory areas, or a virtual memory area shared by page tables in the multiple virtual memory areas. The second process is a child process of the first process, and the child process can send a signal to the parent process, request resources from the parent process, and report its status to the parent process.
[0070] In an optional embodiment of the present specification, before allocating the shadow virtual memory area to the target virtual memory area in the multiple virtual memory areas, the following steps may also be included:
[0071] A target virtual memory area is screened out from the multiple virtual memory areas, wherein the target virtual memory area is a virtual memory area shared by the page table.
[0072] It should be noted that before allocating the shadow virtual memory area to the target virtual memory area, in order to facilitate the allocation of the shadow virtual memory area, the target virtual memory area can be screened out from multiple virtual memory areas. Further, in order to improve the allocation efficiency of the shadow virtual memory area, only the virtual memory area shared by the page table in the multiple virtual memory areas can be used as the target virtual memory area.
[0073] In actual applications, there are many ways to filter out a target virtual memory area with page table sharing from multiple virtual memory areas, and the specific selection is based on the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, the target virtual memory area with page table sharing can be manually filtered out from multiple virtual memory areas. In another possible implementation of this specification, the target virtual memory area can be filtered out from multiple virtual memory areas based on the page table sharing identifiers corresponding to each of the multiple virtual memory areas.
[0074] By applying the solution of the embodiment of this specification, a target virtual memory area is screened out from multiple virtual memory areas, wherein the target virtual memory area is a virtual memory area shared by a page table. By screening out the target virtual memory area shared by a page table from multiple virtual memory areas, redundant allocation of shadow virtual memory areas for virtual memory areas that are not shared by page tables is avoided, thereby improving the efficiency of shadow virtual memory area allocation.
[0075] In an optional embodiment of the present specification, the above-mentioned screening out of the target virtual memory area from the multiple virtual memory areas may include the following steps:
[0076] Obtain page table sharing identifiers corresponding to multiple virtual memory areas respectively;
[0077] According to the page table sharing flag, a target virtual memory area is selected from the multiple virtual memory areas.
[0078] Specifically, the page table sharing flag is used to identify whether the corresponding virtual memory area supports page table sharing. For example, the page table sharing flag corresponding to virtual memory area A is "support page table sharing", and the page table sharing flag corresponding to virtual memory area B is "do not support page table sharing"; for another example, the page table sharing flag corresponding to virtual memory area A is "Y", indicating that the virtual memory area supports page table sharing, and the page table sharing flag corresponding to virtual memory area B is "N", indicating that the virtual memory area does not support page table sharing.
[0079] In actual applications, there are many ways to obtain the page table sharing identifiers corresponding to multiple virtual memory areas, which can be selected according to the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, the virtual memory area carries a page table sharing identifier, and the page table sharing identifiers corresponding to the multiple virtual memory areas can be directly obtained. In another possible implementation of this specification, the page table sharing identifiers corresponding to the multiple virtual memory areas 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 areas respectively, the page table sharing identifiers that support page table sharing can be further filtered out from the page table sharing identifiers, and the virtual memory area corresponding to the page table sharing identifier that supports page table sharing can be used as the target virtual memory area.
[0081] By applying the solution of the embodiment of this specification, the page table sharing identifiers corresponding to the multiple virtual memory areas are obtained; according to the page table sharing identifiers, the target virtual memory area is screened out from the multiple virtual memory areas. By using the page table sharing identifiers to screen out the target virtual memory area from the multiple virtual memory areas, the accuracy of the target virtual memory area is guaranteed.
[0082] Step 406: Determine the target shared page table corresponding to the shadow virtual memory area.
[0083] In one or more embodiments of the present specification, in response to an access request of the first process to access the memory, multiple virtual memory areas are allocated to the first process; after a shadow virtual memory area is allocated to a target virtual memory area among the multiple virtual memory areas, a target shared page table corresponding to the shadow virtual memory area can be further determined.
[0084] Specifically, a shared page table refers to a page table structure for shared memory. In a multi-processor system, each processor has its own page table for mapping 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 actual applications, there are many ways to determine the target shared page table corresponding to the shadow virtual memory area, which can be selected according to the actual situation. The embodiments of this specification do not impose any restrictions on this. 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 area. In another possible implementation of this specification, the target shared page table corresponding to the shadow virtual memory area can be created in the shadow management area.
[0086] By applying the solution of the embodiment of this specification, by introducing the design of page table sharing for ordinary shared memory, the page table sharing function can be used for the process without reserving memory in advance, thereby improving the universality of page table sharing. By allocating multiple virtual memory areas to the first process, the page table sharing coverage is improved, and the introduction of the shadow virtual memory area simplifies the positioning of the shared page table and reduces the page table overhead of the shared memory.
[0087] In an optional embodiment of the present specification, the above-mentioned determination of the target shared page table corresponding to the shadow virtual memory area may include the following steps:
[0088] Get the pre-allocated shared page table of the second process;
[0089] The shared page table of the second process is used as the target shared page table corresponding to the shadow virtual memory area.
[0090] It should be noted that there are multiple ways to obtain the pre-allocated shared page table of the second process, which are selected according to the actual situation, and the embodiments of this specification do not limit this. In one possible implementation of this specification, the second process carries a shared page table, and the pre-allocated shared page table of the second process can be directly obtained. 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 solution of the embodiment of this specification, a 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 area, thereby realizing page table sharing between the first process and the second process.
[0092] In another optional embodiment of the present specification, the above-mentioned determination of the target shared page table corresponding to the shadow virtual memory area may include the following steps:
[0093] Allocate a shadow management area for the shadow virtual memory area;
[0094] Create a target shared page table corresponding to the shadow virtual memory area in the shadow management area.
[0095] It should be noted that, since the shared page table of the second process may not be allocated to the shadow virtual memory area, a shadow management area (Shadow MM, Shadow Memory Management) can be allocated to the shadow virtual memory area, and a target shared page table corresponding to the shadow virtual memory area is created in the shadow management area.
[0096] In actual applications, a normal process has one management area and multiple virtual memory areas. The virtual memory area represents an accessible address space that is managed by the management area. When a user creates a virtual memory area during page table sharing, a shadow virtual memory area and a shadow management area are also created. The purpose of creating a shadow management area is to avoid conflicts between the shadow virtual memory area and the original virtual memory area in the management area. When allocating a shadow management area to a shadow virtual memory area, the shadow management area can be allocated based on the virtual memory area, and the shadow management area is shared with the virtual memory area of the second process.
[0097] By applying the solution of the embodiment of this specification, a shadow management area is allocated to the shadow virtual memory area; a target shared page table corresponding to the shadow virtual memory area is created in the shadow management area, thereby realizing page table sharing between the first process and the second process.
[0098] See also Figure 5 , Figure 5 A flow chart of a page fault exception processing method provided by an embodiment of the present specification is shown, which specifically includes the following steps:
[0099] Step 502: In response to page fault exception information triggered by the first process during memory access, determine an abnormal virtual memory area where the page fault exception occurs.
[0100] In one or more embodiments of the present specification, in response to page fault exception information triggered by the first process during memory access, an abnormal virtual memory area where the page fault exception occurs is determined.
[0101] It should be noted that the virtual memory area may have page faults due to various reasons. Therefore, there are various page fault exception information triggered by the first process when accessing the memory. The page fault exception information includes but is not limited to insufficient physical memory corresponding to the virtual memory area, the physical memory corresponding to the virtual memory area is occupied by other processes, the mapping relationship between the virtual address and the physical address of the virtual memory area is lost, etc.
[0102] Specifically, insufficient physical memory corresponding to a virtual memory area means that when the physical memory corresponding to a virtual memory area is insufficient, the operating system may choose to swap out some memory pages to make room for allocating memory to a new virtual memory area. At this time, the swapped out virtual memory area may have a page fault phenomenon.
[0103] The physical memory corresponding to the virtual memory area is occupied by other processes. When the physical memory corresponding to the virtual memory area is occupied by other processes, the operating system may choose to swap out some memory pages to make room for the new virtual memory area. At this time, the swapped out virtual memory area may have page faults.
[0104] The virtual address and physical address mapping relationship of the virtual memory area is lost when the virtual address and physical address mapping relationship of the virtual memory area is lost. The operating system may choose to swap out some memory pages to establish a new virtual address and physical address mapping relationship of the virtual memory area. At this time, the swapped out virtual memory area may have page faults.
[0105] In actual applications, in response to page fault exception information triggered by the first process during memory access, when determining the abnormal virtual memory area where the page fault exception occurs, the page fault exception information can be obtained and parsed, and the virtual memory area corresponding to the page fault exception information can be determined as the abnormal virtual memory area.
[0106] Step 504: Find the shadow virtual memory area allocated for the abnormal virtual memory area, and obtain the target shared page table corresponding to the shadow virtual memory area, wherein the shadow virtual memory area is used to share the virtual memory area of the second process with the same attributes as the abnormal virtual memory area.
[0107] In one or more embodiments of the present specification, in response to page fault exception information triggered by the first process during memory access, after determining the abnormal virtual memory area where the page fault exception occurs, further, a shadow virtual memory area allocated for the abnormal virtual memory area can be searched to obtain a target shared page table corresponding to the shadow virtual memory area.
[0108] In an optional embodiment of the present specification, before searching for the shadow virtual memory area allocated for the abnormal virtual memory area and obtaining the target shared page table corresponding to the shadow virtual memory area, the following steps may also be included:
[0109] Determine whether the abnormal virtual memory area is a virtual memory area shared by the page table;
[0110] The above-mentioned searching for the shadow virtual memory area allocated for the abnormal virtual memory area and obtaining the target shared page table corresponding to the shadow virtual memory area may include the following steps:
[0111] In the case where the abnormal virtual memory area is a virtual memory area shared by the page table, a shadow virtual memory area allocated for the abnormal virtual memory area is searched to obtain a target shared page table corresponding to the shadow virtual memory area.
[0112] In actual applications, there are many ways to determine whether an abnormal virtual memory area is a virtual memory area shared by a page table, and the specific method is selected according to the actual situation. The embodiments of this specification do not impose any restrictions on this. In one possible implementation of this specification, it can be manually determined whether the abnormal virtual memory area is a virtual memory area shared by a page table. In another possible implementation of this specification, a page table sharing identifier corresponding to the abnormal virtual memory area can be obtained; according to the page table sharing identifier, it is determined whether the abnormal virtual memory area is a virtual memory area shared by a page table. Among them, the implementation method of "obtaining the page table sharing identifier corresponding to the abnormal virtual memory area" is the same as the above-mentioned implementation method of "obtaining the page table sharing identifiers corresponding to multiple virtual memory areas", and the embodiments of this specification will not be repeated.
[0113] It should be noted that, when the abnormal virtual memory area is not a virtual memory area with page tables shared, the abnormal virtual memory area is determined to be a normal virtual memory area, and page tables are not shared; when the abnormal virtual memory area is a virtual memory area with page tables shared, the shadow virtual memory area allocated to the abnormal virtual memory area is searched to obtain the target shared page table corresponding to the shadow virtual memory area.
[0114] By applying the solution of the embodiments of this specification, it is determined whether the abnormal virtual memory area is a virtual memory area with page tables shared; when the abnormal virtual memory area is a virtual memory area with page tables shared, a shadow virtual memory area allocated to the abnormal virtual memory area is searched, and a target shared page table corresponding to the shadow virtual memory area is obtained, thereby realizing page table sharing for the abnormal virtual memory area that supports page table sharing.
[0115] In actual applications, there are many ways to find the shadow virtual memory area allocated for the abnormal virtual memory area and obtain the target shared page table corresponding to the shadow virtual memory area. The specific method is selected according to the actual situation, and the embodiments of this specification do not impose any limitation on this.
[0116] In a possible implementation of the present specification, the above-mentioned searching for the shadow virtual memory area allocated for the abnormal virtual memory area and obtaining the target shared page table corresponding to the shadow virtual memory area may include the following steps:
[0117] Find the shadow virtual memory area allocated for the abnormal virtual memory area;
[0118] In a case where the shadow virtual memory area has been allocated with a target shared page table, the target shared page table is acquired.
[0119] It should be noted that after searching for the shadow virtual memory area allocated for the abnormal virtual memory area, it can be determined whether the shadow virtual memory area has been allocated with the target shared page table. If so, it means that the target shared page table has been stored in the shadow virtual memory area. At this time, the target shared page table can be directly obtained.
[0120] Apply the solution of the embodiments of this specification to find the shadow virtual memory area allocated for the abnormal virtual memory area; when the shadow virtual memory area has been allocated a target shared page table, obtain the target shared page table, accurately obtain the target shared page table, and reduce the page table overhead of the shared memory and the processing overhead of the page fault exception based on the target shared page table.
[0121] In another possible implementation of the present specification, the above-mentioned searching for the shadow virtual memory area allocated for the abnormal virtual memory area and obtaining the target shared page table corresponding to the shadow virtual memory area may include the following steps:
[0122] Find the shadow virtual memory area allocated for the abnormal virtual memory area;
[0123] In a case where the shadow virtual memory area is not allocated with a target shared page table, a target shared page table is allocated for the shadow virtual memory area.
[0124] It should be noted that after searching for the shadow virtual memory area allocated for the abnormal virtual memory area, it can be determined whether the shadow virtual memory area has been allocated with a target shared page table. If not, it means that the target shared page table has not been stored in the shadow virtual memory area. At this time, the target shared page table can be allocated to the shadow virtual memory area.
[0125] By applying the solution of the embodiments of this specification, a shadow virtual memory area allocated for an abnormal virtual memory area is searched; when a target shared page table is not allocated to the shadow virtual memory area, a target shared page table is allocated to the shadow virtual memory area, and based on the target shared page table, the page table overhead of the shared memory and the processing overhead of the page fault exception are reduced.
[0126] In an optional embodiment of the present specification, the above-mentioned allocation of a target shared page table to the shadow virtual memory area may include the following steps:
[0127] Get the pre-allocated shared page table of the second process;
[0128] The shared page table of the second process is used as the target shared page table corresponding to the shadow virtual memory area.
[0129] It should be noted that the implementation method 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 area" is the same as the above Figure 4The implementation method 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 area" in the provided page table sharing method is the same, and will not be repeated in detail in the embodiments of this specification.
[0130] By applying the solution of the embodiment of this specification, a 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 area, thereby realizing page table sharing between the first process and the second process.
[0131] In another optional embodiment of the present specification, the above-mentioned allocation of a target shared page table to the shadow virtual memory area may include the following steps:
[0132] Allocate a shadow management area for the shadow virtual memory area;
[0133] Create a target shared page table corresponding to the shadow virtual memory area in the shadow management area.
[0134] It should be noted that the implementation method of "allocating a shadow management area for the shadow virtual memory area; creating a target shared page table corresponding to the shadow virtual memory area in the shadow management area" is the same as the above Figure 4 The implementation method of "allocating a shadow management area to a shadow virtual memory area; creating a target shared page table corresponding to the shadow virtual memory area in the shadow management area" in the provided page table sharing method is the same, and will not be repeated in the embodiments of this specification.
[0135] Apply the solution of the embodiment of this specification, apply the solution of the embodiment of this specification, allocate a shadow management area for the shadow virtual memory area; create a target shared page table corresponding to the shadow virtual memory area in the shadow management area, and realize page table sharing between the first process and the second process.
[0136] Step 506: Use the target shared page table to map the physical memory for the virtual memory of the first process.
[0137] In one or more embodiments of the present specification, in response to page fault exception information triggered by a first process during memory access, an abnormal virtual memory area where a page fault exception occurs is determined; a shadow virtual memory area allocated to the abnormal virtual memory area is searched, and after obtaining a target shared page table corresponding to the shadow virtual memory area, 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 the page table is used to store the mapping relationship between the virtual address and the physical address of the virtual memory area, after obtaining the target shared page table, the physical memory can be mapped for the virtual memory of the first process according to the mapping relationship between the virtual address and the physical address stored in the target shared page table.
[0139] By applying the scheme of the embodiments of this specification, by introducing a page table sharing design for ordinary shared memory, the page table sharing function can be used for the process without reserving memory in advance, thereby improving the universality of page table sharing. By allocating multiple virtual memory areas to the first process, the page table sharing coverage is improved. By introducing a shadow virtual memory area, the shared page table positioning is simplified, and by using the target shared page table, the virtual memory of the first process is mapped to the physical memory, thereby reducing the page table overhead of the shared memory and the processing overhead of the page fault exception.
[0140] The following combination Figure 6 , the page fault exception handling method is further described. Among them, Figure 6 A process flow chart of a page table sharing method provided by an embodiment of the present specification is shown, which specifically includes:
[0141] In response to an access request of a first process to access memory, a plurality of virtual memory areas are allocated to the first process; in user state, when mmap() is called to create a mapping, a page table sharing identifier is passed in for determining whether the target virtual memory area is a common virtual memory area or a virtual memory area shared by a page table; in kernel state, if the target virtual memory area is a virtual memory area shared by a page table, a shadow virtual memory area and a shadow management area are allocated, wherein the attributes of the shadow virtual memory area are the same as those of the virtual memory area;
[0142] In response to page fault exception information triggered by the first process of the application during memory access, determine the abnormal virtual memory area where the page fault exception occurs, and start allocating page tables and target pages at all levels; judge whether the abnormal virtual memory area is a virtual memory area shared by page tables: if not, determine that the abnormal virtual memory area is a normal virtual memory area; if so, find the shadow virtual memory area allocated to the abnormal virtual memory area, and traverse whether the target shared page table of the shadow virtual memory area is allocated: if so, directly use the target shared page table; if not, allocate the target shared page table to the shadow virtual memory area, and if page faults occur in other child processes subsequently, the target shared page table is no longer allocated to the shadow virtual memory area, and the target shared page table at the same page table entry level is used.
[0143] The scheme of the embodiments of the present specification is applied. The shared page table method provided in the embodiments of the present specification is based on 4K pages, which ensures the universality of the shared page table; the shadow virtual memory area is introduced to automatically align the virtual memory area, which ensures a very high page table sharing coverage rate and realizes rapid positioning of the shared page table; the page table sharing method is simple to use, and the pages used are exactly the same as the normal memory allocation. There is no need to reserve memory in advance, which solves the problem that other applications cannot use the reserved memory in scenarios with large shared memory; by allocating separate shadow virtual memory areas and shadow management areas to manage the sharable page tables, when a page fault occurs, it can be quickly determined whether the shared page table has been allocated, which solves the problem of high overhead in finding shared page tables in scenarios with a large number of concurrent processes, and increases the robustness of the scheme.
[0144] In actual applications, the shared page table method provided in the embodiment of this specification is tested under the microprocessor architecture, and the process concurrency of the test application is set to 100. During the test, see Table 1 below. The page table overhead in the shared memory scenario of 20G, 50G, 100G, 200G and 400G is used in the test application. For test data, see the test data table:
[0145] Table 1 Test data table
[0146]
[0147] It should be noted that, for an application with 50 concurrent processes, theoretical calculations show that the page table overhead can be saved by about 50%.
[0148] Therefore, the page table sharing method provided in the embodiments of the present specification introduces a page table sharing design for ordinary shared memory, and the page table sharing function can be used for any process without reserving memory in advance; the shadow virtual memory area and the shadow management area are introduced to simplify the positioning of the shared page table, and the shared memory position can be located with a time complexity of O(1) for any process concurrency; the virtual memory area can be automatically aligned to 2M, and the page table sharing coverage rate 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 the shared memory. When the switch is turned off, it is consistent with the original Linux kernel behavior.
[0149] Corresponding to the above-mentioned page table sharing method embodiment, this specification also provides a page table sharing device embodiment, Figure 7 FIG. 2 shows a schematic diagram of a page table sharing device provided by an embodiment of the present specification. Figure 7 As shown, the device comprises:
[0150] A first allocation module 702 is configured to allocate multiple virtual memory areas to the first process in response to an access request of the first process to access the memory;
[0151] A second allocation module 704 is configured to allocate a shadow virtual memory area for a target virtual memory area among the multiple virtual memory areas, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attribute as the target virtual memory area;
[0152] The first determination module 706 is configured to determine a target shared page table corresponding to the shadow virtual memory area.
[0153] Optionally, the device further includes: a screening module configured to screen out a target virtual memory area from the multiple virtual memory areas, wherein the target virtual memory area is a virtual memory area shared by the page table.
[0154] Optionally, the screening module is further configured to obtain page table sharing identifiers respectively corresponding to the multiple virtual memory areas; and screen out the target virtual memory area from the multiple virtual memory areas according to the page table sharing identifiers.
[0155] Optionally, the first determining module 706 is further configured to obtain a pre-allocated shared page table of the second process; and use the shared page table of the second process as a target shared page table corresponding to the shadow virtual memory area.
[0156] Optionally, the first determining module 706 is further configured to allocate a shadow management area for the shadow virtual memory area; and create a target shared page table corresponding to the shadow virtual memory area in the shadow management area.
[0157] By applying the solution of the embodiment of this specification, by introducing the design of page table sharing for ordinary shared memory, the page table sharing function can be used for the process without reserving memory in advance, thereby improving the universality of page table sharing. By allocating multiple virtual memory areas to the first process, the page table sharing coverage is improved, and the introduction of the shadow virtual memory area simplifies the positioning of the shared page table and reduces the page table overhead of the shared memory.
[0158] The above is a schematic scheme of a page table sharing device of this embodiment. It should be noted that the technical scheme of the page table sharing device and the technical scheme of the above-mentioned page table sharing method belong to the same concept, and the details not described in detail in the technical scheme of the page table sharing device can be referred to the description of the technical scheme of the above-mentioned page table sharing method.
[0159] Corresponding to the above-mentioned page fault exception handling method embodiment, this specification also provides a page fault exception handling device embodiment, Figure 8 FIG. 2 shows a schematic diagram of a structure of a page fault exception handling device provided by an embodiment of the present specification. Figure 8 As shown, the device comprises:
[0160] The second determining module 802 is configured to determine an abnormal virtual memory area where a page fault exception occurs in response to page fault exception information triggered by the first process in the process of accessing the memory;
[0161] A search module 804 is configured to search for a shadow virtual memory area allocated for the abnormal virtual memory area, and obtain a target shared page table corresponding to the shadow virtual memory area, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attribute as the abnormal virtual memory area;
[0162] The mapping module 806 is configured to map the physical memory for the virtual memory of the first process using the target shared page table.
[0163] Optionally, the device also includes: a judgment module, configured to judge whether the abnormal virtual memory area is a virtual memory area shared by page tables; a search module 804, further configured to search for a shadow virtual memory area allocated to the abnormal virtual memory area when the abnormal virtual memory area is a virtual memory area shared by page tables, and obtain a target shared page table corresponding to the shadow virtual memory area.
[0164] Optionally, the search module 804 is further configured to search for a shadow virtual memory area allocated for the abnormal virtual memory area; and obtain the target shared page table when the shadow virtual memory area has been allocated with the target shared page table.
[0165] Optionally, the search module 804 is further configured to search for a shadow virtual memory area allocated for the abnormal virtual memory area; and when the shadow virtual memory area is not allocated with a target shared page table, allocate a target shared page table for the shadow virtual memory area.
[0166] Optionally, the search module 804 is further configured to obtain a pre-allocated shared page table of the second process; and use the shared page table of the second process as a target shared page table corresponding to the shadow virtual memory area.
[0167] Optionally, the search module 804 is further configured to allocate a shadow management area for the shadow virtual memory area; and create a target shared page table corresponding to the shadow virtual memory area in the shadow management area.
[0168] By applying the scheme of the embodiments of this specification, by introducing a page table sharing design for ordinary shared memory, the page table sharing function can be used for the process without reserving memory in advance, thereby improving the universality of page table sharing. By allocating multiple virtual memory areas to the first process, the page table sharing coverage is improved. By introducing a shadow virtual memory area, the shared page table positioning is simplified, and by using the target shared page table, the virtual memory of the first process is mapped to the physical memory, thereby reducing the page table overhead of the shared memory and the processing overhead of the page fault exception.
[0169] The above is a schematic scheme of a page fault exception handling device of this embodiment. It should be noted that the technical scheme of the page fault exception handling device and the technical scheme of the above-mentioned page fault exception handling method belong to the same concept, and the details not described in detail in the technical scheme of the page fault exception handling device can be referred to the description of the technical scheme of the above-mentioned page fault exception handling method.
[0170] Fig. 9 The structure block diagram of a computing device provided by an embodiment of the present 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 the database 950 is used to store data.
[0171] The computing device 900 also includes an access device 940 that enables the computing device 900 to communicate via one or more networks 960. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 940 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world microwave interconnection access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0172] In one embodiment of the present specification, the above components of the computing device 900 and Fig. 9 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig. 9 The computing device structure block diagram shown is only for the purpose of illustration, 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 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 900 may also be a mobile or stationary server.
[0174] The processor 920 is used to execute the following computer executable instructions, which, when executed by the processor, implement the steps of the above-mentioned page table sharing method or page fault exception handling method.
[0175] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned page table sharing method and page fault exception handling method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned page table sharing method or page fault exception handling method.
[0176] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the above-mentioned page table sharing method or page fault exception handling method.
[0177] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned page table sharing method and page fault exception handling method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned page table sharing method or page fault exception handling method.
[0178] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned page table sharing method or page fault exception handling method.
[0179] The above is a schematic scheme of a computer program of this embodiment. It should be noted that the technical scheme of the computer program and the technical scheme of the above-mentioned page table sharing method and page fault exception handling method belong to the same concept, and the details not described in detail in the technical scheme of the computer program can be referred to the description of the technical scheme of the above-mentioned page table sharing method or page fault exception handling method.
[0180] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0181] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0182] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0183] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0184] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A page table sharing method, comprising: In response to a request from a first process to access a memory, allocating a plurality of virtual memory areas to the first process; Allocating a shadow virtual memory area for a target virtual memory area among the multiple virtual memory areas, wherein the shadow virtual memory area is used to share a virtual memory area of a second process having the same attribute as the target virtual memory area; A target shared page table corresponding to the shadow virtual memory area is determined.
2. The method according to claim 1, before allocating the shadow virtual memory area to the target virtual memory area among the multiple virtual memory areas, further comprising: A target virtual memory area is screened out from the multiple virtual memory areas, wherein the target virtual memory area is a virtual memory area shared by a page table.
3. The method according to claim 2, wherein the step of selecting a target virtual memory area from the plurality of virtual memory areas comprises: Obtaining page table sharing identifiers corresponding to the multiple virtual memory areas respectively; According to the page table sharing identifier, a target virtual memory area is screened out from the multiple virtual memory areas.
4. The method according to claim 1, wherein determining the target shared page table corresponding to the shadow virtual memory area comprises: Obtaining a 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 area.
5. The method according to claim 1, wherein determining the target shared page table corresponding to the shadow virtual memory area comprises: Allocating a shadow management area to the shadow virtual memory area; A target shared page table corresponding to the shadow virtual memory area is created in the shadow management area.
6. A page fault exception processing method, comprising: In response to page fault exception information triggered by the first process during memory access, determining an abnormal virtual memory area where the page fault exception occurs; Searching for a shadow virtual memory area allocated for the abnormal virtual memory area, and obtaining a target shared page table corresponding to the shadow virtual memory area, wherein the shadow virtual memory area is used to share a virtual memory area of the second process with the same attribute as the abnormal virtual memory area; The target shared page table is used to map the physical memory for the virtual memory of the first process.
7. The method according to claim 6, before searching for the shadow virtual memory area allocated for the abnormal virtual memory area and obtaining the target shared page table corresponding to the shadow virtual memory area, further comprises: Determining whether the abnormal virtual memory area is a virtual memory area shared by a page table; The searching for the shadow virtual memory area allocated to the abnormal virtual memory area to obtain a target shared page table corresponding to the shadow virtual memory area includes: In the case that the abnormal virtual memory area is a virtual memory area shared by a page table, a shadow virtual memory area allocated to the abnormal virtual memory area is searched to obtain a target shared page table corresponding to the shadow virtual memory area.
8. The method according to claim 6, wherein searching for the shadow virtual memory area allocated to the abnormal virtual memory area and obtaining a target shared page table corresponding to the shadow virtual memory area comprises: Finding a shadow virtual memory area allocated to the abnormal virtual memory area; In a case where the shadow virtual memory area has been allocated with a target shared page table, the target shared page table is obtained.
9. The method according to claim 6, wherein searching for the shadow virtual memory area allocated to the abnormal virtual memory area and obtaining a target shared page table corresponding to the shadow virtual memory area comprises: Finding a shadow virtual memory area allocated to the abnormal virtual memory area; In a case where the shadow virtual memory area is not allocated with a target shared page table, a target shared page table is allocated for the shadow virtual memory area.
10. The method according to claim 9, wherein allocating a target shared page table to the shadow virtual memory area comprises: Obtaining a 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 area.
11. The method according to claim 9, wherein allocating a target shared page table to the shadow virtual memory area comprises: Allocating a shadow management area to the shadow virtual memory area; A target shared page table corresponding to the shadow virtual memory area is created in the shadow management area.
12. 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. When the computer-executable instructions are executed by the processor, the steps of the method described in any one of claims 1 to 5 or any one of claims 6 to 11 are implemented.
13. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the method described in any one of claims 1 to 5 or any one of claims 6 to 11.
Citation Information
Patent Citations
Memory sharing method and device, electronic equipment and storage medium
CN111813584A
Multi-dimensional process execution method and system for high-performance computing and medium
CN116880971A
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
Memory management method for supporting shared virtual memories with hybrid page table utilization and related machine readable medium
US20160179686A1
Cited By
Memory sharing method and device, electronic equipment, storage medium and product
CN121880049A