Process memory allocation method and electronic device

By identifying and setting the image memory identifier during kernel-mode process loading, the problem of critical processes being unable to use image memory throughout the entire lifecycle is solved, achieving reliable and efficient identification of processes throughout the entire lifecycle.

CN121210335BActive Publication Date: 2026-03-03LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511771333.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-03-03
Estimated Expiration
2045-11-28

AI Technical Summary

Technical Problem

Existing technology cannot switch the memory allocated after the process starts and before the flag is modified to mirror memory, which prevents critical processes from using mirror memory for the entire lifecycle and affects reliability.

Method used

During kernel-mode process loading, critical processes are identified by obtaining the process's entity file name and a mirror memory identifier is set for them. When allocating memory for the process, mirror memory is allocated according to the identifier. The process identifier is stored in the eBPF shared mapping table to realize the mirror memory allocation of critical processes.

Benefits of technology

It enables critical processes to use mirrored memory throughout their entire lifecycle, improving process reliability, reducing the impact on system stability, and enhancing the efficiency of critical process identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121210335B_ABST
    Figure CN121210335B_ABST
Patent Text Reader

Abstract

The application discloses a process memory allocation method and an electronic device, and is applied to the technical field of communication. In order to solve the problem that a key process cannot use mirror memory in a whole cycle in the related art, leading to poor reliability, the method comprises the following steps: determining a key process according to an entity file name of a loaded process in a kernel state process loading process; setting a mirror memory usage identifier for the key process; and in a process memory allocation process, if a process to be allocated has the mirror memory usage identifier, allocating mirror memory for the process to be allocated. In the application, the key process identification and the mirror memory allocation for the key process can be realized in the process loading process, and the mirror memory can be used as soon as the process starts running, so that the key process can use the mirror memory in a whole cycle, and the reliability of the key process is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a process memory allocation method and an electronic device. Background Technology

[0002] Scenarios such as financial transactions, telecommunications billing, and industrial control have an urgent need for "zero interruption and zero data loss" for single nodes. Traditional solutions that rely on master-slave process switching or distributed redundancy still trigger interruptions lasting seconds or even minutes in the face of memory module failures, making it difficult to meet these requirements. However, current servers generally support hardware-level memory mirroring technology, which can perform microsecond-level seamless switching when DIMMs (Dual-Inline-Memory-Modules) fail momentarily. Running critical processes in mirrored memory has become the core path to improve the reliability of single nodes.

[0003] In related technologies, a flag is modified after a process starts, and this flag is then used to determine whether the process is critical. If it is determined to be critical, mirrored memory is allocated to it. However, because most of the memory is allocated to the process between startup and flag modification, the memory allocated before the flag is modified cannot be switched to mirrored memory. This prevents critical processes from using mirrored memory throughout their entire lifecycle, impacting reliability. Therefore, how to enable critical processes to use mirrored memory throughout their entire lifecycle and improve their reliability has become a problem that those skilled in the art need to solve. Summary of the Invention

[0004] This application provides a process memory allocation method and electronic device that enables critical processes to use mirrored memory throughout their entire lifecycle, thereby improving the reliability of critical processes.

[0005] This application provides a method for process memory allocation, including:

[0006] During the kernel-mode process loading process, the key processes are identified based on the entity filenames of the loaded processes;

[0007] Set the critical process to use a mirrored memory identifier;

[0008] During the process memory allocation process, if the process to be allocated has a mirror memory identifier, then mirror memory is allocated to the process to be allocated.

[0009] This application also provides a process memory allocation device, including:

[0010] The first determination module is used to determine the key process based on the entity file name of the loaded process during the kernel-mode process loading process.

[0011] The configuration module is used to set the mirror memory identifier for the key process;

[0012] The first allocation module is used to allocate mirror memory to the process to be allocated if the process to be allocated has a mirror memory identifier during the process of allocating memory.

[0013] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described process memory allocation methods when executing the computer program.

[0014] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described process memory allocation methods.

[0015] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described process memory allocation methods.

[0016] As can be seen from the above technical solution, the beneficial effects of this application are as follows:

[0017] This application provides a process memory allocation method, which includes determining a key process based on the entity file name of the loaded process during the kernel-mode process loading process; setting a mirror memory identifier for the key process; and allocating mirror memory for the process to be allocated if the process to be allocated has a mirror memory identifier during the process memory allocation process.

[0018] Therefore, this application obtains the entity filename of the loaded process during kernel-mode process loading and determines whether the loaded process is a critical process based on the entity filename. If the loaded process is a critical process, a mirror memory usage flag is set for the critical process. Furthermore, during process memory allocation, mirror memory is allocated to processes with the mirror memory usage flag based on whether they possess it. This application identifies critical processes by their corresponding entity filenames during process loading and sets a mirror memory usage flag for them. During process memory allocation, mirror memory is directly allocated to processes with this flag. Because this application can identify critical processes and complete mirror memory allocation for them during process loading, mirror memory can be used from the start of process execution, ensuring that critical processes use mirror memory throughout their entire lifecycle and improving their reliability.

[0019] Furthermore, this application also provides a corresponding electronic device for implementing the process memory allocation method, which further enhances the practicality of the method, and the electronic device has corresponding advantages. Attached Figure Description

[0020] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 A flowchart illustrating a process memory allocation method provided in this application embodiment;

[0022] Figure 2 A flowchart illustrating a memory allocation process provided in this application embodiment;

[0023] Figure 3 A flowchart for identifying key processes and setting up a mirror memory identifier is provided as an embodiment of this application;

[0024] Figure 4 This is a structural diagram of a process memory allocation device provided in an embodiment of this application. Detailed Implementation

[0025] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0026] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0027] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0028] It's important to note that mirrored memory refers to dividing physical memory into two equal "mirror" regions using hardware or firmware technologies (such as Intel Memory Mirroring or AMD Memory Interleaving). Data is written to both regions simultaneously to achieve redundancy. Mirrored memory is managed by each controller. When writing data to mirrored memory, the memory controller writes the data to both the primary and backup memory. When reading data from mirrored memory, the memory controller verifies the data in both primary and backup memory. If an error is detected, the data is retrieved from the backup memory.

[0029] To improve single-node reliability from "tolerable reboots" to "zero hardware interrupts," critical processes need to run directly in the mirrored memory region. Related technologies primarily use the kernel-mode process information writing interface / proc to locate the directory corresponding to the process's PID (Process ID), and then use the reliable field, i.e., / proc / , to... <pid>The ` / reliable` variable writes a critical process identifier, enabling the use of mirrored memory for critical processes. In kernel mode, a field is added to the `task_struct` process structure to indicate whether the process uses mirrored memory. The process uses this field to determine whether to use mirrored memory when allocating memory. However, the implementation in related technologies has the following drawbacks: First, the identifier can only be modified after the process starts; memory allocated before the identifier is modified cannot be switched to mirrored memory. Second, because the process PID changes, related technologies require manual identification of the critical process PID, leading to low accuracy and efficiency. Third, adding a field to the `task_struct` process structure in the kernel requires modifying kernel code, significantly impacting system stability.

[0030] In view of this, embodiments of this application provide a process memory allocation method that can ensure critical processes use mirrored memory throughout their entire lifecycle and improve process reliability. The following is a detailed explanation of such a method. Figure 1 The flowchart shown illustrates the process memory allocation method, providing a detailed description of the method. The method includes the following steps S110 to S130.

[0031] S110: During the kernel-mode process loading process, the critical process is determined based on the entity file name of the loaded process.

[0032] It should be noted that, in this embodiment, when the startup of a kernel-mode process is detected, the entity filename of the loaded process is obtained during the kernel-mode process loading process. This loaded process is the process currently being loaded. Then, based on the entity filename of the loaded process, it is determined whether the loaded process is a critical process. Here, a critical process refers to a process related to customer business, uninterruptible, and highly available. The system can load multiple processes; that is, if multiple processes are being loaded in the system kernel mode, then there are multiple loaded processes. The entity filename corresponding to each loaded process is obtained, and then the critical process is determined from each loaded process based on the entity filename.

[0033] S120: Set the use of mirrored memory identifier for critical processes.

[0034] It should be noted that, in this embodiment of the application, after identifying the key process from each loaded process, a mirror memory identifier is set for the key process so that the mirror identifier can be used to determine whether the process needs to allocate mirror memory when allocating memory.

[0035] S130: During the process of allocating memory, if the process to be allocated has a memory mirroring identifier, then mirroring memory is allocated to the process to be allocated.

[0036] It is understood that, in the process of allocating memory for a loading process in this embodiment of the application, for a process to be allocated, it can be determined whether the process to be allocated has a mirror memory identifier. If it is determined that the process to be allocated has a mirror memory identifier, it means that the process to be allocated is a critical process, and at this time, mirror memory needs to be allocated for the process to be allocated.

[0037] Therefore, this application obtains the entity filename of the loaded process during kernel-mode process loading and determines whether the loaded process is a critical process based on the entity filename. If the loaded process is a critical process, a mirror memory usage flag is set for the critical process. Furthermore, during process memory allocation, mirror memory is allocated to processes with the mirror memory usage flag based on whether they possess this flag. This application identifies critical processes by their corresponding entity filenames during process loading and sets a mirror memory usage flag for them. During memory allocation, mirror memory is directly allocated to processes with this flag. Because this application can identify critical processes and allocate mirror memory to them during process loading, mirror memory can be used from the start of process execution, ensuring that critical processes use mirror memory throughout their entire lifecycle and improving their reliability.

[0038] Based on the above embodiments, the embodiments of this application will further explain and optimize the technical solution.

[0039] In one implementation, the process of allocating mirror memory for the process to be allocated in S140 above may include:

[0040] Obtain available mirror memory addresses from the mirror memory address list;

[0041] Allocate available mirror memory addresses to the processes to be allocated.

[0042] It should be noted that a list of mirrored memory addresses can be pre-established, and the status of each mirrored memory address, such as available or allocated, can be recorded in this list. Therefore, when allocating mirrored memory for a process, an available mirrored memory address can be retrieved from this list and assigned to that process. This allows for rapid allocation of available mirrored memory to the process and better maintenance and management of mirrored memory addresses.

[0043] In one implementation, the process of setting the mirror memory identifier for the critical process in S120 above may include:

[0044] Obtain the process identifier corresponding to the critical process and save the process identifier of the critical process to the shared mapping table.

[0045] It is understood that, in the process of setting the use of a mirror identifier for a critical process in this embodiment of the application, the process identifier of the critical process can be obtained, and then the process identifier of the critical process can be stored in a shared mapping table. The use of a mirror memory identifier for the critical process can be set by storing the process identifier of the critical process in the shared mapping table. This shared mapping table can be a shared mapping table based on an Extended Berkeley PacketFilter (eBPF).

[0046] Among them, the Berkeley Filter extended by eBPF is a highly efficient security technology that runs within the Linux kernel, allowing user-space programs to execute in the kernel as bytecode. eBPF programs are checked by a verifier before loading to ensure their security and stability, offering high flexibility and efficiency. Through probes such as uprobes and kprobes, eBPF can trace function calls in both user space and kernel space, enabling fine-grained control and monitoring of system behavior.

[0047] In order to ensure the reliability of process memory allocation in this application embodiment, a shared mapping table based on eBPF is used to store the process identifiers of critical processes. This shared mapping table is a shared hash table of eBPF program kernel-user space data.

[0048] In one implementation, the process of obtaining the process identifier corresponding to the key process may include:

[0049] Obtain the process identifier of the critical process from the process structure corresponding to the critical process.

[0050] In other words, if the loaded process is determined to be a critical process, the process structure corresponding to the loaded process currently running on the CPU (Central Processing Unit) can be obtained from the kernel runtime context, and the process identifier (PID) can be obtained from the structure data of the process structure. Then, the process identifier (PID) is recorded in the dbp shared hash table bpf mapA for storage.

[0051] Therefore, if the process to be allocated has a mirror memory identifier in S130 above, the process of allocating mirror memory to the process to be allocated may include:

[0052] Get the process identifier of the process to be allocated;

[0053] Determine whether a first target process identifier exists in the shared mapping table that matches the process identifier of the process to be allocated. If it exists, determine that the process to be allocated has the identifier to use mirrored memory, and allocate mirrored memory to the process to be allocated.

[0054] It should be noted that in this embodiment, the first instruction at the beginning of the target kernel function body can be changed to a jump instruction in advance using function-level hot-swap technology, thereby jumping to the entry point of the eBPF program provided in this embodiment, and then executing the eBPF program to determine whether the process to be allocated is a critical process and to allocate the mirrored memory.

[0055] In practical applications, an eBPF program for identifying mirrored memory allocation can be pre-attached to functions such as `alloc_pages()` (the core function for allocating physical memory pages in kernel-mode processes) and `kmalloc()` (the function for dynamically allocating contiguous physical memory, i.e., kernel-mode process memory allocation functions). This eBPF program adds a jump instruction at the function entry point, which transfers the current logic flow to a custom logic flow. That is, as shown... Figure 2 As shown, in this application, during the memory allocation process for the process to be allocated, the eBPF program used for mirror memory allocation identification is executed to monitor the kernel-mode process memory allocation function, obtain the process identifier of the process to be allocated, and determine whether a first target process identifier with the same identifier exists in the shared mapping table based on the process identifier of the process to be allocated. That is, by checking whether the process identifier of the process to be allocated is stored in the shared mapping table, it is determined whether to allocate mirror memory to the process to be allocated. If the shared mapping table has a first target process identifier with the same identifier as the process identifier of the process to be allocated, it indicates that the process to be allocated is a critical process, and mirror memory is allocated to the process to be allocated. Of course, if the shared mapping table does not have a first target process identifier with the same identifier as the process identifier of the process to be allocated, it indicates that the process to be allocated is not a critical process, and non-mirror memory can be allocated to it. In the embodiments of this application, during the process of obtaining the process identifier of the process to be allocated, the process identifier of the process to be allocated can be obtained from the process structure corresponding to the process to be allocated.

[0056] It is understood that, in this embodiment of the application, when obtaining the process identifier of the process to be allocated, the eBPF program used for mirror memory allocation identification can be used to obtain the process structure corresponding to the process to be allocated currently running on the CPU from the kernel runtime context, and obtain the corresponding process identifier (PID) from the structure data of the process structure. After obtaining the process identifier of the process to be allocated, the above-mentioned steps of determining whether there is a first target process identifier in the shared mapping table that is consistent with the process identifier of the process to be allocated are executed. If it exists, it is determined that the process to be allocated has a mirror memory usage identifier, and mirror memory is allocated to the process to be allocated.

[0057] In one embodiment, the method may further include:

[0058] If no target process identifier matching the process identifier of the process to be allocated exists in the shared mapping table, non-mirror memory is allocated to the process to be allocated.

[0059] In other words, in this embodiment of the application, after comparing the process identifier of the process to be allocated with the process identifiers stored in the shared mapping table, if there is no first target process identifier in the shared mapping table that matches the process identifier of the process to be allocated, it means that the process to be allocated is not a critical process. At this time, the original logic can be directly jumped back to execute the original memory allocation strategy and allocate a general memory address for the process to be allocated. That is, a general memory address is allocated for the application corresponding to the process to be allocated, thereby realizing the memory allocation for non-critical processes.

[0060] In one implementation, the process of determining the key process based on the entity filename of the loaded process during the kernel-mode process loading process in S110 above includes:

[0061] During the kernel-mode process loading process, the entity file name of the loaded process is obtained; the entity file name is the absolute path entity file name of the loaded process.

[0062] It should be noted that, in the kernel-mode process loading process of this application embodiment, the entity file name of the loaded process can be obtained. The entity file name is the absolute path entity file name of the loaded process, so that the file name of the file actually operated by the loaded process can be accurately obtained.

[0063] In one implementation, the process of obtaining the entity filename of the loaded process during kernel-mode process loading may include:

[0064] By monitoring the kernel-mode process startup function, the file actually executed by the process can be determined from the member data of the input parameter structure of the kernel-mode process startup function;

[0065] Use the filename of the file as the entity filename of the loaded process.

[0066] It is understandable that, in practical applications, a kernel-mode probe program for monitoring the startup status of kernel-mode processes can be pre-attached at the kernel-mode process startup function. In this embodiment, the kernel-mode probe program is named the kernel-mode process startup monitoring program, such as... Figure 3 As shown, the kernel-mode process startup monitoring program can monitor the kernel-mode process startup function and obtain the entity filename of the loaded process. Specifically, it can obtain the member data of the input parameter structure of the kernel-mode process startup function, and then retrieve the actual filename of the loaded process from these member data. This filename is the entity filename of the loaded process. After obtaining the actual filename, it can be further determined whether the loaded process is a critical process, and if it is a critical process, its process identifier is saved to the shared mapping table.

[0067] In other words, during the kernel-mode process loading process, the kernel-mode process startup monitoring program, mounted at the executable file binary format loading function (i.e., the kernel-mode process startup function) in the link path, can be called. This kernel-mode process startup monitoring program can then obtain the filename of the file actually executed by the loaded process (e.g., bprm->filename) from the member data of the input parameter structure (linux_binprm *bprm) of the kernel-mode process startup function. This member data includes memory management-related data, file and path-related data, process credentials and security data, parameters and environment variables, execution control and status data, resource limit data, and data buffers. In practical applications, the executable file's pathname can be obtained from the file and path-related data in the member data, and then the actual filename can be obtained from that executable file's pathname.

[0068] Compare the filenames of the loaded processes with the filenames of the pre-set critical processes.

[0069] It should be noted that, in this embodiment of the application, the user can set the key process entity file name according to actual needs. There can be multiple key process entity file names. After obtaining the entity file name of the loaded process, the entity file name of the loaded process can be compared with the entity file names of each key process entity.

[0070] If the filename of the loaded process matches the filename of the critical process, the loaded process is identified as a critical process.

[0071] In other words, if the filename of the loaded process is the same as the filename of at least one critical process, it means that the loaded process is a critical process, and the subsequent steps S120 to S130 can be executed.

[0072] In one embodiment, the method may further include:

[0073] Determine the current exit process;

[0074] If the currently exiting process is a critical process, clear the memory usage flag corresponding to the currently exiting process.

[0075] It should be noted that, in practical applications, in order to facilitate the maintenance of critical processes and the use of mirrored memory identifiers, in this embodiment of the application, a kernel-mode probe program for monitoring process exit can be attached at the entry point of the kernel-mode process exit function. The kernel-mode probe program for monitoring process exit is implemented based on eBPF. By monitoring the kernel-mode process exit function, the currently exiting process can be determined. The currently exiting process is the process that is currently exiting. Before the process structure data and memory mapping of the currently exiting process are released, it is determined whether the currently exiting process is a critical process. If the currently exiting process is a critical process, the use of mirrored memory identifiers of the process to be exited is cleared.

[0076] In one implementation, if the currently exiting process is a critical process, the process of clearing the memory identifier corresponding to the currently exiting process may include:

[0077] Get the process identifier of the currently exiting process;

[0078] The process identifier of the currently exiting process is compared with the process identifiers in the shared mapping table. If a second target identifier that matches the process identifier of the currently exiting process exists in the shared mapping table, the second target identifier is removed from the shared mapping table.

[0079] It is understood that, based on the above embodiments, the use of mirrored memory flags for critical processes is set by obtaining the process identifier of the critical process and saving the process identifier to the shared mapping table. In this embodiment, after determining the currently exiting process, if the currently exiting process is a critical process, the process identifier corresponding to the use of mirrored memory flags for the currently exiting process can be obtained, and the process identifiers in the shared mapping table can be traversed. If a second target identifier that matches the process identifier of the currently exiting process exists in the shared mapping table, it indicates that the currently exiting process is a critical process. At this time, the second target identifier is cleared from the shared mapping table, indicating that the life cycle of the critical process has ended.

[0080] Furthermore, the process identifier of the currently exiting process mentioned above includes:

[0081] Before the process structure data and memory mapping corresponding to the currently exiting process are released, the process structure corresponding to the currently exiting process is obtained from the kernel runtime context, and the corresponding process identifier is obtained from the structure data of the process structure.

[0082] It should be noted that, in this embodiment of the application, when obtaining the process identifier of the currently exiting process, the process structure data and memory mapping corresponding to the currently exiting process can be obtained from the kernel running context before the process structure data and memory mapping corresponding to the currently exiting process are released. Based on the information of each member in the structure data of the process structure, the corresponding process identifier can be obtained, thereby obtaining the process identifier of the currently exiting process.

[0083] In one embodiment, the method may further include:

[0084] After the current exit process completes its exit, the image memory corresponding to the current exit process is released.

[0085] It is understood that in this embodiment of the application, after determining that the current exit process has completed its exit, that is, after clearing the process identifier corresponding to the current exit process from the shared mapping table, the image memory corresponding to the current exit process is released, thereby making the corresponding image memory idle.

[0086] As can be seen, in this embodiment, the kernel-programmable extended Berkeley filter, combined with kernel-mode probes and function-level hot-swap technology, identifies critical processes by analyzing the entity filenames of loaded processes and sets a mirror memory identifier for these critical processes. When allocating memory for user-mode processes, the allocation of mirror memory is determined based on whether the process to be allocated possesses this identifier. The process memory allocation method provided in this embodiment, by using process entity filenames to identify critical processes, improves the efficiency of critical process identification, reduces the risk of configuration errors, and enables mirror memory allocation at process startup, ensuring that critical processes use mirror memory throughout their lifecycle. Furthermore, this application does not require modification of kernel code, reducing the impact on system stability.

[0087] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0088] Embodiments of this application also provide a process memory allocation device, please refer to... Figure 4 The device includes:

[0089] The first determining module 11 is used to determine the key process based on the entity file name of the loaded process during the kernel-mode process loading process.

[0090] Module 12 is configured to set the mirror memory identifier for critical processes.

[0091] The first allocation module 13 is used to allocate mirror memory to the process to be allocated if the process to be allocated has a mirror memory identifier during the process of allocating memory.

[0092] In one embodiment, the setting module 12 includes:

[0093] The first acquisition unit is used to acquire the process identifier corresponding to the key process and save the process identifier of the key process to the shared mapping table;

[0094] The first allocation module 13 includes:

[0095] The second acquisition unit is used to acquire the process identifier of the process to be allocated;

[0096] The judgment unit is used to determine whether there is a first target process identifier in the shared mapping table that matches the process identifier of the process to be allocated. If it exists, the first allocation unit is triggered.

[0097] The first allocation unit is used to determine whether the process to be allocated has a mirror memory identifier and to allocate mirror memory to the process to be allocated.

[0098] In one implementation, the first acquisition unit is configured to:

[0099] Obtain the process identifier of the critical process from the process structure corresponding to the critical process;

[0100] Then, the second acquisition unit is used for:

[0101] Obtain the process identifier of the process to be allocated from the process structure corresponding to the process to be allocated.

[0102] In one implementation, the shared mapping table is a shared mapping table based on an extended Berkeley filter.

[0103] In one embodiment, the first determining module 11 includes:

[0104] The third acquisition unit is used to acquire the entity file name of the loaded process during the kernel-mode process loading process; the entity file name is the absolute path entity file name of the loaded process.

[0105] The comparison unit is used to compare the entity file name of the loaded process with the pre-set key process entity file name;

[0106] The first determining unit is used to determine that the loaded process is a critical process if the entity file name of the loaded process is consistent with the entity file name of the critical process.

[0107] In one embodiment, the third acquisition unit includes:

[0108] The first determining subunit is used to determine the file actually executed by the process loaded in the member data of the input parameter structure of the kernel-mode process startup function by monitoring the kernel-mode process startup function;

[0109] The second determining subunit is used to use the file name of the file as the entity file name of the loaded process.

[0110] In one embodiment, the device may further include:

[0111] The second determining module is used to determine the currently exiting process;

[0112] The cleanup module is used to clear the memory usage flags associated with the currently exiting process if the process is a critical process.

[0113] In one implementation, the clearing module includes:

[0114] The fourth acquisition unit is used to acquire the process identifier of the currently exiting process;

[0115] The clearing unit is used to compare the process identifier of the currently exiting process with each process identifier in the shared mapping table. If a second target identifier that matches the process identifier of the currently exiting process exists in the shared mapping table, the second target identifier is cleared from the shared mapping table.

[0116] In one embodiment, the fourth acquisition unit is configured to:

[0117] Before the process structure data and memory mapping corresponding to the currently exiting process are released, the process structure corresponding to the currently exiting process is obtained from the kernel runtime context, and the corresponding process identifier is obtained from the structure data of the process structure.

[0118] In one embodiment, the device may further include:

[0119] The second allocation module is used to allocate non-mirrored memory to the process to be allocated if there is no target process identifier in the shared mapping table that matches the process identifier of the process to be allocated.

[0120] In one embodiment, the device may further include:

[0121] After the current exit process completes its exit, the image memory corresponding to the current exit process is released.

[0122] In one implementation, the first allocation module includes:

[0123] The fifth acquisition unit is used to acquire available image memory addresses from the image memory address list;

[0124] The second allocation unit is used to allocate available mirror memory addresses to processes to be allocated.

[0125] It should be noted that the process memory allocation device provided in this application embodiment has the same beneficial effects as the process memory allocation method provided in the above embodiments. For a detailed description of the process memory allocation method involved in this application embodiment, please refer to the above embodiments. That is, the description of the features of the process memory allocation device in the corresponding embodiment can be found in the relevant description of the process memory allocation method in the corresponding embodiment, which will not be repeated here.

[0126] Embodiments of this application also provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above-described process memory allocation method embodiments.

[0127] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described process memory allocation method embodiments at runtime.

[0128] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0129] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described process memory allocation method embodiments.

[0130] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described process memory allocation method embodiments.

[0131] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0132] The foregoing has provided a detailed description of a process memory allocation method, computer program product, electronic device, and computer-readable storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to help understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.< / pid>

Claims

1. A process memory allocation method, characterized by, The application comprises the following steps: In the process of loading the kernel process, the key process is determined according to the entity file name of the loaded process; The key process is set with the use of mirror memory identifier; In the process of allocating memory to the process, if the process to be allocated has the use of mirror memory identifier, mirror memory is allocated to the process to be allocated; wherein: In the process of loading the kernel process, the key process is determined according to the entity file name of the loaded process, which comprises the following steps: In the process of loading the kernel process, the entity file name of the loaded process is obtained; the entity file name is the absolute path entity file name of the loaded process; The entity file name of the loaded process is compared with the pre-set key process entity file name; In the case that the entity file name of the loaded process is consistent with the key process entity file name, the loaded process is determined as the key process; In the process of loading the kernel process, the entity file name of the loaded process is obtained, which comprises the following steps: By monitoring the kernel process startup function, the file actually executed by the loaded process in the argument structure member data of the kernel process startup function is determined; The file name of the file is taken as the entity file name of the loaded process.

2. The process memory allocation method according to claim 1, wherein, The key process is set with the use of mirror memory identifier, which comprises the following steps: The process identifier corresponding to the key process is obtained, and the process identifier of the key process is saved to the shared mapping table; the shared mapping table is a shared mapping table based on an extended Berkeley filter; If the process to be allocated has the use of mirror memory identifier, mirror memory is allocated to the process to be allocated, which comprises the following steps: The process identifier of the process to be allocated is obtained; It is judged whether there is a first target process identifier consistent with the process identifier of the process to be allocated in the shared mapping table; if there is, it is determined that the process to be allocated has the use of mirror memory identifier, and the available mirror memory address is obtained from the mirror memory address list, and the available mirror memory address is allocated to the process to be allocated.

3. The process memory allocation method according to claim 2, wherein, The process identifier corresponding to the key process is obtained, which comprises the following steps: The process identifier of the key process is obtained from the process structure corresponding to the key process; The process identifier of the process to be allocated is obtained from the process structure corresponding to the process to be allocated. Further comprising:

4. The process memory allocation method according to claim 2, wherein, Determine the current exit process; In the case that the current exit process is the key process, the use of mirror memory identifier corresponding to the current exit process is cleared; After the current exit process completes the exit, the mirror memory corresponding to the current exit process is released. In the case that the current exit process is the key process, the use of mirror memory identifier corresponding to the current exit process is cleared, which comprises the following steps:

5. The process memory allocation method according to claim 4, wherein, The process identifier of the current exit process is obtained; The process identifier of the current exit process is compared with each process identifier in the shared mapping table; in the case that there is a second target identifier consistent with the process identifier of the current exit process in the shared mapping table, the second target identifier is cleared from the shared mapping table. The process identifier of the current exit process is obtained, which comprises the following steps:

6. The process memory allocation method of claim 5, wherein, ​ Before process structure data and memory mapping corresponding to the current exiting process are released, a process structure corresponding to the current exiting process is acquired from a kernel running context, and a corresponding process identifier is acquired from structure data of the process structure.

7. The process memory allocation method of claim 2, wherein, Further comprising: In a case where a target process identifier consistent with the process identifier of the process to be allocated does not exist in the shared mapping table, non-mirrored memory is allocated for the process to be allocated.

8. An electronic device, comprising: Comprising: a memory for storing a computer program; a processor for implementing the steps of the process memory allocation method according to any one of claims 1 to 7 when executing the computer program.

Citation Information

Patent Citations

  • Memory allocation method and device, electronic equipment and storage medium

    CN118819857A

  • Application thermal migration method, computing device and application thermal migration system

    CN120631495A