Memory allocation method and device, electronic equipment and storage medium
By re-allocating memory according to the data reliability requirements of the process after setting the memory mark information, the problem of difficulty in improving the reliability of the allocated memory process is solved, and memory reliability is improved without changing the memory, ensuring that key processes are ensured. stability.
Patent Information
- Application Number
- CN202410996746.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-10-22
AI Technical Summary
In the existing technology, it is difficult to improve the reliability of processes that have allocated memory, and once the reliability flag of the memory is set, it is difficult to change, affecting the reliability of key processes.
After setting the memory tag information, determine the target process that has allocated memory, reset the tag information according to its data reliability requirements, and migrate the data to the corresponding memory to ensure that the process uses memory with the same tag information and improve the efficiency of the allocated memory. Process reliability.
It improves the reliability of its processes without changing the allocated memory, ensures that key processes use high-reliability memory, and reduces the impact of memory failures on the business.
Smart Images

Figure CN118819857A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a memory allocation method, device, electronic device and storage medium. Background Art
[0002] Memory reliability grading refers to the process of classifying memory into different grades or categories based on the reliability characteristics of the memory. This classification helps users understand the reliability level of memory when selecting it and make appropriate choices based on specific needs.
[0003] In the related art, once memory is allocated, it will not be changed. After the reliability mark is set for the memory, the newly applied memory will select the corresponding memory according to the reliability requirements of the process. However, the reliability of the allocated memory still affects the reliability of the key process.
[0004] Therefore, how to improve the reliability of processes that have allocated memory is a technical problem that those skilled in the art need to solve. Summary of the invention
[0005] The purpose of the present application is to provide a memory allocation method, device, electronic device and storage medium, which improve the reliability of the process of allocated memory.
[0006] To achieve the above purpose, the present application provides a memory allocation method, comprising:
[0007] After setting the tag information of the memory, determining a first target process to which the memory has been allocated, and setting the tag information of the first target process according to a data reliability requirement of the first target process;
[0008] Determining whether the tag information of the first target memory allocated for the first target process is the same as the tag information of the first target process;
[0009] If not, determining the corresponding second target memory according to the tag information of the first target process; wherein the tag information of the second target memory is the same as the tag information of the first target process;
[0010] Migrate data in the first target memory to the second target memory, and allocate the second target memory to the first target process.
[0011] Among them, it also includes:
[0012] The tag information of the memory is set according to the memory type of the memory; if the memory is a mirrored memory, the tag information of the memory is set to the first information, and if the memory is a non-mirrored memory, the tag information of the memory is set to the second information.
[0013] Among them, it also includes:
[0014] If the number of cyclic redundancy check errors of the third target memory whose marking information is the second information reaches a preset value within a preset time period, setting the marking information of the third target memory as the third information;
[0015] Determine a second target process that uses the third target memory, and select an unallocated fourth target memory whose marking information is the second information;
[0016] The data in the third target memory is migrated to the fourth target memory, and the fourth target memory is allocated to the second target process.
[0017] The step of setting the tag information of the first target process according to the data reliability requirement of the first target process includes:
[0018] Determining a process type of the first target process;
[0019] If the first target process is a kernel process, setting the mark information of the first target process to the first information;
[0020] If the first target process is a user process, determining whether the first target process is a system management process;
[0021] If the first target process is a system management process, setting the mark information of the first target process to the first information;
[0022] If the first target process is not a system management process, the tag information of the first target process is set according to the data reliability requirement level of the first target process; wherein, if the data reliability requirement level of the first target process is greater than or equal to the first level threshold, the tag information of the first target process is set to the first information; if the data reliability requirement level of the first target process is less than the first level threshold and greater than the second level threshold, the tag information of the first target process is set to the second information; if the data reliability requirement level of the first target process is less than or equal to the second level threshold, the tag information of the first target process is set to the third information, and the first level threshold is greater than the second level threshold.
[0023] If the first target process is not a system management process, the method further includes:
[0024] The parent process of the first target process is determined, and the marking information of the first target process is set according to the marking information of the parent process of the first target process.
[0025] Migrating data in the first target memory to the second target memory, and allocating the second target memory to the first target process, includes:
[0026] Adding a memory lock to the first target memory, and migrating data in the first target memory to the second target memory;
[0027] Modify the memory mapping table of the first target process to map the virtual memory address of the first target process to the second target memory;
[0028] Release the memory lock of the first target memory.
[0029] Among them, it also includes:
[0030] When receiving a memory allocation request of a third target process, setting the marking information of the third target process according to the data reliability requirement of the third target process;
[0031] A corresponding fifth target memory is allocated to the third target process according to the tag information of the third target process; wherein the tag information of the fifth target memory is the same as the tag information of the third target process.
[0032] To achieve the above object, the present application provides a memory allocation device, comprising:
[0033] A first setting module is used to determine a first target process to which memory has been allocated after setting the tag information of the memory, and to set the tag information of the first target process according to a data reliability requirement of the first target process;
[0034] a judging module, configured to judge whether the tag information of the first target memory allocated for the first target process is the same as the tag information of the first target process; if not, starting the working process of the first determining module;
[0035] A first determining module, configured to determine a corresponding second target memory according to the tag information of the first target process; wherein the tag information of the second target memory is the same as the tag information of the first target process;
[0036] The first migration module is used to migrate the data in the first target memory to the second target memory, and allocate the second target memory to the first target process.
[0037] To achieve the above objectives, the present application provides an electronic device, including:
[0038] Memory for storing computer programs;
[0039] A processor is used to implement the steps of the above-mentioned memory allocation method when executing the computer program.
[0040] To achieve the above objectives, the present application provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above memory allocation method are implemented.
[0041] It can be seen from the above scheme that a memory allocation method provided by the present application includes: after setting the tag information of the memory, determining the first target process to which the memory has been allocated, and setting the tag information of the first target process according to the data reliability requirement of the first target process; judging whether the tag information of the first target memory allocated to the first target process is the same as the tag information of the first target process; if not, determining the corresponding second target memory according to the tag information of the first target process; wherein the tag information of the second target memory is the same as the tag information of the first target process; migrating the data in the first target memory to the second target memory, and allocating the second target memory to the first target process.
[0042] The memory allocation method provided by the present application, after setting the tag information of the memory, for the first target process to which the memory has been allocated, determines whether the tag information of the first target process is the same as the tag information of the first target memory allocated to the first target process, and if they are different, reallocates the second target memory with the same tag information to the first target process, and migrates the data in the first target memory to the second target memory, ensuring that the process to which the memory has been allocated before the tag information of the memory is set uses the memory with the same tag information, thereby improving the reliability of the process to which the memory has been allocated. The present application also discloses a memory allocation device, an electronic device, and a non-volatile storage medium, which can also achieve the above technical effects.
[0043] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific implementation methods, they are used to explain the present disclosure, but do not constitute a limitation to the present disclosure. In the drawings:
[0045] Figure 1is a flow chart of a memory allocation method according to an exemplary embodiment;
[0046] Figure 2 is a flowchart of another memory allocation method according to an exemplary embodiment;
[0047] Figure 3 is a structural diagram of a memory allocation device according to an exemplary embodiment;
[0048] Figure 4 The figure is a structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In addition, in the embodiments of the present application, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0050] The embodiment of the present application discloses a memory allocation method, which improves the reliability of the process of allocated memory.
[0051] See also Figure 1 , according to a flowchart of a memory allocation method shown in an exemplary embodiment, such as Figure 1 As shown, including:
[0052] S101: After setting the mark information of the memory, determining a first target process to which the memory has been allocated, and setting the mark information of the first target process according to the data reliability requirement of the first target process;
[0053] As a feasible implementation, this embodiment also includes: setting the tag information of the memory according to the memory type of the memory; wherein, if the memory is a mirrored memory, the tag information of the memory is set to the first information, and if the memory is a non-mirrored memory, the tag information of the memory is set to the second information.
[0054] In a specific implementation, the memory is graded for reliability according to the memory type of the memory, and the tag information of the memory is set according to the reliability grading result. For the mirror memory, its reliability level is the highest, and its tag information is set to the first information, that is, the mirror memory is used as a high-reliability memory for key processes. For the non-mirrored memory, its reliability level is low, and its tag information is set to the second information, that is, the non-mirrored memory is used as an ordinary memory for ordinary processes.
[0055] As a preferred implementation, it also includes: if the number of cyclic redundancy check errors in the third target memory whose marking information is the second information reaches a preset value within a preset time period, setting the marking information of the third target memory as the third information.
[0056] In a specific implementation, for a memory whose marking information is the second information, that is, a normal memory, the number of cyclic redundancy check (CRC) errors within a preset time period is detected. If the number of CRC errors within the preset time period reaches a preset value, the marking information is modified to the third information, that is, the memory is treated as an unreliable memory.
[0057] It can be seen that in this implementation, unreliable memory is divided by memory life prediction, and this part of the memory is isolated to alert maintenance personnel to replace it. Only when the memory is insufficient, the re-executable archiving and sorting processes are run, that is, the processes are re-run. Ordinary processes do not use unreliable memory, thereby minimizing the impact of memory failures on the business.
[0058] Furthermore, after setting the mark information of the memory, the first target process to which the memory has been allocated is determined, and the mark information of the first target process is set according to the data reliability requirement of the first target process, that is, the mark information is used to characterize the data reliability requirement of the process. If the reliability requirement of the first target process is high, its mark information is set to the first information; if the reliability requirement of the first target process is low, its mark information is set to the second information.
[0059] As a feasible implementation mode, setting the tag information of the first target process according to the data reliability requirement of the first target process includes: determining the process type of the first target process; if the first target process is a kernel process, setting the tag information of the first target process to the first information; if the first target process is a user process, determining whether the first target process is a system management process; if the first target process is a system management process, setting the tag information of the first target process to the first information; if the first target process is not a system management process, setting the tag information of the first target process according to the data reliability requirement level of the first target process; wherein, if the data reliability requirement level of the first target process is greater than or equal to a first level threshold, setting the tag information of the first target process to the first information, if the data reliability requirement level of the first target process is less than the first level threshold and greater than a second level threshold, setting the tag information of the first target process to the second information, if the data reliability requirement level of the first target process is less than or equal to the second level threshold, setting the tag information of the first target process to the third information, and the first level threshold is greater than the second level threshold.
[0060] In a specific implementation, the tag information of the first target process is set according to the process type of the first target process. If the first target process is a kernel process, it means that its data reliability requirement is high, so its tag information is set to the first information and high reliability memory is used. If the first target process is a user process, it is first determined whether it is released as a system management (systemd) process. If so, it means that its data reliability requirement is high, so its tag information is set to the first information and high reliability memory is used. If not, the tag information of the first target process is set according to the data reliability requirement level of the first target process. If the data reliability requirement level of the first target process is greater than or equal to the first level threshold, it means that its data reliability requirement is high, that is, it is a critical process, and its tag information is set to the first information and high reliability memory is used. If the data reliability requirement level of the first target process is less than the first level threshold and greater than the second level threshold, it means that its data reliability requirement is low, and its tag information is set to the second information and ordinary memory is used. If the data reliability requirement level of the first target process is less than or equal to the second level threshold, it means that its data reliability requirement is very low, that is, the first target process is a rerunnable process, and its tag information is set to the third information and unreliable memory is used.
[0061] It should be noted that the tag information of the first target process can be set through the proc (process information) interface, which is represented by " / proc / <pid> / graded", graded is the marking information. For the kernel process, its pid (process identifier, Process ID) is 0, and its graded attribute is marked as the first information. For the system management process, its pid is 1, and its graded attribute is marked as the first information. The graded attributes of other processes are marked according to their data reliability requirement levels.
[0062] As a feasible implementation, if the first target process is not a system management process, the method further includes: determining the parent process of the first target process, and setting the tag information of the first target process according to the tag information of the parent process of the first target process. In a specific implementation, for user processes other than system management processes, their tag information can be set through the proc interface or inherit the tag information of their parent process, that is, the graded attribute of the first target process is the same as the graded attribute of its parent process.
[0063] S102: Determine whether the tag information of the first target memory allocated to the first target process is the same as the tag information of the first target process; if not, proceed to S103;
[0064] In this step, it is determined whether the tag information of the first target process is the same as the tag information of the first target memory allocated to the first target process. If they are the same, the next target process is determined. If they are different, the process proceeds to S103.
[0065] S103: Determine a corresponding second target memory according to the tag information of the first target process; wherein the tag information of the second target memory is the same as the tag information of the first target process;
[0066] In this step, an unallocated second target memory having the same tag information as the first target process is determined.
[0067] S104: Migrate the data in the first target memory to the second target memory, and allocate the second target memory to the first target process.
[0068] In this step, the data in the first target memory is migrated to the second target memory, and the second target memory is allocated to the first target process.
[0069] As a feasible implementation method, data in the first target memory is migrated to the second target memory, and the second target memory is allocated to the first target process, including: adding a memory lock to the first target memory, migrating data in the first target memory to the second target memory; modifying the memory mapping table of the first target process, mapping the virtual memory address of the first target process to the second target memory; releasing the memory lock of the first target memory.
[0070] In a specific implementation, before data migration, a memory lock is first added to the first target memory to prevent other processes from accessing the first target memory during data migration. Next, the data in the first target memory is copied to the second target memory. Then, the memory mapping table of the first target process is modified to map the virtual memory address of the first target process to the second target memory. Finally, the memory lock of the first target memory is released.
[0071] That is to say, in this embodiment, for the first target process to which memory has been allocated, if the tag information of the first target process is the first information, it means that its data reliability requirement is relatively high. If the tag information of the first target memory allocated to the first target process is the second information, it means that the reliability of the first target memory cannot meet the data reliability requirement of the first target process. A second target memory with the tag information of the first information is reselected and allocated to the first target process, and the data in the first target memory is migrated to the second target memory. If the tag information of the first target process is the second information, it means that its data reliability requirement is relatively low. If the tag information of the first target memory allocated to the first target process is the first information, although the reliability of the first target memory can meet the data reliability requirement of the first target process, in order to avoid the first target process occupying the high-reliability memory and other processes with high data reliability requirements cannot use the high-reliability memory, a second target memory with the tag information of the second information is reselected and allocated to the first target process, and the data in the first target memory is migrated to the second target memory.
[0072] It should be noted that if the marking information of the first target process is the first information and the marking information of the first target memory is the second information, but the memory whose current marking information is the first information, that is, the high-reliability memory is insufficient, data migration can be temporarily suspended until other processes release the high-reliability memory before performing data migration.
[0073] As a preferred implementation, after setting the tag information of the third target memory to the third information, it also includes: determining the second target process using the third target memory, selecting an unallocated fourth target memory whose tag information is the second information; migrating the data in the third target memory to the fourth target memory, and allocating the fourth target memory to the second target process.
[0074] In a specific implementation, for the third target memory whose marking information is the third information, that is, marked as unreliable memory, the second target process using the third target memory is determined. Since the reliability of the third target memory is low at this time, the marking information of the third target memory is different from the marking information of the second target process, and the third target memory will affect the reliability of the second target process, therefore, an unallocated fourth target memory with the same marking information as the second target process is determined, and then the data in the third target memory is migrated to the fourth target memory, and the fourth target memory is allocated to the second target process. The specific data migration process is the same as that described above and will not be repeated here.
[0075] The memory allocation method provided in the embodiment of the present application, after setting the tag information of the memory, for the first target process to which the memory has been allocated, determines whether the tag information of the first target process is the same as the tag information of the first target memory allocated to the first target process; if they are different, reallocates the second target memory with the same tag information to the first target process, and migrates the data in the first target memory to the second target memory, thereby ensuring that the process to which the memory has been allocated before the tag information of the memory is set uses the memory with the same tag information, thereby improving the reliability of the process to which the memory has been allocated.
[0076] The present application embodiment discloses a memory allocation method, specifically:
[0077] See also Figure 2 , a flowchart of another memory allocation method according to an exemplary embodiment is shown, such as Figure 2 As shown, including:
[0078] S201: When receiving a memory allocation request of a third target process, setting tag information of the third target process according to data reliability requirements of the third target process;
[0079] S202: Allocate a corresponding fifth target memory to the third target process according to the tag information of the third target process; wherein the tag information of the fifth target memory is the same as the tag information of the third target process.
[0080] In this embodiment, for the third target process that newly applies for memory, the tag information is set according to its data reliability requirements. The specific setting method has been described in detail in the previous embodiment and will not be repeated here. Then, the unallocated fifth target memory with the same tag information as the third target process is selected, and the fifth target memory is allocated to the third target process.
[0081] It should be noted that if the marking information of the third target process is the first information, when the memory marked with the first information, that is, the high-reliability memory, is insufficient, the memory marked with the second information, that is, the ordinary memory, can be allocated to the third target process.
[0082] In addition, when the tag information of the third target process is the second information, but it uses the target function of certain scenarios, in addition to allocating memory with the tag information of the second information, that is, ordinary memory, to the third target process, memory with the tag information of the first information, that is, high-reliability memory, can also be allocated to the third target process, and the high-reliability memory is used when the third target process uses the target function. That is, the third target process is simultaneously allocated memory with the tag information of the first information, that is, high-reliability memory, and memory with the tag information of the second information, that is, ordinary memory. The target functions here may include hugetlb (large page memory), pagecache (page cache), vdso (virtual dynamic shared object), tmpfs (temporary file system), etc.
[0083] It can be seen that this embodiment improves the stability and reliability of the system, reduces the possibility of system failure or crash, and improves the robustness of the system by grading the reliability of the memory and using the corresponding level of memory according to the data reliability requirements of the process.
[0084] The following describes an application embodiment provided by the present application, which divides memory into three levels: high-reliability memory, ordinary memory, and unreliable memory. Part of the memory is configured as mirror memory through BIOS (Basic Input / Output System). This part of the mirror memory is treated as high-reliability memory. The kernel's memblock (memory block manager) will first try to allocate mirror memory. If it fails, it will fall back to non-mirrored memory. Non-mirrored memory is treated as ordinary memory. By detecting the memory fault count, the number of correctable errors that have occurred in the memory within a certain period of time is counted. If it exceeds the set threshold, it will be marked as unreliable memory.
[0085] Configuring the startup parameter "kernelcore=graded" means turning on the memory reliability graded management switch. CONFIG_MEMORY_GRADED is a necessary configuration, otherwise the memory reliability graded management of the entire system will not be enabled. As needed, you can use the startup parameter graded_debug=[F][S][P] to selectively turn off the fallback function (F), turn off tmpfs to use high-reliability memory (S), and turn off read-write cache to use high-reliability memory (P). The above functions are enabled by default. According to the address segment reported by the BIOS, find the mirror memory and mark the mirror memory as high-reliability memory. For NUMA (Non-Uniform Memory Access) systems, high-reliability memory does not necessarily need to be reserved on each node, but the lower 4G physical space on node0 must be high-reliability memory. Memory will be requested during system startup. If high-reliability memory cannot be allocated, it will fallback to ordinary memory for allocation or cause the system to fail to boot. If ordinary memory is used, the entire system will be unstable, so the high-reliability memory on node0 must be reserved and the lower 4G physical space must be high-reliability memory.
[0086] For non-mirrored memory, all ordinary memory is marked as ordinary memory at startup. During use, as time goes by, the memory will have CRC errors. When the number of CRC errors in a memory area per unit time exceeds the preset threshold, the memory is marked as unreliable memory. According to experience, unreliable memory will have memory errors (uce) in the near future, causing the memory to be unavailable. Once a memory area is marked as unreliable memory, the kernel will start a task to migrate the data in the unreliable memory area to ordinary memory. By modifying the page table, the entire migration process is transparent and imperceptible to the processes using these memories. At the same time, the unreliable memory area is mapped to the specific memory bar process of the server to notify the maintenance personnel to replace the memory as soon as possible. If the system is short of ordinary memory, the kernel can assign processes marked as archive and organize to run on unreliable memory. For uce errors in unreliable memory areas, the system will not be triggered to crash, but the user process will be killed instead.
[0087] Since the memory is divided into three sections according to high and low reliability, the application and release of memory also need to be managed separately according to high and low reliability. The OS (Operating System) needs to be able to control the memory application path. By default, user memory is allocated from the non-mirrored area and kernel memory is allocated from the mirrored area. When high-reliability memory is insufficient, it needs to be able to fallback to ordinary memory application or directly fail the application. When ordinary memory is insufficient, unreliable memory can be used to allocate user memory.
[0088] At the same time, the reliability requirements of some memory segments of the process and the nature of the process itself also need to support the on-demand application of high-reliability memory, ordinary memory or unreliable memory. For example, specify that key processes use high-reliability memory to reduce the probability of key processes encountering memory errors, ordinary processes use ordinary memory, and log archiving and sorting processes that can be re-run after errors are allowed to use unreliable memory.
[0089] Linux supports memory mirroring. The kernel uses high-reliability memory, and user-mode processes use ordinary memory. Problems with user process memory can cause instability in some key or core services. For example, a failure in a core business process can cause IO interruption, affecting business stability. Therefore, these key core business processes need to be specially handled so that they use high-reliability memory to improve the stability of key process operations. For log archiving and sorting processes, the process can be rerun after a failure. Therefore, it is necessary to allow these processes that can be rerun after an error to use unreliable memory.
[0090] When the system encounters a memory error, the OS should overwrite the unallocated normal memory to clear the undetected memory errors, and mark this memory as unreliable memory when the number of memory errors reaches a certain level. The kernel and ordinary user-mode processes no longer use this memory to avoid possible memory errors that affect business programs.
[0091] For memory allocation requests marked as critical processes, the kernel will allocate high-reliability memory to the process. <pid>" / graded" marks whether the process is a critical process. Core processes such as init0 are marked as critical processes by default. The graded attribute of a user-mode process can only be modified through the proc interface after the process is started or directly inherited from the parent process. systemd (pid=1) uses high-reliability memory, and its graded attribute has no effect and is not inherited. The graded attribute of kernel-mode threads is invalid, and the graded attribute of other marked core processes can be inherited.
[0092] For the ordinary memory allocated before marking the marked critical process, a task will be started when the process is marked to migrate the allocated memory to the high-reliability memory, release the ordinary memory originally used to prevent the critical process from being killed due to uce errors in the ordinary memory.
[0093] After a critical process is marked as a normal process, a task will be started to migrate the allocated high-reliability memory to the normal memory area when the process is marked, releasing the originally used high-reliability memory for the kernel or other critical processes to use.
[0094] Higher-grade memory usually has better data integrity and error repair capabilities, which means that the system can better protect data and prevent data loss or damage when memory errors or failures occur. By using memory modules with higher reliability, the system can process data and tasks more efficiently, thereby improving system performance and response speed. Stable memory can reduce system performance degradation or delays caused by memory errors. Using memory modules with higher reliability can reduce the risk of hardware failure or damage to the system, thereby extending the service life of the entire system. By selecting memory modules that meet the reliability rating, system administrators can reduce the cost and workload of maintaining and managing the system. Stable memory modules mean fewer failures and problems, reducing the need for troubleshooting and repair. Through memory reliability grading, the system does not have to use high-reliability memory for all memory. It can choose to use high-reliability memory for part of the memory and ordinary memory for part of the memory. Putting the kernel and key business processes on high-reliability memory ensures the stability of the business system and reduces the overall hardware cost.
[0095] A memory allocation device provided in an embodiment of the present application is introduced below. The memory allocation device described below and the memory allocation method described above can be referenced to each other.
[0096] See also Figure 3 , according to an exemplary embodiment, a structural diagram of a memory allocation device is shown, such as Figure 3 As shown, including:
[0097] A first setting module 301 is used to determine a first target process to which memory has been allocated after setting the tag information of the memory, and to set the tag information of the first target process according to a data reliability requirement of the first target process;
[0098] The judging module 302 is used to judge whether the tag information of the first target memory allocated for the first target process is the same as the tag information of the first target process; if not, start the working process of the first determining module;
[0099] A first determination module 303 is used to determine a corresponding second target memory according to the tag information of the first target process; wherein the tag information of the second target memory is the same as the tag information of the first target process;
[0100] The first migration module 304 is used to migrate the data in the first target memory to the second target memory, and allocate the second target memory to the first target process.
[0101] The memory allocation device provided in the embodiment of the present application, after setting the tag information of the memory, determines whether the tag information of the first target process to which the memory has been allocated is the same as the tag information of the first target memory allocated to the first target process. If they are different, the second target memory with the same tag information is reallocated to the first target process, and the data in the first target memory is migrated to the second target memory, thereby ensuring that the process to which the memory has been allocated before the tag information of the memory is set uses the memory with the same tag information, thereby improving the reliability of the process to which the memory has been allocated.
[0102] Based on the above embodiment, as a preferred implementation, it also includes:
[0103] The second setting module is used to set the tag information of the memory according to the memory type of the memory; if the memory is a mirrored memory, the tag information of the memory is set to the first information; if the memory is a non-mirrored memory, the tag information of the memory is set to the second information.
[0104] Based on the above embodiment, as a preferred implementation, it also includes:
[0105] A third setting module, configured to set the marking information of the third target memory as the third information if the number of cyclic redundancy check errors of the third target memory whose marking information is the second information reaches a preset value within a preset time period;
[0106] A second determining module is used to determine a second target process using the third target memory, and select an unallocated fourth target memory whose marking information is the second information;
[0107] The second migration module is used to migrate the data in the third target memory to the fourth target memory, and allocate the fourth target memory to the second target process.
[0108] On the basis of the above embodiment, as a preferred implementation mode, the first setting module 301 is specifically used to: determine the process type of the first target process; if the first target process is a kernel process, set the tag information of the first target process to the first information; if the first target process is a user process, determine whether the first target process is a system management process; if the first target process is a system management process, set the tag information of the first target process to the first information; if the first target process is not a system management process, set the tag information of the first target process according to the data reliability requirement level of the first target process; wherein, if the data reliability requirement level of the first target process is greater than or equal to the first level threshold, set the tag information of the first target process to the first information, if the data reliability requirement level of the first target process is less than the first level threshold and greater than the second level threshold, set the tag information of the first target process to the second information, if the data reliability requirement level of the first target process is less than or equal to the second level threshold, set the tag information of the first target process to the third information, and the first level threshold is greater than the second level threshold.
[0109] Based on the above embodiment, as a preferred implementation mode, the first setting module 301 is also used for: if the first target process is not a system management process, determining the parent process of the first target process, and setting the marking information of the first target process according to the marking information of the parent process of the first target process.
[0110] Based on the above embodiments, as a preferred implementation mode, the first migration module 304 is specifically used to: add a memory lock to the first target memory, migrate the data in the first target memory to the second target memory; modify the memory mapping table of the first target process, map the virtual memory address of the first target process to the second target memory; release the memory lock of the first target memory.
[0111] Based on the above embodiment, as a preferred implementation, it also includes:
[0112] a fourth setting module, configured to set the marking information of the third target process according to the data reliability requirement of the third target process when receiving the memory allocation request of the third target process;
[0113] An allocation module is used to allocate a corresponding fifth target memory to the third target process according to the tag information of the third target process; wherein the tag information of the fifth target memory is the same as the tag information of the third target process.
[0114] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0115] Based on the hardware implementation of the above program module, and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides an electronic device, Figure 4 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 4 As shown, the electronic equipment includes:
[0116] Communication interface 1, capable of exchanging information with other devices such as network devices;
[0117] The processor 2 is connected to the communication interface 1 to implement information exchange with other devices and is used to execute the memory allocation method provided by one or more of the above technical solutions when running a computer program. The computer program is stored in the memory 3.
[0118] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 4 Various buses are labeled as bus system 4.
[0119] The memory 3 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0120] It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 3 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memories.
[0121] The method disclosed in the above embodiment of the present application can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 2 or the instruction in the form of software. The above processor 2 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in the memory 3, and the processor 2 reads the program in the memory 3 and completes the steps of the above method in combination with its hardware.
[0122] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present application are implemented, which will not be repeated here for the sake of brevity.
[0123] In an exemplary embodiment, the embodiment of the present application further provides a non-volatile storage medium storing a computer program, which can be executed by the processor 2 to complete the steps of the aforementioned method.
[0124] In an exemplary embodiment, the present application also provides a computer program product, including a computer program, which is executed by the processor 2 to complete the steps of the aforementioned method.
[0125] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to computer program instructions, and the aforementioned computer program can be stored in a non-volatile storage medium. When the computer program is executed, it executes the steps of the above-mentioned method embodiment. Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product, which is stored in a non-volatile storage medium and includes a number of instructions for an electronic device (which can be a personal computer, a server, a network device, etc.) to execute all or part of the methods described in each embodiment of the present application.
[0126] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.< / pid> < / pid>
Claims
1. A memory allocation method, It is characterized in that include: After setting the tag information of the memory, determining a first target process to which the memory has been allocated, and setting the tag information of the first target process according to a data reliability requirement of the first target process; Determining whether the tag information of the first target memory allocated for the first target process is the same as the tag information of the first target process; If not, determining the corresponding second target memory according to the tag information of the first target process; wherein the tag information of the second target memory is the same as the tag information of the first target process; Migrate data in the first target memory to the second target memory, and allocate the second target memory to the first target process.
2. According to the memory allocation method of claim 1, It is characterized in that Also includes: The tag information of the memory is set according to the memory type of the memory; if the memory is a mirrored memory, the tag information of the memory is set to the first information, and if the memory is a non-mirrored memory, the tag information of the memory is set to the second information.
3. According to the memory allocation method of claim 2, It is characterized in that Also includes: If the number of cyclic redundancy check errors of the third target memory whose marking information is the second information reaches a preset value within a preset time period, setting the marking information of the third target memory as the third information; Determine a second target process that uses the third target memory, and select an unallocated fourth target memory whose marking information is the second information; The data in the third target memory is migrated to the fourth target memory, and the fourth target memory is allocated to the second target process.
4. According to the memory allocation method of claim 3, It is characterized in that Setting the mark information of the first target process according to the data reliability requirement of the first target process includes: Determining a process type of the first target process; If the first target process is a kernel process, setting the mark information of the first target process to the first information; If the first target process is a user process, determining whether the first target process is a system management process; If the first target process is a system management process, setting the mark information of the first target process to the first information; If the first target process is not a system management process, setting the mark information of the first target process according to the data reliability requirement level of the first target process; Among them, if the data reliability requirement level of the first target process is greater than or equal to the first level threshold, the mark information of the first target process is set to the first information; if the data reliability requirement level of the first target process is less than the first level threshold and greater than the second level threshold, the mark information of the first target process is set to the second information; if the data reliability requirement level of the first target process is less than or equal to the second level threshold, the mark information of the first target process is set to the third information, and the first level threshold is greater than the second level threshold.
5. According to the memory allocation method of claim 4, It is characterized in that If the first target process is not a system management process, the method further includes: The parent process of the first target process is determined, and the marking information of the first target process is set according to the marking information of the parent process of the first target process.
6. The memory allocation method according to claim 1, It is characterized in that Migrating data in the first target memory to the second target memory, and allocating the second target memory to the first target process, includes: Adding a memory lock to the first target memory, and migrating data in the first target memory to the second target memory; Modify the memory mapping table of the first target process to map the virtual memory address of the first target process to the second target memory; Release the memory lock of the first target memory.
7. The memory allocation method according to claim 1, It is characterized in that Also includes: When receiving a memory allocation request of a third target process, setting the marking information of the third target process according to the data reliability requirement of the third target process; A corresponding fifth target memory is allocated to the third target process according to the tag information of the third target process; wherein the tag information of the fifth target memory is the same as the tag information of the third target process.
8. A memory allocation device, It is characterized in that include: A first setting module is used to determine a first target process to which memory has been allocated after setting the tag information of the memory, and to set the tag information of the first target process according to a data reliability requirement of the first target process; a judging module, configured to judge whether the marking information of the first target memory allocated for the first target process is the same as the marking information of the first target process; if not, starting the working process of the first determining module; A first determining module, configured to determine a corresponding second target memory according to the tag information of the first target process; wherein the tag information of the second target memory is the same as the tag information of the first target process; The first migration module is used to migrate the data in the first target memory to the second target memory, and allocate the second target memory to the first target process.
9. An electronic device, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the memory allocation method as claimed in any one of claims 1 to 7 when executing the computer program.
10. A non-volatile storage medium, It is characterized in that The non-volatile storage medium stores a computer program, and when the computer program is executed, the steps of the memory allocation method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Process memory allocation method and electronic equipment
CN121210335A
Process memory allocation method and electronic device
CN121210335B
