A memory data loading method, device, medium and product

By allocating and mapping physical memory to virtual address space during the initialization phase through kernel drivers, and combining this with character device management of memory space, the problems of memory leaks and data loss in user-mode shared memory are solved, achieving fine-grained access control and the continuity and stability of business processing.

CN120780541BActive Publication Date: 2025-12-05LANGCHAO ELECTRONIC INFORMATION IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511255564.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-04
Publication Date
2025-12-05
Estimated Expiration
2045-09-04

AI Technical Summary

Technical Problem

User-mode shared memory faces security risks such as memory leaks or data loss that may result from abnormal termination of the main process, as well as data tampering and out-of-bounds access caused by coarse-grained access control.

Method used

By allocating physical memory during the initialization phase through the kernel driver and mapping it to a contiguous memory space in the virtual address space, and using character devices to manage the memory space, fine-grained access control and data mapping are achieved, ensuring that the memory space is not lost when the process crashes and that unprocessed data is loaded when the process restarts.

Benefits of technology

It achieves stability and security of memory space, prevents memory leaks and data loss, and improves the continuity and stability of application business processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120780541B_ABST
    Figure CN120780541B_ABST
Patent Text Reader

Abstract

The application discloses a memory data loading method and device, medium and product, and relates to the technical field of computers. The application pre-applys a piece of physical memory based on a kernel driver of an operating system, and maps the physical memory into a continuous memory space in a virtual address space. Since the memory space is not managed by an application process, but is only managed by the kernel driver, when the application process crashes, the memory space will not have the problems of leakage or data loss. Meanwhile, the kernel driver can intercept illegal requests for the memory space in a kernel state, so that fine-grained permission control of the memory space is realized. When the application process restarts, the character device added based on the kernel driver maps the memory space to a process space, so that the application process can continue to load and process the remaining unprocessed data in the memory space before the process crashes, and the continuity and stability of the application process business processing are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, medium and product for loading data into memory. Background Technology

[0002] Process restarts are unavoidable in business operations due to factors such as hardware failures, software defects, resource limitations, and external interference. Measures must be taken to mitigate their impact and prevent data loss caused by process restarts. Currently, a memory recovery method based on shared memory exists. Specifically, in shared memory technology, a process creates and initializes a fixed-size shared memory region through system calls, assigns a unique identifier, and maps it to its own address space for direct access. Data writing and state tracking ensure consistency through atomic operations, enabling rapid recovery after a process restart without requiring disk input / output (IO) or network transmission. The mapping operation is also time-efficient.

[0003] However, this technology faces some challenges: First, user-mode shared memory relies on the main process for management. If the main process exits abnormally and does not release the memory properly, the memory may not be released but no one is using it, or the data may be lost. Second, the access control is coarse-grained and relies on the basic permission mechanism of the operating system. It cannot perform complex access verification, which poses security risks such as data tampering and out-of-bounds access.

[0004] Given the above issues, how to solve the security risks of memory leaks or data loss that may result from abnormal termination of the main process in current user-mode shared memory, as well as data tampering and out-of-bounds access caused by coarse-grained access control, are problems that technical personnel in this field urgently need to solve. Summary of the Invention

[0005] This invention provides a memory data loading method, device, medium, and product to at least solve the security risks of memory leaks or data loss that may result from abnormal exit of the main process in current user-mode shared memory, as well as data tampering and out-of-bounds access caused by coarse-grained access control.

[0006] This invention provides a memory data loading method, comprising:

[0007] When the process restarts, it checks whether the kernel driver is loaded. During the initialization phase, the kernel driver requests physical memory and maps the physical memory to a contiguous memory space in the virtual address space.

[0008] If it is confirmed that the kernel driver has been loaded, the memory space is mapped to the process space through the character device; the character device is an input / output device added in advance by the kernel driver, which supports memory management operations on the memory space.

[0009] Determine if there is any unprocessed data corresponding to the restarted process in the memory space;

[0010] If the data is confirmed to exist, load the unprocessed data and perform business processing.

[0011] The present invention also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described memory data loading methods when executing the computer program.

[0012] The present invention 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 memory data loading methods.

[0013] The present invention 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 memory data loading methods.

[0014] The beneficial effects of this invention are as follows: a block of physical memory is pre-allocated based on the kernel driver of the operating system and mapped to a contiguous memory space in the virtual address space; since this memory space is not managed by the application process but only by the kernel driver, there will be no memory leakage or data loss when the application process crashes; at the same time, the kernel driver can intercept illegal requests to the memory space in kernel mode, realizing fine-grained permission control of the memory space; when the application process restarts, the memory space is mapped to the process space based on the character device added by the kernel driver, so that the application can continue to load and process the unprocessed data remaining in the memory space before the process crashes, improving the continuity and stability of the application's business processing.

[0015] In addition, the present invention also provides a memory data loading device, medium and product, with the same effect as above. Attached Figure Description

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

[0017] Figure 1 A flowchart of a memory data loading method provided in an embodiment of the present invention;

[0018] Figure 2 A schematic diagram of memory reservation provided for embodiments of the present invention;

[0019] Figure 3This is a schematic diagram of the memory organization provided in an embodiment of the present invention;

[0020] Figure 4 A schematic diagram illustrating the organization of memory space metadata as provided in an embodiment of the present invention;

[0021] Figure 5 This is a schematic diagram of the user-mode memory management organization provided in an embodiment of the present invention;

[0022] Figure 6 This is a schematic diagram of a memory data loading device provided in an embodiment of the present invention. Detailed Implementation

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

[0024] It should be noted that, in the description of this invention, 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., used in this invention are used to distinguish similar objects and are not used to describe a specific order or sequence.

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

[0026] Currently, in shared memory-based memory recovery methods, processes create and initialize a fixed-size shared memory region through system calls, assign a unique identifier, and map it to their own address space for direct access. Data writing and state tracking ensure consistency through atomic operations, allowing for rapid recovery after process restart without disk I / O or network transmission, and the mapping operation is time-efficient. However, user-mode shared memory relies on the main process for management. If the main process exits abnormally and fails to properly release the memory, it may result in unused memory being left unreleased or data loss. Furthermore, access control is coarse-grained, relying on the operating system's basic permission mechanisms, which cannot perform complex access checks, posing security risks such as data tampering and out-of-bounds access. Therefore, to address these issues, this invention provides a memory data loading method. It should be noted that the method provided by this invention is applied to user-mode applications.

[0027] Figure 1 This is a flowchart illustrating a memory data loading method provided in an embodiment of the present invention. Figure 1 As shown, the method includes:

[0028] S10: When the process restarts, determine whether the kernel driver is loaded. If yes, proceed to step S11; otherwise, end the process.

[0029] During the initialization phase, the kernel driver requests physical memory and maps the physical memory to a contiguous memory space in the virtual address space.

[0030] Specifically, when an application restarts, it first checks whether the kernel driver is loaded. It's important to note that during initialization, the kernel driver allocates physical memory and maps it to a contiguous block of memory in the virtual address space. This memory space is used by the application process but is not managed by the application process itself; it is managed only by the kernel driver. During application runtime, the corresponding process writes business data to this memory space. If the application's business logic wasn't fully processed before the restart, the remaining business data will remain in memory and won't be lost if the process crashes. Therefore, when the process restarts, it needs to further process the remaining unprocessed data in memory. If it's confirmed that the kernel driver is not loaded, the data in memory cannot be further read and verified, and the current process ends.

[0031] It should be noted that this embodiment does not restrict the specific process of the kernel driver requesting physical memory during the initialization phase and mapping the physical memory to a contiguous memory space in the virtual address space, nor does it restrict the size of the requested physical memory, which depends on the specific implementation.

[0032] S11: Map memory space to process space via character device.

[0033] Character devices are input / output devices pre-added by the kernel driver, supporting memory management operations on the memory space.

[0034] If the kernel driver is confirmed to be loaded, the memory space needs to be mapped to the process space corresponding to the application in order to read the data in the memory space. Specifically, the memory space is mapped to the process space through a character device.

[0035] It should be noted that character devices are input / output devices pre-added by the kernel driver, supporting memory management operations, specifically including system calls such as open, close, memory mapping (mmap), and input / output control (ioctl). Only through this device can memory space be managed and access to that space obtained.

[0036] S12: Determine if there is unprocessed data corresponding to the restarted process in the memory space; if yes, proceed to step S13; otherwise, end the process.

[0037] S13: Load unprocessed data and perform business processing.

[0038] Finally, it checks if there is any unprocessed data corresponding to the restarted process in the memory space. If it is confirmed that there is no unprocessed data corresponding to the restarted process in the memory space, it is assumed that there is no business process that has not been completed, and the current process can be terminated directly. If it is confirmed that there is unprocessed data corresponding to the restarted process in the memory space, it is assumed that there is a business process that has not been completed, and the unprocessed data in the memory space is loaded and the business process is performed.

[0039] It should be noted that this embodiment does not restrict the specific method for determining whether there is unprocessed data corresponding to the restarted process in the memory space. For example, business-related data can be retrieved directly in the memory space, or the identifier corresponding to the data in the memory space can be read to determine whether the data is unprocessed data, depending on the specific implementation.

[0040] In this embodiment, a block of physical memory is pre-allocated based on the operating system's kernel driver and mapped to a contiguous memory space in the virtual address space. Since this memory space is not managed by the application process but only by the kernel driver, there will be no memory leaks or data loss when the application process crashes. At the same time, the kernel driver can intercept illegal requests to the memory space in kernel mode, achieving fine-grained permission control over the memory space. When the application process restarts, the memory space is mapped to the process space based on the character device added by the kernel driver, allowing the application to continue loading and processing the unprocessed data remaining in the memory space before the process crashes, thus improving the continuity and stability of the application's business processing.

[0041] Figure 2 This is a schematic diagram illustrating memory reservation provided in an embodiment of the present invention. Figure 2 As shown, the kernel driver needs to store business data, therefore it needs to manage a significant amount of memory. Since the operating system manages memory in pages, allocating a large contiguous block of memory is difficult. Therefore, to achieve physical memory allocation, based on the above embodiments, in some embodiments, the kernel driver allocates physical memory during the initialization phase, including:

[0042] S101: Determine the preset size of the physical memory to be requested.

[0043] S102: Based on a preset size, request multiple physical memory segments through a general kernel memory allocation function.

[0044] Physical memory can be allocated by repeatedly requesting "small blocks of memory." Specifically, first, the preset size of the physical memory to be requested is determined, and then multiple physical memory segments are requested based on the preset size using general kernel memory allocation functions. For example, when the preset size of physical memory is 128KB, "small blocks of memory" of 4KB in size can be requested consecutively using general kernel memory allocation functions (such as kmalloc) until the total memory size reaches 128KB. This method is convenient and fast.

[0045] In some embodiments, the kernel driver requests physical memory during the initialization phase, including:

[0046] S103: Determine the preset size of the physical memory to be requested.

[0047] S104: Based on the preset size, the underlying contiguous physical memory allocation function is called in the initialization function to request physical memory from the buddy system.

[0048] Memory can also be dynamically reserved through code. Specifically, a preset size of the physical memory to be requested is determined. Based on this preset size, the underlying contiguous physical memory allocation function, such as alloc_pages() or dma_alloc_coherent(), is called in the kernel driver loading and initialization function to request the preset size of physical memory from the buddy system. This method can successfully reserve a large block of contiguous physical memory for exclusive use by the driver before the system memory becomes severely fragmented.

[0049] In some embodiments, the kernel driver requests physical memory during the initialization phase, including:

[0050] S105: Determine the preset size and starting physical address of the physical memory to be requested.

[0051] S106: Edit the configuration file for the system boot process.

[0052] S107: Add memory mapping parameters to the kernel boot command line in the configuration file to specify the default size and starting physical address of the physical memory.

[0053] S108: Save the configuration file and restart the system to reserve physical memory.

[0054] Memory can also be reserved through boot parameters. Specifically, determine the preset size and starting physical address of the physical memory to be requested. Edit the system boot configuration file (GRUB) and add the memory mapping parameter `memmap=` to the kernel boot command line to specify the preset size and starting physical address of the physical memory. Finally, save the configuration file and reboot the system to reserve physical memory. This method can completely isolate a completely contiguous, system-invisible memory region physically.

[0055] In summary, by repeatedly requesting "small blocks of memory," dynamically reserving code, and reserving startup parameters, the kernel driver can request physical memory, thus achieving kernel-mode memory management.

[0056] Based on the above embodiments, in some embodiments, the kernel driver maps physical memory to a contiguous memory space in the virtual address space, including:

[0057] S111: Map physical memory to the virtual address space using memory mapping functions; where physical memory contains multiple discrete memory segments.

[0058] S112: Organize discrete memory segments into a contiguous memory space in the virtual address space.

[0059] To map physical memory into a contiguous memory space within the virtual address space, the kernel driver uses the memory map (mmap) function to map physical memory into the virtual address space. It's important to note that since the allocated physical memory is not necessarily contiguous, it contains multiple discrete memory segments.

[0060] Figure 3 This is a schematic diagram illustrating the memory organization provided in an embodiment of the present invention. Figure 3 As shown, to ensure the integrity of memory allocation, this embodiment manages small memory segments in a page-based manner, arranging these memory segments into contiguous virtual address memory segments according to certain logic for business use. This embodiment does not limit the specific process of organizing the discrete memory segments into a contiguous memory space; it depends on the specific implementation.

[0061] In this embodiment, by mapping physical memory to a virtual address space and organizing discrete memory segments into a contiguous memory space within the virtual address space, the integrity of memory allocation is ensured.

[0062] Based on the above embodiments, in some embodiments, discrete memory segments are organized into contiguous memory spaces in the virtual address space, including:

[0063] S121: Divide each discrete memory segment according to a preset page size to obtain multiple memory pages.

[0064] S122: Organize the divided memory pages into a contiguous memory space.

[0065] To organize discrete memory segments into a contiguous memory space, this embodiment specifically divides each discrete memory segment according to a preset page size to obtain multiple memory pages. This embodiment does not limit the preset page size; for example, it can be 4KB, 2MB, or 1GB, depending on the specific implementation. After obtaining multiple memory pages of the same size, a starting position is determined in the virtual address space. Based on this starting position, these memory pages are organized into a large block of virtually contiguous memory, i.e., the memory space. It should be noted that the memory space includes a total metadata area and multiple address spaces.

[0066] Figure 4 This is a schematic diagram illustrating the organization of memory space metadata as provided in an embodiment of the present invention. Figure 4 As shown, the total metadata area is the region in the memory space that stores basic information about each memory page. There is only one total metadata area, which specifically includes the total number of memory pages in the memory space, the virtual address, physical address, address space, memory page size, and reference count of each memory page; it also includes the number, size, and location of the allocated discrete memory segments, as well as the number of address spaces, the starting address, size, and number of memory pages contained in each address space.

[0067] An address space is a region in memory that stores business data and information about the corresponding memory pages. There are multiple address spaces, each corresponding to a specific kernel in the system; the business data of each kernel application is stored in its corresponding address space. Each address space consists of multiple memory pages. An address space includes a metadata area and a storage area; the metadata area contains information about the number of memory pages corresponding to the address space and whether those pages have been allocated; the storage area is used to store business data.

[0068] In this embodiment, the kernel driver divides each discrete memory segment according to a preset page size, and organizes the divided memory pages into a contiguous memory space, which can better manage the requested memory space and is beneficial to business processing.

[0069] To indicate whether business data processing is complete, in some embodiments, based on the above embodiments, the method further includes:

[0070] S131: When a process is first started, the memory space is mapped to the process space through the character device.

[0071] S132: Divide the storage areas of each address space in the memory space into an identifier area and a data area.

[0072] Figure 5 This is a schematic diagram illustrating the user-mode memory management organization provided in an embodiment of the present invention. Figure 5 As shown, when user space acquires memory space and a process starts for the first time, user space further divides the memory space. Specifically, it maps the memory space to the process space through a character device, dividing the storage areas of each address space in the memory space into an identifier area and a data area. It should be noted that the identifier area includes the identifier area size, object size, object address, and bitmap.

[0073] An object refers to the memory area occupied by an application process in user mode within the data area when performing business processing. Therefore, the object size represents the total size of the space occupied by the process in the corresponding data area; the object address represents the address of the space occupied by the process in the corresponding data area. For example, if a process requests three contiguous memory pages in the data area to store business data, then these three memory pages are the object, the object size is the total size of the three memory pages, and the object address is the address of the three memory pages.

[0074] The bitmap contains information about whether the data in the corresponding data area has been processed. For example, unprocessed data will be marked as 0, and processed data will be marked as 1, which is determined by the relevant API call in the business logic. The size of the identifier area is the object size, the object address, and the bit depth. Figure 3 The size of the space occupied by the device.

[0075] In this way, by dividing the storage area of ​​each address space in the memory space into an identifier area and a data area, data can be written to the corresponding data area of ​​the storage area to indicate whether the processing has been completed, thus realizing the identification of whether the business data has been processed, so as to facilitate the reprocessing of business after the process restarts.

[0076] To ensure accurate mapping between user-mode memory space and process space, based on the above embodiments, in some embodiments, memory space is mapped to process space through a character device, including:

[0077] S141: Based on the data in the total metadata area, map the memory space to the user-mode process space.

[0078] The mapping relationship between virtual addresses and physical addresses in the memory space of a user-mode process is the same as that in the kernel-mode memory space.

[0079] Specifically, the kernel driver establishes the processing logic for device mapping functions based on information from the global metadata area. When a user-mode application performs mapping, it maps the memory space to the user-mode process space based on the data in the global metadata area. The relationship between the virtual and physical addresses of the user-mode mapped memory remains consistent with the relationship in the kernel-mode mapping. This ensures that the offsets in kernel mode and user mode are consistent.

[0080] Based on the above embodiments, in some embodiments, determining whether there is unprocessed data corresponding to a restarted process in the memory space includes:

[0081] S151: Determine the kernel to which the reboot process belongs.

[0082] S152: Determine the corresponding target address space in each address space under the memory space according to the kernel to which the reboot process belongs.

[0083] S153: Obtain the target bitmap in the identifier region of the target address space.

[0084] S154: Determine whether the data in the corresponding data area has been processed based on the target bitmap; if not, proceed to step S155; if yes, proceed to step S156.

[0085] S155: Confirmed that there is unprocessed data corresponding to the restart process.

[0086] S156: Confirmed that there is no unprocessed data corresponding to the restart process.

[0087] As can be seen from the above embodiments, there are multiple address spaces in the memory space, each corresponding to a different kernel in the system; the business data of each kernel application is stored in its corresponding address space. Therefore, in order to verify whether there is unprocessed data corresponding to the restarted process in the memory space, this embodiment first needs to determine the kernel to which the restarted process belongs.

[0088] Furthermore, based on the kernel to which the restart process belongs, the corresponding target address space is determined within each address space of the memory space, and the target bitmap in the identifier region of the target address space is obtained. Since the bitmap indicates whether the data in the corresponding data area has been processed, the processing status of the data in the corresponding data area is determined based on the target bitmap. If it is confirmed that the data in the data area has not been processed, then it is confirmed that there is unprocessed data corresponding to the restart process. If it is confirmed that the data in the data area has been processed, then it is confirmed that there is no unprocessed data corresponding to the restart process. In this way, the accurate retrieval of unprocessed business data is achieved, so as to continue business processing and ensure the continuity of business processing.

[0089] Based on the above embodiments, in some embodiments, loading unprocessed data and performing business processing includes:

[0090] S161: Load unprocessed data from the data area in the target address space.

[0091] S162: Perform business processing on the unprocessed data according to business requirements and modify the bitmap in the target address space.

[0092] To enable continued processing of unprocessed data, this embodiment specifically loads the unprocessed data in the data area under the target address space, further processes the unprocessed data according to business requirements, and modifies the bitmap in the target address space after the business processing is completed to indicate that the data in the corresponding data area has been processed, thus realizing the complete processing of user-mode business.

[0093] On the other hand, if it is confirmed that there is no unprocessed data corresponding to the restarted process, the data area under the target address space can be further initialized. The initialized data area can be reused according to business needs, thereby improving the utilization of memory space.

[0094] Finally, after reusing the initialized data area according to business needs, the data in the data area is further saved to the database, the running log of this process is recorded, and all data in the data area is cleared, thereby ensuring non-volatile storage of business data and saving storage resources in memory space.

[0095] Furthermore, when an application process ceases business processing and no longer uses memory space, the application sends a command to the kernel driver to release memory resources. When the kernel driver determines that the allocated memory space is no longer needed, it must call the corresponding release function to return the memory. For example, if the memory was allocated using the general kernel memory allocation function `kmalloc`, the kernel memory release function `kfree` must be called to release the memory; if the memory was allocated using the underlying contiguous physical memory allocation functions `alloc_pages` series, the memory release function `free_pages` must be called to release the memory; and for consistent Direct Memory Access (DMA) mapped memory obtained through the underlying contiguous physical memory allocation function `dma_alloc_coherent`, the consistent DMA memory release function `dma_free_coherent` must be used to release it. This ensures that the occupied system resources are returned to the kernel memory management system in a timely and correct manner, thereby avoiding memory leaks.

[0096] 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.

[0097] Figure 6 This is a schematic diagram of a memory data loading device provided in an embodiment of the present invention. Figure 6 As shown, the device includes:

[0098] The first judgment module 10 is used to determine whether the kernel driver is loaded when the process restarts. The kernel driver requests physical memory during the initialization phase and maps the physical memory to a contiguous memory space in the virtual address space. If so, the mapping module is triggered.

[0099] The mapping module 11 is used to map memory space to process space through character devices; wherein, the character devices are input / output devices added in advance by the kernel driver, which support memory management operations on the memory space.

[0100] The second judgment module 12 is used to determine whether there is unprocessed data corresponding to the restarted process in the memory space; if so, the loading module is triggered.

[0101] Loading module 13 is used to load unprocessed data and perform business processing.

[0102] In some embodiments, the kernel driver maps physical memory to a contiguous memory space in the virtual address space, including: mapping physical memory to the virtual address space through a memory mapping function; wherein the physical memory contains multiple discrete memory segments; and organizing each discrete memory segment into a contiguous memory space in the virtual address space.

[0103] In some embodiments, the kernel driver organizes discrete memory segments into contiguous memory spaces in the virtual address space, including: dividing the discrete memory segments into multiple memory pages according to a preset page size; and organizing the divided memory pages into contiguous memory spaces. The memory space includes a total metadata area and multiple address spaces. The total metadata area includes the number of memory pages, the virtual address, physical address, address space, page size, and reference count of each memory page, the number, size, and location of discrete memory segments, the number of address spaces, and the starting address, size, and number of memory pages mapped to each address space. Each address space includes a metadata area and a storage area. The metadata area includes information about the number of memory pages corresponding to each address space and whether the memory pages are allocated. The storage area is used to store business data.

[0104] In some embodiments, it also includes:

[0105] The first mapping submodule is used to map memory space to process space via character device when the process is first started;

[0106] The partitioning module is used to divide the storage areas of each address space in the memory space into an identifier area and a data area;

[0107] The identifier area includes the identifier area size, object size, object address, and bitmap; the object size represents the total size of the space occupied by the process in the corresponding data area; the object address represents the address of the space occupied by the process in the corresponding data area; and the bitmap contains information on whether the data in the corresponding data area has been processed.

[0108] In some embodiments, the mapping module 11 includes:

[0109] The second mapping submodule is used to map memory space to user-mode process space based on data in the total metadata area;

[0110] The mapping relationship between virtual addresses and physical addresses in the memory space of a user-mode process is the same as that in the kernel-mode memory space.

[0111] In some embodiments, the second determining module 12 includes:

[0112] The first determination submodule is used to determine the kernel to which the reboot process belongs;

[0113] The second determination submodule is used to determine the corresponding target address space in each address space under the memory space based on the kernel to which the restarted process belongs;

[0114] The first acquisition submodule is used to acquire the target bitmap in the identifier region under the target address space;

[0115] The first judgment submodule is used to determine whether the data in the corresponding data area has been processed based on the target bitmap; if it is confirmed that the processing has not been completed, it is confirmed that there is unprocessed data corresponding to the restart process; if it is confirmed that the processing has been completed, it is confirmed that there is no unprocessed data corresponding to the restart process.

[0116] In some embodiments, the loading module 13 includes:

[0117] The first loading submodule is used to load unprocessed data from the data area in the target address space.

[0118] The business processing module is used to process unprocessed data according to business requirements and modify the bitmap in the target address space.

[0119] In some embodiments, it also includes:

[0120] The initialization module is used to initialize the data area in the target address space.

[0121] The reuse module is used to reuse the data area after initialization processing according to business requirements.

[0122] In some embodiments, it also includes:

[0123] The save module is used to save data from the data area to the database;

[0124] The log module is used to record the running log of this process and clear all data in the data area.

[0125] In some embodiments, the kernel driver requests physical memory during the initialization phase, including: determining a preset size of the physical memory to be requested; and requesting multiple physical memory segments based on the preset size using a general kernel memory allocation function.

[0126] In some embodiments, the kernel driver requests physical memory during the initialization phase, including: determining a preset size of the physical memory to be requested; and, based on the preset size, calling the underlying contiguous physical memory allocation function in the initialization function to request physical memory from the buddy system.

[0127] In some embodiments, the kernel driver requests physical memory during the initialization phase, including: determining the preset size and starting physical address of the physical memory to be requested; editing the configuration file for the system boot process; adding memory mapping parameters to the kernel boot command line in the configuration file to specify the preset size and starting physical address of the physical memory; saving the configuration file and restarting the system to reserve physical memory.

[0128] For a description of the features in the embodiment corresponding to the memory data loading device, please refer to the relevant description in the embodiment corresponding to the memory data loading method, which will not be repeated here.

[0129] Embodiments of the present invention 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 memory data loading method embodiments.

[0130] Embodiments of the present invention 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 memory data loading method embodiments at runtime.

[0131] 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.

[0132] Embodiments of the present invention 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 memory data loading method embodiments.

[0133] Embodiments of the present invention 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 memory data loading method embodiments.

[0134] 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 implementations should not be considered beyond the scope of this invention.

[0135] The foregoing has provided a detailed description of a memory data loading method, device, medium, and product provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only intended to aid in understanding the method and core ideas of the present invention. It should be noted that those skilled in the art can make various improvements and modifications to the present invention without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

Claims

1. A method for loading data into memory, characterized in that, include: When the process restarts, it is determined whether the kernel driver is loaded; wherein, the kernel driver requests physical memory during the initialization phase and maps the physical memory to a contiguous memory space in the virtual address space; If it is confirmed that the kernel driver has been loaded, the memory space is mapped to the process space through a character device; wherein, the character device is an input / output device added in advance by the kernel driver, which supports memory management operations on the memory space; Determine whether there is any unprocessed data corresponding to the restarted process in the memory space; If the existence is confirmed, the unprocessed data is loaded and business processing is performed; Also includes: When the process is first started, the memory space is mapped to the process space through the character device; The storage area of ​​each address space in the memory space is divided into an identifier area and a data area; The identifier area includes an identifier area size, an object size, an object address, and a bitmap; the object size represents the total size of the space occupied by the process in the corresponding data area; the object address represents the address of the space occupied by the process in the corresponding data area; and the bitmap contains information on whether the data in the corresponding data area has been processed.

2. The memory data loading method according to claim 1, characterized in that, The kernel driver maps the physical memory to a contiguous memory space in the virtual address space, including: The physical memory is mapped to the virtual address space using a memory mapping function; wherein the physical memory comprises multiple discrete memory segments; The discrete memory segments are organized into a contiguous memory space within the virtual address space.

3. The memory data loading method according to claim 2, characterized in that, Organizing the discrete memory segments into a contiguous memory space within the virtual address space includes: Each discrete memory segment is divided according to a preset page size to obtain multiple memory pages; The divided memory pages are organized into a contiguous memory space; The memory space comprises a total metadata area and multiple address spaces. The total metadata area includes the number of memory pages, the virtual address, physical address, address space, page size, and reference count of each memory page, the number, size, and location of discrete memory segments, the number of address spaces, and the starting address, size, and number of memory pages mapped to each address space. Each address space includes a metadata area and a storage area. The metadata area includes the number of memory pages corresponding to each address space and information on whether the memory pages are allocated. The storage area is used to store business data.

4. The memory data loading method according to claim 3, characterized in that, Mapping the memory space to the process space via a character device includes: Based on the data in the total metadata area, the memory space is mapped to the user-mode process space; The mapping relationship between virtual addresses and physical addresses of memory space in the user-mode process space is the same as the mapping relationship between virtual addresses and physical addresses of memory space in the kernel mode.

5. The memory data loading method according to claim 1, characterized in that, Determining whether unprocessed data corresponding to a restarted process exists in the memory space includes: Determine the kernel to which the reboot process belongs; Based on the kernel to which the reboot process belongs, determine the corresponding target address space in each of the address spaces under the memory space; Obtain the target bitmap in the identifier region under the target address space; Determine whether the data in the corresponding data area has been processed based on the target bitmap; If it is confirmed that the processing has not been completed, then it is confirmed that there is unprocessed data corresponding to the restart process; If the processing is confirmed to be complete, it is confirmed that there is no unprocessed data corresponding to the restart process.

6. The memory data loading method according to claim 5, characterized in that, Loading the unprocessed data and performing business processing includes: Load the unprocessed data in the data area under the target address space; The unprocessed data is processed according to business requirements, and the bitmap in the target address space is modified.

7. The memory data loading method according to claim 5, characterized in that, If it is confirmed that there is no unprocessed data corresponding to the restarted process, the following is also included: The data area in the target address space is initialized. The data area after initialization can be reused according to business needs.

8. The memory data loading method according to claim 7, characterized in that, After reusing the data area after initialization according to business needs, the process also includes: Save the data in the data area to the database; Record the running log of this process and clear all data in the data area.

9. The memory data loading method according to claim 1, characterized in that, The kernel driver requests physical memory during the initialization phase, including: Determine the preset size of the physical memory to be requested; Based on the preset size, multiple physical memory segments are requested through the general kernel memory allocation function.

10. The memory data loading method according to claim 1, characterized in that, The kernel driver requests physical memory during the initialization phase, including: Determine the preset size of the physical memory to be requested; Based on the preset size, the underlying contiguous physical memory allocation function is called in the initialization function to request the physical memory from the buddy system.

11. The memory data loading method according to claim 1, characterized in that, The kernel driver requests physical memory during the initialization phase, including: Determine the preset size and starting physical address of the physical memory to be requested; Edit the configuration file for system boot level; Add memory mapping parameters to the kernel boot command line in the configuration file to specify the preset size of the physical memory and the starting physical address; Save the configuration file and restart the system to reserve the physical memory.

12. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the memory data loading method as described in any one of claims 1 to 11 when executing the computer program.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the memory data loading method as described in any one of claims 1 to 11.

14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the memory data loading method as described in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Equipment driving method for user mode and kernel mode driver cooperative processing framework

    CN112231007A

  • Memory access method, program product, equipment and medium

    CN120353723A