Page missing exception processing method, device and equipment
By creating multiple processing modules in the computing device and awakening the corresponding processing modules according to the number of page missing exceptions, the problem of low concurrency in the prior art processing of page missing exceptions is solved, and the processing efficiency is improved.
Patent Information
- Application Number
- CN202311811420.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2025-06-27
AI Technical Summary
In the prior art, the concurrency of page missing exception processing is low, resulting in low processing efficiency.
Create multiple processing modules in the computing device and put them in a dormant state. When a page-failed exception occurs in a memory access operation, the corresponding number of processing modules will be awakened according to the number of page-failed exceptions, and other processing modules will continue to be in a dormant state.
By waking up an appropriate number of processing modules, the waste of CPU scheduling resources is avoided, and the parallel processing of different page-missible exceptions is ensured, which improves the processing efficiency of page-missible exceptions.
Smart Images

Figure CN120216227A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technologies, and in particular, to a method, apparatus, and device for handling page faults. Background Art
[0002] An operating system associates virtual memory and physical memory based on a paging mechanism. Herein, every 4KB bytes are regarded as one page, that is, a virtual memory space with a size of 4KB bytes is called a virtual memory page, and a physical memory space with a size of 4KB bytes is called a physical memory page. A central processing unit (CPU) accesses physical memory through virtual memory. Specifically, virtual memory pages and physical memory pages are associated. When performing an access operation, the CPU can access the physical memory page associated with the virtual memory page through the virtual memory page. If, when performing an access operation, the virtual memory page used by the CPU is not associated with a physical memory page, a page fault occurs.
[0003] When a memory swap-in is triggered during an access operation, a large number of page faults occur. Currently, the concurrency of the page fault handling solution is low, resulting in low processing efficiency. Summary of the Invention
[0004] This application provides a method, apparatus, and device for handling page faults, which can improve the efficiency of handling page faults.
[0005] In a first aspect, a method for handling page faults is provided. The method is applied to a computing device and includes: creating a plurality of processing modules for handling page faults and putting the plurality of processing modules in a dormant state; when at least one page fault occurs in a memory access operation of the computing device, waking up at least one processing module among the plurality of processing modules based on the number of page faults in the at least one page fault, where the number of page faults in the at least one page fault is greater than or equal to the number of processing modules among the plurality of processing modules; the processing modules other than the at least one processing module among the plurality of processing modules continue to be in a dormant state; and the at least one processing module is used to handle the at least one page fault. Exemplarily, the processing module may be a thread.
[0006] This method can create multiple processing modules in a computing device, which are used to handle page faults. These multiple processing modules are in a dormant state by default. When a page fault occurs during a memory access operation of the computing device, based on the number of page faults that occur, the corresponding number of processing modules are woken up, and the other processing modules continue to be in a dormant state. In this way, when a page fault occurs, an appropriate number of processing modules are woken up, avoiding the waste of CPU scheduling resources caused by waking up too many processing modules, and can also ensure the parallel processing of different page faults, improving the processing efficiency of page faults.
[0007] In a possible implementation, different processing modules among the multiple processing modules are associated with different files. The files are used to record information about page faults, and the processing modules associated with the files are used to process page faults based on the information. The method further includes: when at least one page fault occurs during a memory access operation of the computing device, recording the information of the at least one page fault into the files associated with at least one processing module; and at least one processing module is used to read the information of the at least one page fault from the files associated with the at least one processing module, and process the at least one page fault based on the information of the at least one page fault.
[0008] In this implementation, the information of different page faults is recorded into different files. In this way, different processing modules can read the information of page faults from different files, avoiding the serial reading of the information of different page faults from the same file by different processing modules, improving the concurrency of the processing of multiple page faults, and improving the processing efficiency of page faults.
[0009] In a possible implementation, the computing device includes a cluster of processing units; different processing modules among the multiple processing modules are associated with different processing units in the cluster of processing units; wherein, at least one page fault is a page fault that occurs when the processing unit associated with at least one processing module performs a memory access operation.
[0010] In this implementation, different processing modules are associated with different processing units, realizing the per-core processing of page faults, that is, the processing module is used to process the page faults that occur during the memory access operation of the processing unit associated with the processing module, and the page faults that occur during the memory access operation of the processing unit are processed by the processing module associated with the processing unit. Different processing modules are associated with different processing units. Therefore, different processing modules are independent of each other and do not affect each other, ensuring the full concurrent processing of page faults that occur during the memory access operations of different processing units, and improving the processing efficiency of page faults when page faults occur simultaneously during the memory access operations of multiple processing units.
[0011] In a possible implementation, the processing unit cluster is a multi-core processor, and different processing units in the processing unit cluster are different computing cores or different groups of computing cores in the multi-core processor.
[0012] In a possible implementation, at least one processing module is used to process at least one page fault exception, including: at least one processing module triggers the computing device to obtain and cache the data to be accessed corresponding to the memory access operation; the method further includes: associating the physical page caching the data to be accessed with the virtual address corresponding to at least one page fault exception, so that the access operation accesses the data to be accessed in the physical page through the virtual address.
[0013] In this implementation, by reusing the physical memory page caching the data to be accessed, there is no need to apply for a physical memory page for the virtual memory page, saving the computing resource overhead of applying for a physical memory page and avoiding the lock conflict in the application of the physical memory page. Moreover, using the physical memory page caching the data to be accessed as the physical memory page associated with the virtual memory page saves the operation of copying the data to be accessed to the physical memory page associated with the virtual memory page, thus reducing the computing resource overhead and the memory bandwidth overhead. And it can reduce the time overhead of page fault exception handling and improve the efficiency of page fault exception handling.
[0014] In a second aspect, a page fault exception handling device is provided. The device is configured in a computing device and includes: a creation unit for creating a plurality of processing modules for handling page fault exceptions and putting the plurality of processing modules in a dormant state; a wake-up unit for waking up at least one processing module among the plurality of processing modules based on the number of page fault exceptions in at least one page fault exception when a memory access operation of the computing device has at least one page fault exception; wherein, the number of page fault exceptions in at least one page fault exception is greater than or equal to the number of processing modules in at least one processing module; the processing modules other than at least one processing module among the plurality of processing modules continue to be in a dormant state; and at least one processing module is used to process at least one page fault exception.
[0015] In a possible implementation, different processing modules among the plurality of processing modules are associated with different files, the files are used to record information about page fault exceptions, and the processing modules associated with the files are used to process page fault exceptions based on the information; the device further includes: a recording unit for recording the information about at least one page fault exception into the files associated with at least one processing module when a memory access operation of the computing device has at least one page fault exception; and at least one processing module is used to read the information about at least one page fault exception from the files associated with at least one processing module and process at least one page fault exception based on the information about at least one page fault exception.
[0016] In a possible implementation, a computing device includes a cluster of processing units; different processing modules among a plurality of processing modules are associated with different processing units in the cluster of processing units; wherein, at least one page fault is a page fault that occurs when a processing unit associated with at least one processing module performs a memory access operation.
[0017] In a possible implementation, the cluster of processing units is a multi-core processor, and different processing units in the cluster of processing units are different computing cores or different groups of computing cores in the multi-core processor.
[0018] In a possible implementation, at least one processing module is configured to handle at least one page fault, including: at least one processing module triggers the computing device to obtain and cache data to be accessed corresponding to the memory access operation; the apparatus further includes: an association unit, configured to associate the physical page caching the data to be accessed with the virtual address corresponding to at least one page fault, so that the access operation accesses the data to be accessed in the physical page through the virtual address.
[0019] In a third aspect, a computing device is provided, including: a memory, configured to store an executable program; a processor, configured to execute the method provided in the first aspect by running the executable program.
[0020] In a fourth aspect, a computer-readable storage medium is provided, including computer program instructions, when the computer program instructions are executed by a computing device, the computing device executes the method provided in the first aspect.
[0021] In a fifth aspect, a computer program product including instructions is provided, when the instructions are run by a computing device, the computing device is caused to execute the method provided in the first aspect.
[0022] Wherein, the beneficial effects of the second aspect to the fifth aspect can be referred to the description of the beneficial effects of the first aspect above, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a schematic structural diagram of a computing device provided by an embodiment of the present application;
[0024] Figure 2 is a schematic diagram of the association between a processing module and a processing unit provided by an embodiment of the present application;
[0025] Figure 3 is a flowchart of a method for handling a page fault provided by an embodiment of the present application;
[0026] Figure 4A is a schematic diagram of the association between a virtual memory page and a physical memory page provided by an embodiment of the present application;
[0027] Figure 4BA schematic diagram showing the association between virtual memory pages and physical memory pages provided by an embodiment of the present application;
[0028] Figure 5 A schematic structural diagram of a computing device management apparatus provided by an embodiment of the present application;
[0029] Figure 6 A schematic structural diagram of a computing device provided by an embodiment of the present application. Detailed implementation manners
[0030] The solutions provided by the embodiments of the present application will be described below in conjunction with the accompanying drawings. Among them, in the embodiments of the present application, "a plurality of" means two or more, and "a variety of" means two or more. "First", "second", etc. are only used to distinguish similar objects and do not have to be used to describe a specific order or the number of objects.
[0031] To facilitate understanding of the solutions provided by the embodiments of the present application, the technical terms that may be involved in the embodiments of the present application will be introduced first.
[0032] Memory swap-in: It refers to swapping data in the swap space (such as a disk, etc.) into the memory.
[0033] Memory swap-out: It refers to swapping data in the memory out to the swap space (such as a disk, etc.).
[0034] Swap space: It refers to the storage space for data exchange with the memory of the computing device. The swap space can be a local storage device of the computing device or a remote storage device of the computing device. Among them, the storage device can be a disk or the memory of a computing device other than the computing device.
[0035] Page fault exception: It refers to the phenomenon that when performing a memory access operation, the virtual memory page used by the processor is not associated with a physical memory page. Among them, the memory access operation includes accessing the physical memory page through the virtual memory page to access the data stored in the physical memory page. By associating the virtual memory page with the physical memory page, the processor performing the memory access operation can use the virtual memory page to access the physical memory page associated with the virtual memory page. When the virtual memory page of the memory access operation is not associated with a physical memory page, a page fault exception occurs.
[0036] User-mode page fault handling mechanism (userfaultfd): A mechanism provided by the Linux operating system that allows user-mode programs to customize the page fault handling strategy and process. Generally speaking, the operating system creates a userfaultfd object through the userfaultfd mechanism. This userfaultfd object delegates the page fault handling function to the user-mode program, that is, through the userfaultfd object, the user-mode program executes the page fault handling function, so that the user-mode program can handle page faults.
[0037] User-mode program: Application programs, processes, and threads running in the user space of the operating system. User-mode programs have limited access to the host's hardware resources and can only access some of the hardware resources.
[0038] Kernel-mode program: Programs and threads running in the kernel space of the operating system. Kernel-mode programs have the permission to access all the hardware resources of the host and can access all the hardware resources of the host.
[0039] The sleeping state of a thread refers to the blocked state or the suspended state.
[0040] In one solution, based on userfaultfd, a monitoring thread (uffd monitor) is created in user mode. The monitoring thread is used to handle page faults. In this solution, since only one monitoring thread is created, when multiple page faults occur simultaneously, the monitoring thread processes these multiple page faults serially, resulting in low processing efficiency.
[0041] In another solution, based on userfaultfd, multiple monitoring threads are created in user mode. Whenever a page fault occurs, these multiple monitoring threads are awakened to handle the page fault. In this solution, when only one page fault occurs, all the monitoring threads are also awakened, which wastes CPU scheduling resources. Moreover, in this solution, the information of all page faults is recorded in the same file, and multiple monitoring threads read this file serially to read the information of the corresponding page faults respectively. That is to say, the information of multiple page faults is read serially, so it is impossible to achieve full concurrent processing of multiple page faults, and the processing efficiency is also low.
[0042] In addition, in the related solutions, when handling page faults, it is necessary to reapply for a physical memory page for the virtual memory page, and then copy the data that needs to be swapped into the memory to the newly applied physical memory page. Applying for a physical memory page causes a lock conflict in physical memory, and copying the data to the newly applied physical memory page also increases the CPU computing overhead and the memory bandwidth overhead, affecting the performance of the computing device.
[0043] An embodiment of the present application provides a method for handling page fault exceptions. In this method, multiple processing modules can be created in a computing device, and these processing modules are used to handle page fault exceptions. Among them, the processing module can be a thread. When the registration of multiple processing modules is completed, the multiple processing modules are put into a dormant state. When a page fault exception occurs in the memory access operation of the computing device, a corresponding number of processing modules are awakened based on the number of page fault exceptions, and the remaining processing modules continue to be in the dormant state. The awakened processing modules are used to handle the occurred page fault exceptions. In this method, by awakening a corresponding number of processing modules based on the number of page fault exceptions, it not only avoids the waste of CPU scheduling resources caused by awakening too many processing modules, but also ensures that different page fault exceptions can be processed in parallel, thereby improving the processing efficiency of page fault exceptions.
[0044] Next, the method for handling page fault exceptions provided by the embodiment of the present application will be described.
[0045] Figure 1 A computing device 100 that can be used to implement the method for handling page fault exceptions is shown. The computing device 100 can be any device, equipment, platform or cluster with data processing capabilities. For example, the computing device 100 can be a terminal device, a server, etc. The terminal device can be a mobile phone, a tablet computer, a vehicle-mounted terminal, a laptop computer, a handheld computer, a computer, etc.
[0046] As Figure 1 shown, the computing device 100 includes a physical memory 130. In some embodiments, the physical memory 130 can specifically be a double data rate synchronous dynamic random access memory (DDR). In some embodiments, the physical memory 130 can be a synchronous dynamic random access memory (SDRAM). The swap space 140 is the swap space of the physical memory 130. That is to say, the data in the physical memory 130 can be swapped out to the swap space 140, and the data in the swap space 140 can be swapped into the physical memory 130. In some embodiments, the swap space 140 can be a local storage device of the computing device 100, such as a disk. In some embodiments, the swap space 140 can be a remote storage device of the computing device 100, such as the disk or memory of a computing device outside the computing device 100.
[0047] As Figure 1As shown, the computing device 100 is installed with an operating system 110. The operating system 110 can be a Linux operating system. The user space of the operating system 110 has multiple processing modules such as a processing module 111 and a processing module 112, as well as a swapping module, etc. Among them, the processing modules in the multiple processing modules such as the processing module 111 and the processing module 112 are used to process page faults. For example, they read the information of the page fault and send the read page fault information to the swapping module. In some embodiments, the information of the page fault includes the mapping relationship between the virtual memory page where the page fault occurs and the address in the swap space. The address mapped to the virtual memory page in the swap space stores the data corresponding to the virtual memory page. The swapping module is used to read the data corresponding to the virtual memory page where the page fault occurs from the swap space 140 based on the information of the page fault and write the read data into the physical memory 130. In other embodiments, the information of the page fault includes the virtual memory page where the page fault occurs. The swapping module includes the mapping relationship between the virtual memory page and the address in the swap space. The address mapped to the virtual memory page in the swap space stores the data corresponding to the virtual memory page. The processing module can send the read page fault information to the swapping module. The swapping module is used to read the data corresponding to the virtual memory page where the page fault occurs from the swap space 140 based on the virtual memory page and the mapping relationship between the virtual memory page and the address in the swap space in the information of the page fault and write the read data into the physical memory 130.
[0048] In some embodiments, the processing module can be a thread.
[0049] Among them, the default state of the multiple processing modules such as the processing module 111 and the processing module 112 is the sleep state. That is to say, after the multiple processing modules such as the processing module 111 and the processing module 112 are created, they enter the sleep state. Among them, the sleep state of the processing module refers to the blocked state or the suspended state.
[0050] When the processing module is awakened, the processing module can enter the working state and can process page faults. The multiple processing modules such as the processing module 111 and the processing module 112 are all registered in the management module in the kernel space. Among them, the management module can manage the processing modules registered to the management module, such as awakening the processing module in the sleep state, etc. Exemplarily, the management module can execute the userfaultfd mechanism.
[0051] Among them, the swapping module can be one or more functions, can run in one or more processes in the user space, or can run in one or more threads in the user space. The management module can be one or more functions and can run in one or more threads in the kernel space.
[0052] In some embodiments, the computing device 100 includes a processing unit cluster 120. The processing unit cluster 120 can serve as the processor of the computing device 100, such as a CPU. The processing unit cluster 120 can be a multi-core processor. Among them, one processing unit can be a computing core or a group of computing cores in the multi-core processor. Among them, a group of computing cores can include two or more computing cores.
[0053] The management module can associate different processing modules with different processing units in the processing unit cluster 120 and record the association relationship between the processing modules and the processing units. For example, associate processing module 111 with processing unit 121, and associate processing module 112 with processing unit 122. When the management module detects a page fault exception in the memory access operation executed by a certain processing unit, the management module wakes up the processing module associated with the processing unit so that the processing module processes the page fault exception. When page fault exceptions occur simultaneously in the memory access operations executed by two or more processing units, the management module can wake up the processing modules associated with the two or more processing units at the same time. Among them, after the processing modules associated with different processing units are woken up, they can each process the page fault exceptions that occur in the corresponding processing units. That is to say, the processing of page fault exceptions by different processing modules is independent of each other and does not affect each other, that is, the processing of page fault exceptions by different processing modules is completely concurrent.
[0054] In some embodiments, the computing device 100 can include multiple files for recording information about page fault exceptions. Among them, different processing modules among multiple processing modules such as processing module 111 and processing module 112 are associated with different files among the multiple files. After the processing module is woken up, it can read the information about the page fault exception from the file associated with the processing module and process the page fault exception based on the read information about the page fault exception.
[0055] When the management module discovers multiple page fault exceptions, it can record the information about the multiple page fault exceptions into multiple files respectively, where different files record the information about different page fault exceptions. Thus, after different processing modules are woken up, they can respectively read the information about the page fault exceptions from different files, avoiding different processing modules serially reading the information about the page fault exceptions and improving the concurrency of page fault exception processing.
[0056] In an example of this embodiment, different files among multiple files can be respectively associated with different processing units in the processing unit cluster 120. Among them, as described above, different processing modules are also associated with different processing units. When the management module discovers that a page fault exception occurs in the memory access operation of a certain processing unit, the management module records the information of the page fault exception in the file associated with the processing unit, and wakes up the processing module associated with the processing unit. The woken processing module reads the information of the page fault exception from the file associated with the processing unit associated with the processing module, and then processes the page fault exception based on the information of the page fault exception.
[0057] The above example introduced the computing device 100. Next, in combination with the computing device 100, the process of the page fault exception handling method provided by the embodiments of the present application will be introduced. As Figure 3 shown, the method includes the following steps.
[0058] Step 301, create multiple processing modules for handling page fault exceptions, and make the multiple processing modules in a dormant state. Among them, the multiple processing modules are created in the computing device 100.
[0059] Among them, the processing module can be a thread, which can be called a monitoring thread. For example, the processing module can specifically be the uffd monitor in the userfaultfd mechanism.
[0060] In some embodiments, the processing module processes the page fault exception by executing the page fault exception handling function. Exemplarily, the computing device 100 creates a userfaultfd object through the userfaultfd mechanism, and the userfaultfd object delegates the page fault exception handling function to each processing module among the multiple processing modules, so that each processing module among the multiple processing modules executes the page fault exception handling function, thereby enabling each processing module among the multiple processing modules to process the page fault exception.
[0061] The multiple processing modules may include the above-mentioned processing module 111, processing module 112 and other multiple processing modules. The processing module is a user-mode processing module, that is, the processing module is used to run in the user-mode space. The user can create multiple processing modules in the computing device 100 through an application program, and each processing module can be independently used to handle page fault exceptions. After the creation of the processing module is completed, control the processing module to be in a dormant state.
[0062] The different processing modules among the multiple processing modules are independent of each other and can be independently woken up.
[0063] In some embodiments, the computing device 100 includes a processing unit cluster 120. The processing unit cluster 120 includes a plurality of processing units, where each processing unit can perform a memory access operation. Different processing modules can be associated with different processing units. The processing module is used to handle a page fault exception that occurs in the memory access operation of the processing unit associated with the processing module. In this way, different processing modules can handle page fault exceptions that occur in different processing units, so that there is no mutual exclusion and conflict between different processing modules, and the concurrency of page fault exception handling is improved.
[0064] Among them, after creating a processing module, the processing module can be registered in the kernel space. By registering, different processing modules are associated with different processing units. Exemplarily, the processing module can be registered in the management module in the kernel space, so that the management module can record the processing units associated with the processing module, and so that the management module can wake up the processing module managed by the processing unit when a page fault exception occurs in the memory access operation of the processing unit.
[0065] Step 302, when at least one page fault exception occurs in the memory access operation of the computing device 100, based on the number of page fault exceptions in the at least one page fault exception, wake up at least one processing module among the plurality of processing modules; where the number of page fault exceptions in the at least one page fault exception is greater than or equal to the number of processing modules in the at least one processing module; the processing modules other than the at least one processing module among the plurality of processing modules continue to be in a dormant state; the at least one processing module is used to handle the at least one page fault exception.
[0066] The number of page fault exceptions refers to the number of virtual memory pages that have no associated physical memory pages. That is to say, when there are N virtual memory pages without associated physical memory pages, the number of page fault exceptions is N.
[0067] When a page fault exception occurs in the memory access operation of the computing device 100, according to the number of page fault exceptions, wake up the corresponding number of processing modules from the plurality of processing modules in the dormant state, and the other processing modules continue to be in the dormant state. In this way, the number of awakened processing modules matches the number of page fault exceptions, while ensuring the concurrency of page fault exception handling, avoiding waking up too many processing modules, and thus avoiding waste of the processor's scheduling resources.
[0068] In some embodiments, the computing device 100 includes a processing unit cluster 120; different processing modules among the plurality of processing modules are associated with different processing units in the processing unit cluster; where the at least one page fault exception is a page fault exception that occurs when the processing unit associated with the at least one processing module performs the memory access operation.
[0069] As described above, different processing modules are associated with different processing units in the cluster 120 of processing units. When a page fault exception occurs during a memory access operation of a processing unit, the processing module associated with the processing unit can be awakened. The awakened processing module is used to handle the page fault exception that occurs during the memory access operation of the processing unit. Among them, one or more page fault exceptions can occur during the memory access operation of the processing unit, and the processing module associated with the processing unit is used to handle the one or more page fault exceptions.
[0070] When page fault exceptions occur simultaneously during the memory access operations of two or more processing units, two or more processing modules associated with the two or more processing units can be awakened simultaneously. Among them, after the two or more processing modules associated with the processing units are awakened, they can each handle the page fault exceptions that occur in the corresponding processing units. That is to say, different processing modules handle page fault exceptions independently of each other and do not affect each other, that is, different processing modules handle page fault exceptions completely concurrently.
[0071] Among them, when a page fault exception is detected, it is possible to determine the processing unit in which the page fault exception occurs, that is, to determine which processing unit's memory access operation causes the page fault exception. When the processing unit in which the page fault exception occurs is determined, if the processing module associated with the processing unit is in a dormant state, the processing module is awakened.
[0072] Among them, the management module in the kernel space can receive the interrupt signal sent by the CPU due to the page fault exception, thereby detecting the page fault exception, and when the page fault exception is detected, determining the processing unit in which the page fault exception occurs, and awakening the processing module associated with the processing unit.
[0073] The processing module handling the page fault exception may refer to the processing module reading the information of the page fault exception from a file. In some embodiments, the information of the page fault exception may include the address of the swap space associated with the virtual memory page of the page fault exception (that is, the virtual memory page not associated with the physical memory page). The data corresponding to the virtual memory page is stored at the address of the swap space associated with the virtual memory page. The processing module can send the read information of the page fault exception to the swap module. The swap module can obtain the data corresponding to the virtual memory page based on the address of the swap space associated with the virtual memory page in the information of the page fault exception. In some embodiments, the information of the page fault exception includes the virtual memory page where the page fault exception occurs. The swap module includes the mapping relationship between the virtual memory page and the address in the swap space. The data corresponding to the virtual memory page is stored at the address in the swap space mapped to the virtual memory page. The processing module can send the read information of the page fault exception to the swap module. The swap module obtains the data corresponding to the virtual memory page from the swap space based on the virtual memory page in the information of the page fault exception and the mapping relationship between the virtual memory page and the address in the swap space.
[0074] Among them, the data corresponding to the virtual memory page refers to the data that the memory access operation needs to access through the virtual memory page, and this data needs to be written to the physical memory page address associated with the virtual memory page. Thus, the memory access operation can access the physical address memory page associated with the virtual memory page through the virtual memory page, so as to access this data.
[0075] In some embodiments, different processing modules among the multiple processing modules are associated with different files, the files are used to record information about page faults, and the processing module associated with the file is used to process the page faults based on the information; the method further includes: when at least one page fault occurs in the memory access operation of the computing device, recording the information about the at least one page fault into the file associated with the at least one processing module; the at least one processing module is used to read the information about the at least one page fault from the file associated with the at least one processing module, and process the at least one page fault based on the information about the at least one page fault.
[0076] In this embodiment, multiple files can be set in the computing device 100. Among them, each file is used to record information about page faults. Different processing modules among the multiple processing modules can be associated with different files among the multiple files. After the processing module is awakened, it can read the information about the page fault from the file associated with this processing module, and process the page fault based on the read information about the page fault. In this way, the situation where multiple processing modules serially read the information about the page fault from one file is avoided, and the concurrency of page fault processing is improved.
[0077] In an example of this embodiment, different files among the multiple files can be respectively associated with different processing units in the processing unit cluster 120. Among them, as described above, different processing modules are also associated with different processing units. When a page fault occurs in the memory access operation of a certain processing unit, record the information about the page fault into the file associated with this processing unit, and awaken the processing module associated with this processing unit. The awakened processing module reads the information about the page fault from the file associated with the processing unit associated with this processing module, and then processes the page fault based on the information about the page fault.
[0078] After the processing module reads the information about the page fault, it can send the information about the page fault to the swap module. The swap module can, based on the information about the page fault, obtain the data corresponding to the virtual memory page from the address of the swap space associated with the virtual memory page. Among them, after the swap module obtains the data corresponding to the virtual memory page, it can cache the data into the buffer space. The buffer space is associated with the physical memory page A1, and caching the data into the buffer space specifically means storing the data into the physical memory page A1 associated with this buffer space.
[0079] In some embodiments, the at least one processing module is configured to handle the at least one page fault, including: the at least one processing module triggers the computing device 100 to obtain and cache the data to be accessed corresponding to the memory access operation. Refer to Figure 4A , the method further includes: applying for a physical memory page A2 for the at least one page fault; associating the physical memory page A2 with the virtual memory page of the page fault, and storing the data to be accessed in the physical memory page A2. Wherein, the data to be accessed refers to the data corresponding to the virtual memory page. The specific operation of storing the data to be accessed in the physical memory page A2 is to copy the data (i.e., the data to be accessed) in the physical memory page A1 to the physical memory page A2.
[0080] In some embodiments, the at least one processing module is configured to handle the at least one page fault, including: the at least one processing module triggers the computing device 100 to obtain and cache the data to be accessed corresponding to the memory access operation. Refer to Figure 4B , the method further includes: associating the physical page A1 caching the data to be accessed with the virtual address corresponding to the at least one page fault, so that the access operation accesses the data to be accessed in the physical page A1 through the virtual address. That is to say, in this embodiment, the physical memory page A1 associated with the buffer space for buffering the data to be accessed is directly associated with the virtual memory page of the page fault, that is, the physical memory page A1 is used as the physical memory page associated with the virtual memory page. Among them, the address of the virtual memory page of the page fault can be directly mapped to the address of the physical memory page A1, so as to associate the physical memory page A1 with the virtual memory page of the page fault.
[0081] In this embodiment, by reusing the physical memory page associated with the buffer space, there is no need to apply for a physical memory page for the virtual memory page, saving the computational resource overhead of applying for a physical memory page and avoiding the lock conflict of applying for a physical memory page. Moreover, using the physical memory page A2 as the physical memory page associated with the virtual memory page saves the operation of copying the data to be accessed to the physical memory page associated with the virtual memory page, thus saving the computational resource overhead and the memory bandwidth overhead. And the time overhead of page fault handling can be reduced, and the efficiency of page fault handling is improved.
[0082] In summary, the page fault handling method provided by the embodiments of the present application can wake up the corresponding number of processing modules based on the number of page faults, that is, it avoids the waste of CPU scheduling resources caused by waking up too many processing modules, and can also ensure the parallel processing of different page faults, improving the efficiency of page fault handling.
[0083] Refer to Figure 5, an embodiment of the present application also provides a page fault handling device 500. The device 500 is configured in a computing device, such as the computing device 100. As Figure 5 shown, the device 500 includes:
[0084] A creation unit 510, configured to create a plurality of processing modules for handling page faults and put the plurality of processing modules in a dormant state;
[0085] A wake-up unit 520, configured to, when at least one page fault occurs in a memory access operation of the computing device, wake up at least one processing module from the plurality of processing modules based on the number of page faults in the at least one page fault; wherein, the number of page faults in the at least one page fault is greater than or equal to the number of processing modules in the at least one processing module; the processing modules other than the at least one processing module in the plurality of processing modules continue to be in a dormant state; the at least one processing module is configured to handle the at least one page fault.
[0086] In some embodiments, different processing modules in the plurality of processing modules are associated with different files, the files are used to record page fault information, and the processing module associated with the file is configured to handle the page fault based on the information; the device 500 further includes: a recording unit 530, configured to, when at least one page fault occurs in a memory access operation of the computing device, record the information of the at least one page fault into the file associated with the at least one processing module; the at least one processing module is configured to read the information of the at least one page fault from the file associated with the at least one processing module and handle the at least one page fault based on the information of the at least one page fault.
[0087] In some embodiments, the computing device includes a processing unit cluster; different processing modules in the plurality of processing modules are associated with different processing units in the processing unit cluster; wherein, the at least one page fault is a page fault that occurs when the processing unit associated with the at least one processing module executes the memory access operation.
[0088] In an example of this embodiment, the processing unit cluster is a multi-core processor, and different processing units in the processing unit cluster are different computing cores or different groups of computing cores in the multi-core processor.
[0089] In some embodiments, the at least one processing module is configured to process the at least one page fault exception, including: the at least one processing module triggers the computing device to acquire and cache the data to be accessed corresponding to the memory access operation; the apparatus 500 further includes an association unit 540, configured to associate the physical page caching the data to be accessed with the virtual address corresponding to the at least one page fault exception, so that the access operation accesses the data to be accessed in the physical page through the virtual address.
[0090] The functions of the functional units of the apparatus 500 may also be implemented with reference to the descriptions of the foregoing method embodiments, which will not be elaborated herein. Figure 3 shown above, and will not be repeated here.
[0091] An embodiment of the present application provides a computing device 600. As Figure 6 shown, the computing device 600 includes a processor 610 and a memory 620. The memory 620 is configured to store an executable program. The processor 610 is configured to execute the executable program stored in the memory 620, so that the computing device 600 can execute the method Figure 3 shown above.
[0092] An embodiment of the present application further provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can run on a computing device or be stored in any available medium. When the computer program product runs on a computing device, the computing device is caused to execute Figure 3 the method shown above.
[0093] An embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that can be stored by a computing device or a data storage device such as a data center including one or more available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid-state drive), etc. The computer-readable storage medium includes instructions, and the instructions cause the computing device to execute Figure 3 the method shown above.
[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for handling page fault exceptions, characterized in that, The method is applied to a computing device, and the method includes: Create a plurality of processing modules for handling page faults, and put the plurality of processing modules in a dormant state; When at least one page fault occurs in the memory access operation of the computing device, based on the number of page faults in the at least one page fault, wake up at least one processing module among the plurality of processing modules; wherein, the number of page faults in the at least one page fault is greater than or equal to the number of processing modules in the at least one processing module; the processing modules other than the at least one processing module among the plurality of processing modules continue to be in a dormant state; The at least one processing module is used to handle the at least one page fault.
2. The method according to claim 1, characterized in that, Different processing modules among the plurality of processing modules are associated with different files, the files are used to record information of page faults, and the processing modules associated with the files are used to handle the page faults based on the information; The method further includes: when at least one page fault occurs in the memory access operation of the computing device, record the information of the at least one page fault into the files associated with the at least one processing module; The at least one processing module is used to read the information of the at least one page fault from the files associated with the at least one processing module, and handle the at least one page fault based on the information of the at least one page fault.
3. The method according to claim 1 or 2, characterized in that, The computing device includes a processing unit cluster; different processing modules among the plurality of processing modules are associated with different processing units in the processing unit cluster; wherein, the at least one page fault is a page fault that occurs when the processing unit associated with the at least one processing module executes the memory access operation.
4. The method according to claim 3, characterized in that, The processing unit cluster is a multi-core processor, and different processing units in the processing unit cluster are different computing cores or different groups of computing cores in the multi-core processor.
5. The method according to any one of claims 1-4, characterized in that, The at least one processing module is used to handle the at least one page fault, including: the at least one processing module triggers the computing device to obtain and cache the data to be accessed corresponding to the memory access operation; the method further includes: Associate the physical page caching the data to be accessed with the virtual address corresponding to the at least one page fault, so that the access operation accesses the data to be accessed in the physical page through the virtual address.
6. A page fault exception handling device, characterized in that, The apparatus is configured in a computing device, and the apparatus includes: A creation unit, configured to create a plurality of processing modules for handling page faults, and put the plurality of processing modules in a dormant state; A wake-up unit, configured to, when at least one page fault occurs in the memory access operation of the computing device, based on the number of page faults in the at least one page fault, wake up at least one processing module among the plurality of processing modules; wherein, the number of page faults in the at least one page fault is greater than or equal to the number of processing modules in the at least one processing module; the processing modules other than the at least one processing module among the plurality of processing modules continue to be in a dormant state; The at least one processing module is used to handle the at least one page fault.
7. The device according to claim 6, characterized in that, Different processing modules among the multiple processing modules are associated with different files, where the files are used to record information about page faults, and the processing modules associated with the files are used to process the page faults based on the information; The apparatus further includes: a recording unit, configured to record information about the at least one page fault into the file associated with the at least one processing module when at least one page fault occurs in a memory access operation of the computing device; The at least one processing module is configured to read the information about the at least one page fault from the file associated with the at least one processing module, and process the at least one page fault based on the information about the at least one page fault.
8. The device according to claim 6 or 7, characterized in that, The computing device includes a cluster of processing units; different processing modules among the multiple processing modules are associated with different processing units in the cluster of processing units; wherein, the at least one page fault is a page fault that occurs when the processing unit associated with the at least one processing module executes the memory access operation.
9. The device according to claim 8, characterized in that, The cluster of processing units is a multi-core processor, and different processing units in the cluster of processing units are different computing cores or different groups of computing cores in the multi-core processor.
10. The device according to any one of claims 6-9, characterized in that, The at least one processing module is configured to process the at least one page fault, including: the at least one processing module triggers the computing device to obtain and cache the data to be accessed corresponding to the memory access operation; the apparatus further includes: An association unit, configured to associate the physical page caching the data to be accessed with the virtual address corresponding to the at least one page fault, so that the access operation accesses the data to be accessed in the physical page through the virtual address.
11. A computing device, characterized in that, Comprising: A memory, configured to store an executable program; A processor, configured to execute the method according to any one of claims 1-5 by running the executable program.
12. A computer-readable storage medium, characterized in that, Comprising computer program instructions, when the computer program instructions are executed by a computing device, the computing device executes the method according to any one of claims 1-5.
13. A computer program product containing instructions, characterized in that, When the instructions are run by a computing device, the computing device is caused to execute the method according to any one of claims 1-5.