A memory processing method, device, equipment and computer readable storage medium
By determining the size of the first large page memory of a process in the operating system, reserving the second large page memory to replace abnormal large pages, and generating alarm information when insufficient large pages are available, the problem of replacement failure caused by insufficient large page memory is solved, improving the stability of the operating system and the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-29
- Publication Date
- 2026-03-27
AI Technical Summary
In an operating system, when a large page memory error occurs, if there is insufficient memory, direct replacement will fail, affecting the normal operation of processes and reducing the stability of the operating system.
By determining the size of the first large page of memory for the process, reserving the second large page of memory to replace abnormal large pages, and generating an alarm message when the second large page of memory is insufficient, direct replacement failure is avoided.
It improves the stability of the operating system, avoids process anomalies caused by failure to handle abnormal large page memory, and enhances system stability and user experience.
Smart Images

Figure CN115543591B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the memory processing technology in the computer field, and particularly relates to a memory processing method and device, equipment and computer readable storage medium. BACKGROUND
[0002] At present, when the process of the operating system uses the large page memory, if an abnormal large page memory exists in the large page memory, the abnormal large page memory is marked and replaced, so that the process no longer uses the abnormal large page memory, to ensure the normal operation of the process. However, if the current large page memory is insufficient, the abnormal large page memory will still be replaced, which leads to replacement failure and causes the abnormal process and low stability of the operating system. SUMMARY
[0003] To solve the above technical problems, the embodiments of the present application provide a memory processing method, device, equipment and computer readable storage medium, which solve the problem of replacement failure of the abnormal large page memory, abnormal process and low stability of the operating system.
[0004] A memory processing method, the method comprising:
[0005] determining the size of the first large page memory of the process; wherein the first large page memory is the memory required for the process to run;
[0006] determining the second large page memory based on the size of the first large page memory;
[0007] In the case that the abnormal large page memory exists in the first large page memory, processing the abnormal large page memory based on the second large page memory.
[0008] In the above scheme, the processing of the abnormal large page memory based on the second large page memory in the case that the abnormal large page memory exists in the first large page memory comprises:
[0009] In the case that the abnormal large page memory exists in the first large page memory and the remaining large page memory in the second large page memory is not zero, replacing the abnormal large page memory with the remaining large page memory.
[0010] In the above scheme, the processing of the abnormal large page memory based on the second large page memory in the case that the abnormal large page memory exists in the first large page memory comprises:
[0011] In a case where there is an abnormal huge page memory in the first huge page memory and the remaining huge page memory in the second huge page memory is zero, alarm information for the abnormal huge page memory is generated and output; wherein the alarm information is used to prompt the user that the first huge page memory is abnormal.
[0012] In the above scheme, the method further comprises:
[0013] After replacing the abnormal huge page memory, the number of the remaining huge page memory is determined.
[0014] In a case where there is an abnormal huge page memory in the first huge page memory and the number of the remaining huge page memory is not greater than a target threshold, a third huge page memory is determined based on the remaining huge page memory.
[0015] Based on the third huge page memory, the second huge page memory is updated.
[0016] In the above scheme, the second huge page memory is determined based on the size of the first huge page memory, comprising:
[0017] Based on the size of the first huge page memory, a first target number is determined according to a first target ratio;
[0018] Based on the first target number, the second huge page memory is applied by the process.
[0019] In the above scheme, the method further comprises:
[0020] A fourth huge page memory is obtained, and a first huge page memory is determined from the fourth huge page memory;
[0021] Based on the size of the first huge page memory, a second target number is determined according to a second target ratio;
[0022] Based on the second target number, the second huge page memory is determined from the fourth huge page memory.
[0023] In the above scheme, before the second huge page memory is used to replace the abnormal huge page memory, the method comprises:
[0024] A first mapping space of a virtual address of the process is obtained; wherein the first mapping space includes a virtual address used by each program of the process;
[0025] Based on the character information of the huge page, a second mapping space where the virtual address of the huge page is located is determined from the first mapping space;
[0026] determine a physical address space of the large page based on the second mapping space and an address mapping relationship table, wherein the address mapping relationship table represents a mapping relationship between a virtual address and the physical address, and wherein the physical address space of the large page comprises a physical address of the large page;
[0027] determine whether the abnormal large page memory exists in the first large page memory based on the physical address of the large page.
[0028] In the above scheme, the determination of whether the abnormal large page memory exists in the first large page memory based on the physical address of the large page comprises:
[0029] detecting the physical address of the large page to determine whether the physical address of the large page is abnormal;
[0030] in the case that the physical address of the large page is abnormal, determining that the abnormal large page memory exists in the first large page memory.
[0031] An apparatus for processing memory, the apparatus comprising:
[0032] a determination unit configured to determine a size of a first large page memory of a process, wherein the first large page memory is a memory required for running the process;
[0033] the determination unit is further configured to determine a second large page memory based on the size of the first large page memory;
[0034] a processing unit configured to process the abnormal large page memory based on the second large page memory in the case that the abnormal large page memory exists in the first large page memory.
[0035] An apparatus for processing memory, the apparatus comprising: a processor, a memory and a communication bus;
[0036] the communication bus is configured to realize a communication connection between the processor and the memory;
[0037] the processor is configured to execute a memory processing program in the memory to realize the following steps:
[0038] determine a size of a first large page memory of a process, wherein the first large page memory is a memory required for running the process;
[0039] determine a second large page memory based on the size of the first large page memory;
[0040] process the abnormal large page memory based on the second large page memory in the case that the abnormal large page memory exists in the first large page memory.
[0041] A computer readable storage medium stores one or more programs executable by one or more processors to implement the steps of the memory processing method.
[0042] The memory processing method, apparatus, device and computer readable storage medium provided in the embodiments of the present application determine the size of the first large page memory of a process, wherein the first large page memory is the memory required for the process to run; determine the second large page memory based on the size of the first large page memory; and in the case that there is an abnormal large page memory in the first large page memory, process the abnormal large page memory based on the second large page memory. In this way, when there is an abnormal large page memory in the first large page memory, the determined second large page memory can be used to process the abnormal large page memory, thereby avoiding the problem that in the related art, when the large page memory is insufficient, the abnormal large page memory fails to be processed, resulting in abnormality of the process, and improving the stability of the operating system. BRIEF DESCRIPTION OF DRAWINGS
[0043] Figure 1 A flowchart of a memory processing method provided in an embodiment of the present application is shown in the figure.
[0044] Figure 2 A flowchart of a memory processing method provided in another embodiment of the present application is shown in the figure.
[0045] Figure 3 A structure diagram of a memory processing apparatus provided in an embodiment of the present application is shown in the figure.
[0046] Figure 4 A structure diagram of a memory processing device provided in an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application.
[0048] The present application provides a memory processing method, which can be applied to a memory processing device, with reference to Figure 1 The method comprises the following steps:
[0049] Step 101, determine the size of the first large page memory of a process.
[0050] The first large page memory is memory required for process running. The large page memory is also referred to as a large page or a large memory page. An operating system manages memory by using a multi-level page table and paging. A kernel of the operating system maintains a table for mapping a virtual memory address to a physical address. For each page operation, the kernel needs to load a related mapping. If a memory page is small, a large number of pages need to be loaded, which causes the kernel to load more mapping tables. Using a large memory page reduces the number of used pages, thereby reducing the number of mapping tables loaded by the kernel, improving the performance at the kernel level, and being beneficial to the performance of each application during process startup. By starting a large memory page for a process, the operating system only needs to process a small number of page mapping tables, thereby reducing access / maintenance overhead. The operating system can be an operating system for a memory processing device.
[0051] In a feasible implementation, a default size of each page (a memory page) of an operating system is 4 KB. If a process uses a large amount of memory, for example, 1 GB, 1 GB / 4 KB = 262144 page table entries are occupied in a page table. The operating system can accommodate a number of page table entries far less than this number. When multiple memory-intensive applications access memory, the performance of the applications is affected. If the operating system supports a large page of 2 MB by default, when a process uses 1 GB of memory, 1 GB / 2 MB = 512 page table entries are occupied in the page table. Obviously, the number of page table entries occupied by using a large page is far less than the number of page table entries occupied by using a normal page, thereby improving the performance of the application.
[0052] In the embodiment of the application, the first large page memory is applied by a process to an operating system. The memory processing device can view the first large page memory used by the process according to an identifier of the process, and calculate the size of the first large page memory used by the process.
[0053] In step 102, the second large page memory is determined based on the size of the first large page memory.
[0054] The second large page memory is a large page memory reserved for isolating an abnormal large page memory in the first large page memory. The isolation of the abnormal large page memory specifically refers to marking the abnormal large page memory and replacing the abnormal large page memory by using the reserved large page memory.
[0055] In the embodiment of the application, the memory processing device can determine the number of large page memories that need to be reserved according to the size of the first large page memory, and determine the second large page memory according to the number of the reserved large page memories. The number of the second large page memories is not less than the determined number of the large page memories that need to be reserved.
[0056] It should be noted that if the number of large pages to be reserved determined according to the size of the first large page memory is not an integer, the number of large pages to be reserved needs to be re-determined by rounding up; in a feasible implementation manner, if the determined number of large pages to be reserved is 2.5, the number of large pages to be reserved is re-determined by rounding up to be "3".
[0057] The first large page memory is the large page memory required by the process to run, if an abnormal large page memory appears in the first large page memory, if the abnormal large page memory is replaced by using the non-abnormal large page memory in the first large page memory, the memory required by the process to run cannot be guaranteed, which directly causes the abnormality of the process, and further causes the stability of the operating system to be reduced, therefore, it is very necessary to additionally apply a part of the second large page memory under the condition of guaranteeing the memory required by the process, and monitor the number of the second large page memory, so as to replace the abnormal large page memory in the case that the second large page memory is not used up, which can avoid the abnormality of the process, and further improve the stability of the operating system.
[0058] Step 103, in the case that there is an abnormal large page memory in the first large page memory, the second large page memory is used to process the abnormal large page memory.
[0059] The abnormal large page memory refers to the large page in which the abnormal physical address is located.
[0060] In the embodiment of the application, the memory processing device can detect the physical address in the first large page memory of the process, when it is detected that the physical address in the first large page memory is abnormal, the large page in which the abnormal physical address is located can be regarded as the abnormal large page memory, and the second large page memory is used to process the abnormal large page memory, so as to realize the timely processing of the abnormal large page memory, improve the success rate of processing the abnormal large page memory, guarantee the normal running of the process, and improve the stability of the system.
[0061] The memory processing method provided in the embodiment of the application determines the size of the first large page memory of the process; the first large page memory is the memory required by the process to run; the second large page memory is determined based on the size of the first large page memory; in the case that there is an abnormal large page memory in the first large page memory, the abnormal large page memory is processed based on the second large page memory; in this way, when there is an abnormal large page memory in the first large page memory, the determined second large page memory can be used to process the abnormal large page memory, which avoids the problem that in the related art, when the large page memory is insufficient, the processing of the abnormal large page memory fails, which causes the abnormality of the process, and improves the stability of the operating system. Further, the problem that the isolation of the abnormal large page memory fails and the operating system defaults that the isolation is successful is avoided, and the accuracy of the operating system to determine whether the isolation is successful is improved.
[0062] Based on the foregoing embodiments, the embodiments of the present application provide a memory processing method, referring to Figure 2 The method comprises the following steps:
[0063] Step 201, the memory processing device determines the size of the first large page memory of the process.
[0064] The first large page memory is the memory required for the process to run.
[0065] Step 202, the memory processing device determines the first target quantity according to the first target ratio based on the size of the first large page memory.
[0066] The first target ratio is determined according to the maximum number of abnormal large page memories in the process. The maximum number of abnormal large page memories is the maximum number of abnormal large page memories that may occur in the first large page memory.
[0067] In the embodiments of the present application, the size of the second large page memory required can be calculated according to the size of the first large page memory and the first target ratio, and then the size of the determined second large page memory is converted to obtain the first target quantity. In a feasible implementation manner, the first target ratio can be six thousandths of the size of the first large page memory.
[0068] It should be noted that there is a certain corresponding relationship between the size of the large page memory and the number of large page memories, and the size of the second large page memory required by the process can be converted to obtain the number of the second large page memory required. When the number of the second large page memory required is not an integer, the number of the second large page memory required can be rounded up to obtain the first target quantity; when the number of the second large page memory required is an integer, the determined number of the second large page memory required can be taken as the first target quantity.
[0069] In a feasible implementation manner, if the number of the second large page memory required determined after conversion is 2.5, the first target quantity can be determined to be at least 3 after rounding up.
[0070] Step 203, the memory processing device determines the second large page memory based on the first target quantity.
[0071] In the embodiments of the present application, the memory processing device can apply for the first target quantity of the second large page memory from the operating system according to the first target quantity.
[0072] It should be noted that the time of obtaining the second large page memory can be before the process is running, or can be after the process is running, and the embodiment of the present application does not limit the time of obtaining the second large page memory. In a feasible implementation manner, the time of obtaining the second large page memory can be before the process is running, so as to ensure that when the abnormal large page memory appears in the first large page memory after the process is running, the second large page memory is used to process the abnormal large page memory in time, ensure the normal running of the process, improve the stability of the operating system, and avoid that when the abnormal large page memory appears in the first large page memory, the processing of the abnormal large page memory fails due to insufficient large page memory, and the process appears abnormal.
[0073] In step 204, the memory processing device obtains the first mapping space of the virtual address of the process.
[0074] In the first mapping space, the virtual address used by each program of the process is included.
[0075] In the embodiment of the present application, the memory processing device can obtain a process identification file, and parse the process identification file to obtain the identification of each process from the process identification file, and obtain the first mapping space of each process from the operating system according to the identification of each process; wherein the first mapping space can be referred to as the mapping space of the virtual address of the process or the virtual address space of the process.
[0076] Specifically, the process identification file on the operating system can be obtained by initiating an obtaining instruction to the operating system, and the process identification file is parsed to obtain the process identification number (PID) of each process on the operating system, and the first mapping space of the virtual address of the process is obtained from the operating system according to the process identification number of each process. Wherein, the PID is a process identifier, and a process identity document (id), i.e. PID, will be created in the operating system for each opened program, and the PID is the code of each process, and each process has a unique PID number, which is allocated by the system when the process is running, and does not represent a special process. The PID identifier will not change when the process is running, but the PID identifier will be recycled by the operating system after the process is terminated, and will be allocated to a newly running program.
[0077] In a feasible implementation manner, the PID of the process is obtained by ps, and the first mapping space of the virtual address corresponding to the PID of the process is obtained by pamp. Wherein, ps refers to an obtaining instruction for obtaining the PID of the process, and pamp refers to an obtaining instruction for obtaining the first mapping space of the process. Wherein, the process can be a large page virtual machine kvm process.
[0078] In step 205, the memory processing device determines, based on the character information of the large page, a second mapping space in which a virtual address of the large page is located from the first mapping space.
[0079] The character information of the large page refers to field information specific to the large page. The second mapping space includes a virtual address of the large page of the process, which can also be referred to as a virtual address in the first large page memory of the process.
[0080] In the embodiments of the present application, the character information of the large page can be matched with character information corresponding to the name of each application. If the character information of the large page matches the character information corresponding to the name of an application, the virtual address corresponding to the application is taken as the virtual address of the large page, and a virtual address space composed of the virtual address corresponding to the application is taken as the second mapping space.
[0081] It should be noted that when the character information of the large page matches the character information corresponding to the name of an application, the initial virtual address of the application can be taken as the initial virtual address of the large page, and the end virtual address of the large page can be determined according to the length of the address of the application. The initial virtual address of the large page, the end virtual address of the large page, and the virtual address between the initial virtual address and the end virtual address are taken as the virtual address of the large page, and an address space composed of the virtual address of the large page is taken as the second mapping space.
[0082] In a feasible implementation, the field information specific to the large page can be "hugepage", and then an application corresponding to the character information having "hugepage" in the name of the application is determined, and the virtual address corresponding to the application is taken as the virtual address of the large page.
[0083] In step 206, the memory processing device determines, based on the second mapping space and an address mapping relationship table, a physical address space of the large page.
[0084] The address mapping relationship table represents a mapping relationship between a virtual address and a physical address. The address mapping relationship table can be a memory page table. The physical address space of the large page includes a physical address of the large page, which can also be referred to as a physical address in the first large page memory.
[0085] In the embodiments of the present application, the memory processing device can obtain, according to the address mapping relationship table, a physical address corresponding to each virtual address in the second mapping space, and take a memory space composed of multiple physical addresses as the physical address space of the large page.
[0086] Specifically, the memory processing device can obtain a first mapping space of the virtual address of each process according to the PID of each process, determine a second mapping space of the large page from the first mapping space, obtain the physical address (also referred to as the large page physical address) of the large page corresponding to each virtual address in the second mapping space through reverse mapping of the reflection mapping relationship table, and take the space composed of the physical address of the large page of each process as the physical address space of the large page, so as to subsequently detect the first large page memory in which the physical address of the large page is located according to the physical address of the large page in the physical address space of the large page.
[0087] In step 207, the memory processing device determines whether there is an abnormal large page memory in the first large page memory based on the physical address of the large page.
[0088] In the embodiment of the present application, the physical address of the large page can be detected, and whether there is an abnormal large page memory in the first large page memory is determined by determining whether the physical address of the large page is abnormal.
[0089] In step 207, the memory processing device determines whether there is an abnormal large page memory in the first large page memory based on the physical address of the large page.
[0090] a1, the memory processing device detects the physical address of the large page, and determines whether the physical address of the large page is abnormal.
[0091] In the embodiment of the present application, the physical address of the large page in the physical address space of the large page can be detected by using an error correction code (ECC), and whether the physical address of the large page is abnormal is determined.
[0092] a2, the memory processing device determines that there is an abnormal large page memory in the first large page memory in the case that the physical address of the large page is abnormal.
[0093] In the embodiment of the present application, the physical address of the large page can be detected by using an error correction code (ECC), and whether the physical address of the large page is abnormal is determined.
[0094] In the embodiment of the present application, in the case that the physical address of the large page is abnormal, the first large page memory in which the physical address of the large page is located is taken as the abnormal large page memory.
[0095] In step 208, the memory processing device replaces the abnormal large page memory with the remaining large page memory in the case that there is an abnormal large page memory in the first large page memory, and the remaining large page memory in the second large page memory is not zero.
[0096] In this embodiment, when an abnormal large page memory appears in the first large page memory, it needs to be replaced by large page memory in the second large page memory. That is, the second large page memory is constantly being consumed. Therefore, when an abnormal large page memory exists, it is necessary to determine whether the initially allocated second large page memory is exhausted, that is, whether there is still a remaining large page memory in the second large page memory. When it is determined that the remaining large page memory in the second large page memory is not zero, the remaining large page memory is used to replace the abnormal large page memory to ensure the success rate of replacing the abnormal large page memory.
[0097] It should be noted that when replacing abnormal large pages, they are replaced one by one. If the number of abnormal large pages is greater than one, they need to be replaced one by one. During each replacement, it is necessary to check whether there are any remaining large pages in the second large page memory to ensure that the current abnormal large page memory is effectively isolated. This is to avoid isolating the abnormal large page memory when there are no remaining large pages in the second large page memory (i.e., the second large page memory is completely used up), which would lead to isolation failure, process abnormality, and ultimately, instability of the operating system.
[0098] Step 209: If an abnormal large page memory exists in the first large page memory and the remaining large page memory in the second large page memory is zero, the memory processing device generates and outputs an alarm message for the abnormal large page memory.
[0099] The alarm message is used to alert the user that there is an anomaly in the memory of the first page.
[0100] In this embodiment, when the remaining large page memory in the second large page memory is zero, meaning the second large page memory is completely exhausted, even if an abnormal large page memory appears in the first large page memory, it cannot be isolated. If the abnormal large page memory is forcibly isolated using non-abnormal large page memory in the first large page memory, the memory required for process execution will be reduced, leading to process abnormalities. Therefore, it is necessary to generate and output alarm information to remind the user that an abnormality has occurred in the first large page memory, enabling the user to handle it in a timely manner to ensure the normal operation of the process and improve the user experience. The error message includes at least the process identifier and the identifier of the abnormal large page memory.
[0101] In other words, when the second largest page of memory is exhausted, abnormal large pages in the first largest page of memory are not isolated to avoid using non-abnormal large pages in the first largest page of memory to isolate abnormal large pages, which could cause process abnormalities and improve the stability of the operating system. When the second largest page of memory is not exhausted, abnormal large pages are isolated to ensure the success rate of isolation, allowing processes to continue to work normally and improving system stability.
[0102] Based on the foregoing embodiments, in other embodiments of the present application, the memory processing method further includes the following steps:
[0103] Step 210, the memory processing device acquires the fourth large page memory, and determines the first large page memory from the fourth large page memory.
[0104] The fourth large page memory is the large page memory that the process actively applies to the operating system before the process is running, and the size of the fourth large page memory is much larger than the size of the large page memory required by the process running. In other words, the fourth large page memory is the largest large page memory that the process applies to maintain its own running and isolation.
[0105] In the embodiments of the present application, the memory processing device can determine the first large page memory from the fourth large page memory according to the running parameters of the process.
[0106] Step 211, the memory processing device determines a second target quantity according to a second target ratio based on the size of the first large page memory.
[0107] The second target ratio is the same as the first target ratio, and the second target quantity is the same as the first target quantity.
[0108] It should be noted that the implementation process of step 211 is similar to that of step 202, and the embodiments of the present application will not be described here.
[0109] Step 212, the memory processing device determines the second large page memory from the fourth large page memory based on the second target quantity.
[0110] In the embodiments of the present application, the memory processing device can determine the second target quantity of the second large page memory from the fourth large page memory, so that only one fourth large page memory needs to be applied to the operating system by the process, and the first large page memory and the second large page memory can be obtained, without the process applying multiple large page memories to the operating system, thereby improving the efficiency of obtaining the large page memory and reducing the workload of the process in obtaining the large page memory.
[0111] It should be noted that when the second large page memory is used up, the memory processing device can continue to obtain a part of the large page memory from the fourth large page memory for use in process isolation.
[0112] Based on the foregoing embodiments, in other embodiments of the present application, the memory processing method further includes the following steps:
[0113] Step 213, the memory processing device determines the number of remaining large page memories after replacing the abnormal large page memory.
[0114] The number of remaining large page memories represents the number of second large page memories remaining after the abnormal large page memory is replaced.
[0115] It should be noted that when determining whether there is still remaining large page memory in the second large page memory, the remaining second large page memory can be determined by the number of the remaining second large page memory. The number of the remaining second large page memory can also be referred to as a reserved value of the second large page memory.
[0116] In a feasible implementation, when the second large page memory is obtained, since the abnormal large page memory is replaced one by one, the reserved value is reduced by one each time the replacement is performed. Before the replacement, it can be determined whether the reserved value of the second large page memory is zero. If the reserved value is zero, it indicates that the second large page memory has been consumed, and an alarm information is generated and output. If the reserved value is not zero, the remaining large page memory can be used to replace the abnormal large page memory. After the replacement, the reserved value is reduced by one to obtain a new reserved value, and the new reserved value is used to update the reserved value before the abnormal large page information is isolated.
[0117] Step 214, in a case where the memory processing device determines that there is abnormal large page memory in the large page memory, and the number of the remaining large page memory is not greater than a target threshold, the third large page memory is determined based on the remaining large page memory.
[0118] The target threshold is a critical value for pre-warning the number of the remaining large page memory in the second large page memory. When the number of the remaining large page memory is not greater than the target threshold, it indicates that the remaining large page memory is insufficient, and the process needs to re-apply a part of the large page memory for the process to isolate the abnormal large page memory.
[0119] In the embodiment of the present application, in a case where the memory processing device determines that there is abnormal large page memory in the large page memory, and the number of the remaining large page memory is not greater than a target threshold, the number of the large page memory that needs to be applied can be determined according to the number of the remaining large page memory in the second large page memory, and the large page memory is re-applied according to the determined number of the large page memory that needs to be applied, and the re-applied large page memory and the remaining large page memory are used as the third large page memory.
[0120] Step 215, the memory processing device updates the second large page memory based on the fourth large page memory.
[0121] In the embodiment of the present application, the third large page memory is used to replace the second large page memory to obtain the updated second large page memory.
[0122] The memory processing method provided in the embodiments of the present application can process the abnormal large page memory by using the determined second large page memory when the abnormal large page memory exists in the first large page memory, thereby avoiding the problem that the abnormal large page memory fails to be processed when the large page memory is insufficient in the related art, causing the process to be abnormal, and improving the stability of the operating system. Further, the problem that the operating system defaults to isolation success when the abnormal large page memory fails to be isolated is avoided, and the accuracy of the operating system in determining whether the isolation is successful is improved.
[0123] Based on the foregoing embodiments, the embodiments of the present application further provide a memory processing apparatus, which can be applied to Figures 1-2 The memory processing method provided in the corresponding embodiments refers to Figure 3 The memory processing apparatus 3 comprises:
[0124] A determining unit 301 is configured to determine the size of the first large page memory of a process; wherein the first large page memory is the memory required for the process to run.
[0125] The determining unit 301 is further configured to determine the second large page memory based on the size of the first large page memory.
[0126] A processing unit 302 is configured to process the abnormal large page memory based on the second large page memory when the abnormal large page memory exists in the first large page memory.
[0127] In the embodiments of the present application, the processing unit 302 is further configured to perform the following steps:
[0128] When the abnormal large page memory exists in the first large page memory and the remaining large page memory in the second large page memory is not zero, the remaining large page memory is used to replace the abnormal large page memory.
[0129] In the embodiments of the present application, the processing unit 302 is further configured to perform the following steps:
[0130] When the abnormal large page memory exists in the first large page memory and the remaining large page memory in the second large page memory is zero, alarm information for the abnormal large page memory is generated and output; wherein the alarm information is used to prompt the user that the first large page memory is abnormal.
[0131] In the embodiments of the present application, the processing unit 302 is further configured to perform the following steps:
[0132] After the abnormal large page memory is replaced, the number of the remaining large page memory is determined.
[0133] When the abnormal large page memory exists in the large page memory and the number of the remaining large page memory is not greater than a target threshold, the third large page memory is determined based on the remaining large page memory.
[0134] update the second huge page memory based on the third huge page memory.
[0135] In the embodiment of the present application, the determining unit 301 is further configured to perform the following steps:
[0136] determine the first target number according to a first target ratio based on the size of the first huge page memory;
[0137] apply for the second huge page memory by the process based on the target number.
[0138] In the embodiment of the present application, the determining unit 301 is further configured to perform the following steps:
[0139] obtain the fourth huge page memory and determine the first huge page memory from the fourth huge page memory;
[0140] determine the second target number according to a second target ratio based on the size of the first huge page memory;
[0141] determine the second huge page memory from the fourth huge page memory based on the second target number.
[0142] In the embodiment of the present application, the processing unit 302 is further configured to perform the following steps:
[0143] obtain a first mapping space of a virtual address of the process; wherein the first mapping space includes the virtual address used by each program of the process;
[0144] determine a second mapping space in which the virtual address of the huge page is located from the first mapping space based on the character information of the huge page;
[0145] determine a physical address space of the huge page based on the second mapping space and an address mapping relationship table; wherein the address mapping relationship table represents the mapping relationship between the virtual address and the physical address; wherein the physical address space of the huge page includes the physical address of the huge page;
[0146] determine whether there is an abnormal huge page memory in the first huge page memory based on the physical address of the huge page.
[0147] In the embodiment of the present application, the processing unit 302 is further configured to perform the following steps:
[0148] detect the physical address of the huge page to determine whether the physical address of the huge page is abnormal;
[0149] determine that there is an abnormal huge page memory in the first huge page memory in the case that the physical address of the huge page is abnormal.
[0150] It should be noted that the interaction process between the units in the embodiment of the present application can refer to the interaction process between the units in the method of the present application. Figures 1-2The implementation process of the memory processing method provided by the corresponding embodiments is not described here.
[0151] The memory processing apparatus provided by the embodiments of the present application can process the abnormal large page memory by using the determined second large page memory when the abnormal large page memory exists in the first large page memory, thereby avoiding the problem that the abnormal large page memory fails to be processed when the large page memory is insufficient in the related art, causing the process to be abnormal, and improving the stability of the operating system. Further, the problem that the operating system defaults to isolation success when the abnormal large page memory fails to be isolated is avoided, and the accuracy of the operating system to determine whether the isolation is successful is improved.
[0152] Based on the foregoing embodiments, the embodiments of the present application provide a memory processing device, which can be applied to Figures 1-2 In the memory processing method provided by the corresponding embodiments, referring to Figure 4 As shown in the figure, the memory processing device 4 can include a processor 41, a memory 42 and a communication bus 43, wherein:
[0153] The communication bus 33 is used to realize the communication connection between the processor 41 and the memory 42;
[0154] The processor 41 is used to execute the memory processing program in the memory 42 to realize the following steps:
[0155] Determine the size of the first large page memory of the process; wherein the first large page memory is the memory required for the process to run;
[0156] Determine the second large page memory based on the size of the first large page memory;
[0157] In the case that the abnormal large page memory exists in the first large page memory, process the abnormal large page memory based on the second large page memory.
[0158] In other embodiments of the present application, the processor 41 is used to execute the memory processing program in the memory 42 to process the abnormal large page memory based on the second large page memory in the case that the abnormal large page memory exists in the first large page memory, to realize the following steps:
[0159] In the case that the abnormal large page memory exists in the first large page memory and the remaining large page memory in the second large page memory is not zero, replace the abnormal large page memory by using the remaining large page memory.
[0160] In other embodiments of the present application, the processor 41 is used to execute the memory processing program in the memory 42 to process the abnormal large page memory based on the second large page memory in the case that the abnormal large page memory exists in the first large page memory, to realize the following steps:
[0161] In a case where there is abnormal large page memory in the first large page memory and the remaining large page memory in the second large page memory is zero, alarm information for the abnormal large page memory is generated and output; wherein the alarm information is used to prompt the user that the first large page memory is abnormal.
[0162] In other embodiments of the present application, the processor 41 is configured to execute the memory processing program in the memory 42 to implement the following steps:
[0163] After replacing the abnormal large page memory, the number of the remaining large page memory is determined;
[0164] In a case where there is abnormal large page memory in the first large page memory and the number of the remaining large page memory is not greater than a target threshold, the third large page memory is determined based on the remaining large page memory;
[0165] Based on the third large page memory, the second large page memory is updated.
[0166] In other embodiments of the present application, the processor 41 is configured to execute the memory processing program in the memory 42 to implement the following steps:
[0167] Based on the size of the first large page memory, the first target number is determined according to a first target ratio;
[0168] Based on the first target number, the second large page memory is applied by the process.
[0169] In other embodiments of the present application, the processor 41 is configured to execute the memory processing program in the memory 42 to implement the following steps:
[0170] The fourth large page memory is obtained, and the first large page memory is determined from the fourth large page memory;
[0171] Based on the size of the first large page memory, the second target number is determined according to a second target ratio;
[0172] Based on the second target number, the second large page memory is determined from the fourth large page memory.
[0173] In other embodiments of the present application, the processor 41 is configured to execute the memory processing program in the memory 42 to implement the following steps:
[0174] The first mapping space of the virtual address of the process is obtained; wherein the first mapping space includes the virtual address used by each program of the process;
[0175] Based on the character information of the large page, the second mapping space in which the virtual address of the large page is located is determined from the first mapping space;
[0176] determine the physical address space of the large page based on the second mapping space and the address mapping relationship table, wherein the address mapping relationship table represents the mapping relationship between the virtual address and the physical address, and wherein the physical address space of the large page comprises the physical address of the large page;
[0177] determine whether the abnormal large page memory exists in the first large page memory based on the physical address of the large page.
[0178] In other embodiments of the present application, the processor 41 is configured to execute the memory processing program in the memory 42 based on the physical address of the large page, to determine whether the abnormal large page memory exists in the first large page memory, to implement the following steps:
[0179] detect the physical address of the large page, and determine whether the physical address of the large page is abnormal.
[0180] In the case that the physical address of the large page is abnormal, it is determined that the abnormal large page memory exists in the first large page memory.
[0181] It should be noted that the specific implementation process of the steps performed by the processor in the present embodiment can refer to the implementation process of the memory processing method provided by the corresponding embodiments, which will not be described here in detail. Figures 1-2 The implementation process of the memory processing method provided by the corresponding embodiments, which will not be described here in detail.
[0182] The memory processing device provided by the embodiments of the present application can use the determined second large page memory to process the abnormal large page memory when the abnormal large page memory exists in the first large page memory, thereby avoiding the problem that the abnormal large page memory processing fails when the large page memory is insufficient in the related art, resulting in abnormal process, and improving the stability of the operating system. Further, the problem of default isolation success of the operating system when the isolation of the abnormal large page memory fails is avoided, and the accuracy of the operating system to determine whether the isolation is successful is improved.
[0183] Based on the foregoing embodiments, the embodiments of the present application provide a computer readable storage medium, which stores one or more programs executable by one or more processors to implement Figures 1-2 the steps of the memory processing method provided by the corresponding embodiments.
[0184] It should be understood that every feature, structure, or characteristic described herein is within a preferred embodiment of the present application. It should be noted that the foregoing embodiments are merely exemplary and are not to be construed as limiting the present application. It should also be noted that features described in the foregoing relate to both structural and method aspects of the application. Accordingly, the terminology in use has a multi-use effect: to the extent there is technical effect to the structure, that structure is enabled by the described terminology; to the extent there is technical effect to the method, that method is enabled by the described terminology. It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application, as claimed.
[0185] It should be noted that, as used in this document, the terms "comprises" or "comprising," or "includes" or "including" or "has" or "having" or "contains" or "containing" or variants thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, article, or apparatus that comprises a list of elements is not necessarily limited to only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Further, unless otherwise specified, "or" as used herein is intended to be inclusive (i.e., logically "or" rather than logically "exclusive or"), unless otherwise indicated (e.g., "or else" or "or in the alternative").
[0186] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The above-described device embodiments are merely illustrative. For example, the division of units is merely a logical function division. In actual implementation, another division manner can be used, such as: a plurality of units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed components can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0187] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
[0188] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by relevant hardware of program instructions, the foregoing program can be stored in a computer readable storage medium, and the program executes the steps of the above-mentioned method embodiments when executed; and the foregoing storage medium includes a mobile storage device, a read only memory (Read Only Memory, ROM), a magnetic disc or an optical disc and various storage medium capable of storing program codes.
[0189] Alternatively, the integrated units of the present application can be stored in a computer readable storage medium if they are realized in the form of software function modules and sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present application can be embodied in the form of software products, and the computer software products are stored in a storage medium, including a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the embodiments of the method of the present application. The foregoing storage medium includes a mobile storage device, a ROM, a magnetic disc or an optical disc and various storage medium capable of storing program codes.
[0190] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A memory processing method, characterized by, The method comprises: determining the size of a first large page memory of a process; wherein the first large page memory is the memory required for the process to run; determining a second large page memory based on the size of the first large page memory; wherein the second large page memory is the large page memory reserved for isolating an abnormal large page memory in the first large page memory; in the case that there is an abnormal large page memory in the first large page memory, processing the abnormal large page memory based on the second large page memory.
2. The method of claim 1, wherein, The processing of the abnormal large page memory based on the second large page memory in the case that there is an abnormal large page memory in the first large page memory comprises: in the case that there is an abnormal large page memory in the first large page memory and the remaining large page memory in the second large page memory is not zero, replacing the abnormal large page memory with the remaining large page memory.
3. The method according to claim 1 or 2, characterized in that, The processing of the abnormal large page memory based on the second large page memory in the case that there is an abnormal large page memory in the first large page memory comprises: in the case that there is an abnormal large page memory in the first large page memory and the remaining large page memory in the second large page memory is zero, generating and outputting alarm information for the abnormal large page memory; wherein the alarm information is used to prompt the user that the first large page memory is abnormal.
4. The method of claim 2, wherein, The method further comprises: after replacing the abnormal large page memory, determining the number of the remaining large page memory; in the case that there is an abnormal large page memory in the large page memory and the number of the remaining large page memory is not greater than a target threshold, determining a third large page memory based on the remaining large page memory; updating the second large page memory based on the third large page memory.
5. The method of claim 1, wherein, The determination of the second large page memory based on the size of the first large page memory comprises: determining a first target number according to a first target ratio based on the size of the first large page memory; applying the second large page memory through the process based on the first target number.
6. The method of claim 1, wherein, The method further comprises: obtaining a fourth large page memory and determining a first large page memory from the fourth large page memory; Correspondingly, the determination of the second large page memory based on the size of the first large page memory comprises: determining a second target number according to a second target ratio based on the size of the first large page memory; determining the second large page memory from the fourth large page memory based on the second target number.
7. The method of claim 2, wherein, Before replacing the abnormal large page memory with the second large page memory, the method comprises: obtaining a first mapping space of a virtual address of the process; wherein the first mapping space comprises the virtual address used by each program of the process; determining a second mapping space in which the virtual address of the large page is located from the first mapping space based on the character information of the large page; determining a physical address space of the large page based on the second mapping space and an address mapping relationship table; wherein the address mapping relationship table represents the mapping relationship between the virtual address and the physical address; wherein the physical address space of the large page comprises the physical address of the large page; Determine whether the abnormal huge page memory exists in the first huge page memory based on the physical address of the huge page.
8. The method of claim 7, wherein, The determining whether the abnormal huge page memory exists in the first huge page memory based on the physical address of the huge page comprises: Detecting the physical address of the huge page to determine whether the physical address of the huge page is abnormal; In the case that the physical address of the huge page is abnormal, determining that the abnormal huge page memory exists in the first huge page memory.
9. A memory processing device, comprising: The apparatus comprises: A determining unit configured to determine a size of a first huge page memory of a process; wherein the first huge page memory is a memory required by the process to run; The determining unit is further configured to determine a second huge page memory based on the size of the first huge page memory; wherein the second huge page memory is a huge page memory reserved for isolating an abnormal huge page memory in the first huge page memory; A processing unit configured to process the abnormal huge page memory based on the second huge page memory in the case that the abnormal huge page memory exists in the first huge page memory.
10. A memory processing device, comprising: The device comprises a processor, a memory and a communication bus; The communication bus is configured to realize the communication connection between the processor and the memory; The processor is configured to execute a memory processing program in the memory to realize the following steps: Determine a size of a first huge page memory of a process; wherein the first huge page memory is a memory required by the process to run; Determine a second huge page memory based on the size of the first huge page memory; wherein the second huge page memory is a huge page memory reserved for isolating an abnormal huge page memory in the first huge page memory; Process the abnormal huge page memory based on the second huge page memory in the case that the abnormal huge page memory exists in the first huge page memory.
11. A computer readable storage medium, characterized in that, The computer readable storage medium stores one or more programs, which can be executed by one or more processors to realize the steps of the memory processing method as claimed in any one of claims 1 to 8. The computer readable storage medium stores one or more programs, which can be executed by one or more processors to realize the steps of the memory processing method as claimed in any one of claims 1 to 8.
Citation Information
Patent Citations
Processing method, device and system of missing page abnormality
CN102662864A
Memory sharing method and device, electronic equipment and storage medium
CN111813584A