OOT module memory allocation method, system abnormality location method
By using dedicated memory allocation functions and mapping relationships when loading the OOT module, the problem of mixed memory usage and fault location difficulties of OOT modules is solved, memory isolation and rapid fault location are achieved, and the stability and repair efficiency of the system are improved.
Patent Information
- Application Number
- CN202411170378.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2044-08-23
AI Technical Summary
The quality of OOT modules is uneven, resulting in difficulty in memory mixed use and fault positioning. The existing technology lacks effective memory allocation and fault positioning methods, which affects system stability and repair efficiency.
By using a dedicated first memory allocation function instead of the second memory allocation function when loading the OOT module, the memory in the unoccupied OOT memory pool is allocated to the OOT module, and a mapping relationship between the OOT module and the memory pool is established. Implement memory isolation and rapid fault location.
The memory isolation of OOT module is realized, which reduces fault location and repair time, and improves the stability and repair efficiency of the system.
Smart Images

Figure CN118689657B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an OOT module memory allocation method and a system abnormality locating method. Background Art
[0002] OOT kernel modules (hereinafter referred to as OOT modules) refer to "Out-Of-Tree" kernel modules. This is a type of kernel module developed and maintained outside the official source tree of the Linux kernel. Unlike "In-Tree" modules that are directly integrated into the kernel source tree, OOT modules may be provided by third-party developers, companies, or other organizations to support new hardware, file systems, network protocols, or other functions, but have not yet (or may never) been included in the official kernel source code. The typical characteristics of OOT modules are flexibility and timeliness. They allow rapid development and distribution of new features or driver support without having to wait for the next official release cycle of the kernel. The quality of OOT modules varies, so there are often situations such as downtime caused by problems with OOT modules. The occurrence of these situations affects the normal operation of the system, and the time required for problem troubleshooting and repair is long. For this, no better solution has been proposed yet. Summary of the invention
[0003] The embodiments of the present application provide an OOT module memory allocation method and a system abnormality locating method to solve one or more of the above-mentioned technical problems.
[0004] In a first aspect, an embodiment of the present application provides an OOT module memory allocation method, comprising: when loading the OOT module, using a first memory allocation function to replace a second memory allocation function existing in the OOT module, and allocating memory in an unoccupied OOT memory pool to the OOT module; wherein the OOT memory pool is bound to the first memory allocation function, and the first memory allocation function is used to allocate memory in the bound OOT memory pool to the OOT module; and the second memory allocation function is used to allocate memory in a public memory pool to the OOT module.
[0005] In a second aspect, an embodiment of the present application provides a method for locating a system abnormality, wherein the method comprises: searching the memory of the OOT module; determining a system abnormality locating result based on the search result; wherein the memory of the OOT module is allocated according to the above method.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor implements any of the above methods when executing the computer program.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of the above is implemented.
[0008] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a computer program, and the computer program implements the above method when executed by a processor.
[0009] Compared with the related art, this application has the following advantages:
[0010] According to an embodiment of the present application, when loading an OOT module, a first memory allocation function is used to replace a second memory allocation function in the OOT module, and memory in an unoccupied OOT memory pool is allocated to the OOT module; wherein the OOT memory pool is bound to a first memory allocation function, and the first memory allocation function is used to allocate memory in a bound OOT memory pool to the OOT module; and the second memory allocation function is used to allocate memory in a common memory pool to the OOT module. In an embodiment of the present application, the first memory allocation function is specifically used to allocate memory in an unoccupied OOT memory pool to the OOT module. When loading an OOT module, memory in an unoccupied OOT memory pool is allocated, and since the OOT memory pool is bound to a first memory allocation function, memory is allocated to different OOT modules by allocating memory in the OOT memory pool bound to the first memory allocation function to the OOT module through different first memory allocation functions, thereby isolating the memory used by the OOT module, and when an OOT module fails, the problem can be quickly defined based on the memory of the OOT.
[0011] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments according to the present application and should not be regarded as limiting the scope of the present application.
[0013] Figure 1 A flow chart of an OOT module memory allocation method provided in an embodiment of the present application is shown;
[0014] Figure 2A flowchart of an implementation method of an OOT module memory allocation method provided in an embodiment of the present application is shown;
[0015] Figure 3 A flow chart of a method for locating a system abnormality provided in an embodiment of the present application is shown;
[0016] Figure 4 A structural block diagram of an OOT module memory allocation device provided in an embodiment of the present application is shown;
[0017] Figure 5 A structural block diagram of a system abnormality locating device provided in an embodiment of the present application is shown;
[0018] Figure 6 A block diagram of an electronic device used to implement an embodiment of the present application is shown. DETAILED DESCRIPTION
[0019] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the concept or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary in nature and not restrictive.
[0020] To facilitate understanding of the technical solutions of the embodiments of the present application, the following describes the related technologies of the embodiments of the present application. The following related technologies can be combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.
[0021] First, the terminology involved is explained.
[0022] Memory out of bounds: Memory out of bounds refers to a situation where a computer program accesses an area of memory that does not belong to it. In programming, this usually happens when accessing an array, when an attempt is made to read or write an array element, and the index used is outside the actual allocated range of the array. This error can lead to a range of serious problems such as program crashes, data corruption, security vulnerabilities, etc.
[0023] UAF (Use After Free): UAF refers to a specific type of programming error called "use after free", which occurs when a program attempts to access or use a memory resource after it has been released. This can lead to unpredictable behavior, including data corruption, program crashes, and security vulnerabilities.
[0024] Symbol redirection: Symbol redirection is a technique in computer programming. This technique allows a program to redirect a reference to a symbol (such as a function or variable name) to another symbol at runtime, which can achieve a series of functions, including but not limited to version control, compatibility maintenance, feature patches, performance optimization, etc.
[0025] The quality of OOT modules varies, and problems such as use after free and out-of-bounds access often occur. In the existing solution, the public memory pool is the only memory pool used to allocate memory for kernel modules. Therefore, the memory allocated to OOT kernel modules and non-OOT kernel modules all comes from the public memory pool. In the existing memory allocation scheme for OOT kernel modules, the memory allocated to OOT kernel modules is usually mixed with other modules, such as other OOT kernel modules or other non-OOT kernel modules. The memory between OOT modules and even between OOT modules and non-OOT modules is not isolated. Therefore, the memory that is damaged by the OOT module is the memory used in other places, so the scene of the downtime is strange and difficult to locate.
[0026] Based on this, the present application provides an OOT module memory allocation method and a system abnormality positioning method. The OOT module memory allocation method uses a dedicated first allocation function to allocate memory in a unique corresponding OOT memory pool to each OOT kernel module, thereby achieving memory isolation between each OOT kernel module. By isolating the memory of the OOT module, the stepped memory will not be allocated to other places, so that the OOT driver steps on its own memory, and the scene when the fault occurs is in the OOT module, so that the problem can be quickly demarcated, reducing the time required for troubleshooting and repair, and reducing the losses caused by the fault.
[0027] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The several specific embodiments listed can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0028] The present application embodiment provides a method for allocating memory in an OOT module, which can be applied to a Linux system. Figure 1 The flowchart of the OOT module memory allocation method according to an embodiment of the present application is shown. The method may include:
[0029] Step S101, when loading the OOT module, use the first memory allocation function to replace the second memory allocation function existing in the OOT module, and allocate the memory in the unoccupied OOT memory pool to the OOT module; wherein the OOT memory pool is bound to the first memory allocation function, and the first memory allocation function is used to allocate the memory in the bound OOT memory pool to the OOT module; the second memory allocation function is used to allocate the memory in the public memory pool to the OOT module.
[0030] In the embodiment of the present application, the OOT module is an OOT kernel module, which is a type of kernel module. Unlike the kernel module directly integrated into the kernel source code tree, the OOT kernel module is a kernel module developed and maintained outside the official source code tree of the kernel. The OOT module can be provided by third-party developers, companies or other organizations to support new hardware, file systems, network protocols or other functions.
[0031] The OOT memory pool is a memory pool used to allocate memory to the OOT module. It should be noted that the memory pool is a memory management technology that is mainly used to improve the running efficiency of the program, especially in scenarios where small objects are frequently allocated and released. The memory pool pre-allocates a large memory area, and then divides this area into multiple smaller blocks to store objects of the same or similar size. When the program needs to create a new object, it obtains a free block from the memory pool; when the object is no longer needed, this block of memory is not returned to the operating system, but is put back into the memory pool for subsequent object allocation.
[0032] The OOT memory pool is bound to the first memory allocation function, that is, based on the OOT memory pool, a unique first memory allocation function can be determined, and based on the first memory allocation function, a unique OOT memory pool can be determined. The first memory allocation function is a memory allocation function dedicated to the OOT memory pool to which it is bound, that is, the first memory allocation function is used to allocate memory in the bound OOT memory pool to the OOT module.
[0033] The OOT module has a logic for allocating memory, that is, a second memory allocation function. The second memory allocation function is used to allocate memory in a public memory pool to the OOT module. If memory is allocated to the OOT module based on the second memory allocation function, the memory of the OOT module and other modules may be mixed.
[0034] In an embodiment of the present application, the operation of loading the memory module is performed when the system starts to start, or the operation of loading the memory module is started according to actual needs. When loading the target OOT module, the first memory allocation function is used to replace the second memory allocation function in the OOT module, that is, the task that needs to be processed by the second memory allocation function for memory allocation is replaced by the first memory allocation function, and the memory in the unoccupied OOT memory pool is allocated to the OOT module, and the allocation process is performed by the dedicated first memory allocation function. Based on this operation, the memory used by the OOT module can be isolated to avoid mixing with the memory of other modules. When the OOT module has memory out-of-bounds, UAF and other exceptions, the problem location can be quickly demarcated, the problem repair efficiency is improved, and asset loss is reduced.
[0035] According to an embodiment of the present application, when loading an OOT module, a first memory allocation function is used to replace a second memory allocation function in the OOT module, and memory in an unoccupied OOT memory pool is allocated to the OOT module; wherein the OOT memory pool is bound to a first memory allocation function, and the first memory allocation function is used to allocate memory in a bound OOT memory pool to the OOT module; and the second memory allocation function is used to allocate memory in a common memory pool to the OOT module. In an embodiment of the present application, the first memory allocation function is specifically used to allocate memory in an unoccupied OOT memory pool to the OOT module. When loading an OOT module, memory in an unoccupied OOT memory pool is allocated, and since the OOT memory pool is bound to a first memory allocation function, memory is allocated to different OOT modules by allocating memory in the OOT memory pool bound to the first memory allocation function to the OOT module through different first memory allocation functions, thereby isolating the memory used by the OOT module, and when an OOT module fails, the problem can be quickly defined based on the memory of the OOT.
[0036] In a possible implementation, allocating memory in an unoccupied OOT memory pool to the OOT module can be performed according to the following steps: obtaining a mapping relationship between the OOT module and the OOT memory pool; according to the mapping relationship, using the OOT memory pool corresponding to the currently loaded OOT module as an unoccupied OOT memory pool; and allocating memory in the unoccupied OOT memory pool to the currently loaded OOT module.
[0037] In an embodiment of the present application, one or more OOT modules and one or more OOT memory pools may be included. The mapping relationship between the OOT module and the OOT memory pool can be used to determine the OOT memory pool that uniquely corresponds to the OOT module, and to determine the OOT module that uniquely corresponds to the OOT memory pool.
[0038] Based on the mapping relationship, the OOT memory pool corresponding to the currently loaded OOT module can be determined. Since there is a one-to-one correspondence between the currently loaded OOT module and the OOT memory pool, the currently loaded OOT module is an OOT module that has not been loaded before, and the OOT memory pool corresponding to the currently loaded OOT module is an unoccupied OOT memory pool, that is, according to the mapping relationship, the OOT memory pool corresponding to the currently loaded OOT module is used as the unoccupied OOT memory pool.
[0039] The memory in the unoccupied OOT memory pool is allocated to the currently loaded OOT module, thereby allocating different memories in the OOT memory pool to different OOT modules.
[0040] In a possible implementation, obtaining a mapping relationship between an OOT module and an OOT memory pool may be performed according to the following steps: initializing multiple OOT memory pools, and generating a first memory allocation function bound to the OOT memory pool; in the case where a target kernel module is an OOT module, if a second memory allocation function exists in the target kernel module, determining a candidate OOT memory pool in the OOT memory pool, and establishing a mapping relationship between the target kernel module and the candidate OOT memory pool.
[0041] In this possible implementation, firstly, multiple OOT memory pools are configured, and the multiple OOT memory pools are initialized. A first memory allocation function is bound to each initialized OOT memory pool, that is, multiple OOT memory pools are initialized, and the first memory allocation function bound to the OOT memory pool is generated.
[0042] For kernel modules, it can be determined whether they are OOT modules one by one, and the kernel module currently being processed is used as the target kernel module. When a certain target kernel module is an OOT module, it is further determined whether there is a second memory allocation function in the target kernel module. If there is a second memory allocation function in the target kernel module, a memory pool is selected from the initialized OOT memory pool as a candidate OOT memory pool, and a mapping relationship between the OOT module and the candidate OOT memory pool is established. That is, when a certain target kernel module is an OOT module, if there is a second memory allocation function in the target kernel module, a candidate OOT memory pool is determined in the OOT memory pool, and a mapping relationship between the target kernel module and the candidate OOT memory pool is established.
[0043] In this possible implementation, a mapping relationship is established between the target kernel module having the second memory allocation function and the OOT memory pool, so that when memory allocation is performed subsequently, the second memory allocation function is replaced by the first memory allocation function to ensure that the memory in the OOT memory pool with the mapping relationship is allocated to the OOT module, thereby isolating the memory of the OOT module.
[0044] In a possible implementation, generating the first memory allocation function bound to the OOT memory pool can be performed according to the following steps: obtaining memory allocation API (Application Programming Interface) data; wherein the memory allocation API data is shared by multiple kernel modules; the memory allocation API data is used to allocate memory to the multiple kernel modules; copying the memory allocation API data, and using the copied memory allocation API data as the first memory allocation function bound to the OOT memory pool in the OOT memory pool.
[0045] In this possible implementation, the memory allocation API data is an interface provided by the operating system runtime library for dynamically allocating and managing memory when the program is running. These APIs allow programs to request memory when needed and release memory when no longer needed so that other programs or system components can use it. Different platforms and languages may have different APIs. Specifically, the memory allocation API data may include but is not limited to the following data: kmalloc function and kfree function: used to allocate and release small blocks of memory in kernel space; vmalloc function and vfree function: used to allocate and release large blocks of virtual continuous memory; alloc_pages function and free_pages function: directly request and release physical pages from the page allocator.
[0046] It should be noted that in this possible implementation, the memory allocation API data can be used to allocate memory for any kernel module that requires memory allocation processing, that is, the memory allocation API data is shared by multiple kernel modules, and the memory allocation API data is used to allocate memory for the multiple kernel modules.
[0047] The memory pool in the OOT memory pool that currently needs to generate the first memory allocation function is used as the set OOT memory pool, and the copied memory allocation API data is used as the first memory allocation function bound to the OOT memory pool in the OOT memory pool.
[0048] In this possible implementation, by copying the existing memory allocation API data, the copied result is used as the first memory allocation function bound to each OOT memory pool, wherein the number of copies can be determined according to the number of OOT memory pools. For example, the two numbers can be the same to ensure that each OOT memory pool is bound to a dedicated first memory allocation function, thereby further ensuring the memory isolation effect of the OOT module that has a mapping relationship with the OOT memory pool.
[0049] In a possible implementation, determining a candidate OOT memory pool in the OOT memory pool may be performed according to the following steps: determining an OOT memory pool randomly or in a specified order from multiple initialized OOT memory pools as a preliminary OOT memory pool; and using the preliminary OOT memory pool as a candidate OOT memory pool if the preliminary OOT memory pool does not have the mapping relationship with any OOT module.
[0050] In this possible implementation, a memory pool can be randomly selected from the multiple initialized OOT memory pools as the primary OOT memory pool, or the multiple initialized OOT memory pools can be sorted, and the OOT memory pools are sequentially selected according to the sorting results as the primary OOT memory pools. Afterwards, it is determined whether the primary OOT memory pool has a mapping relationship with the OOT module. If the mapping relationship does not exist with any OOT module, the primary OOT memory pool is used as a candidate OOT memory pool.
[0051] It should be noted that if it can be determined according to the selection method that the initially selected OOT memory pool selected from the multiple OOT memory pools after initialization does not have a mapping relationship with any OOT module, then there is no need to perform the step of determining whether the initially selected OOT memory pool has a mapping relationship with the OOT module again. For example, if the multiple OOT memory pools after initialization are sorted, and the OOT memory pools are selected in sequence according to the sorting results, then the OOT memory pool selected each time is one that has not been selected before, and it can be determined that the sequentially selected OOT memory pools do not have a mapping relationship with any OOT module.
[0052] In this possible implementation, the method of determining the primary OOT memory pool among the multiple OOT memory pools after initialization can be selected according to actual needs, and the embodiment of the present application does not make specific limitations on this.
[0053] In a possible implementation, using the first memory allocation function to replace the second memory allocation function existing in the OOT module can be performed according to the following steps: obtaining first address information of the first memory allocation function; replacing the second address information of the second memory allocation function with the first address information to redirect the second memory allocation function to the first memory allocation function.
[0054] In this possible implementation, the address of the first memory allocation function is used as the first address information. The address of the second memory allocation function is used as the second address information. The first address information is used to replace the second address information of the second memory allocation function, so that the original operation of calling the second memory allocation function is changed to calling the first memory allocation function, and the first memory allocation function is used to perform memory allocation.
[0055] It should be noted that in Linux systems, redirection refers to transferring the input or output of a command from the default location (usually the terminal) to another location (such as a file or another command). By using redirection, you can easily save the output of a command, use file contents as the input of a command, and concatenate the output of multiple commands.
[0056] In this possible implementation, based on symbol redirection processing, it is possible to switch from using a public second memory allocation function to allocate memory for the OOT module to using a dedicated first memory allocation function, thereby further ensuring the memory isolation effect between the OOT module and other modules.
[0057] In a possible implementation, establishing a mapping relationship between the OOT module and the candidate OOT memory pool can be performed according to the following steps: adding first field information to the OOT module, and using the first field information to store second index information of the candidate OOT memory pool; and adding second field information to the candidate OOT memory pool, and using the second field information to store the first index information of the OOT module; establishing a one-to-one correspondence between the first index information and the second index information to characterize the mapping relationship between the OOT module and the candidate OOT memory pool.
[0058] In this possible implementation, field information may be added to the OOT module and the candidate OOT memory pool, respectively. First field information is added to the OOT module, and second field information is added to the candidate OOT memory pool, and the index information of the other party is stored based on the added field information, that is, the second index information of the candidate OOT memory pool is stored using the first field information, and the first index information of the OOT module is stored using the second field information.
[0059] In this possible implementation, index information is recorded through field information to establish a one-to-one correspondence between the first index information and the second index information to characterize the mapping relationship between the OOT module and the candidate OOT memory pool, thereby achieving a direct one-to-one correspondence between the OOT module and the candidate OOT memory pool, so as to determine the OOT memory pool that uniquely corresponds to the OOT module, and determine the OOT module that uniquely corresponds to the OOT memory pool.
[0060] In a possible implementation, when a target kernel module is an OOT module, the following steps can be performed: obtaining index information of the target kernel module; wherein the index information at least includes index key value information; if the index information is the same as any pre-stored set index information, determining that the target kernel module is an OOT module.
[0061] In this possible implementation, the target kernel module includes index information, and the index information at least includes index key value information, and the target kernel module can be uniquely identified by the index information. The pre-stored set index information is a pre-stored data list of index information of all OOT modules in the system, and the list can be stored in the form of a data table. By searching the pre-stored set index information, it is determined whether the index information of the target kernel module is included. If the index information is the same as any pre-stored set index information, it is determined that the target kernel module is an OOT module.
[0062] It should be noted that a database index is a data structure that improves the speed of data retrieval, making the process of obtaining information from a database table faster and more efficient. Index information includes but is not limited to the following information: Index key values (KeyValues): This is the main data stored in the index, usually the value of a column in the table. Key values are used to quickly locate data rows. Row identifiers (RowIdentifiers): Each index entry is associated with one or more row identifiers, which can be a row number, pointer, or primary key value, used to directly locate specific rows in the database table. Index type: Index type information, such as hash, bitmap, full-text index, etc. Different types of indexes have different structures and query efficiencies. Statistical information: Including the cardinality of the column (the number of different values), selectivity (the frequency of a certain value), etc., which are used to optimize the query plan. Index metadata: Such as the name of the index, the column it is based on, whether it is unique, whether it is empty, and other attributes. Index structure: Index data structure information, such as depth, etc. Additional information: It may also include some additional information, such as the index version, space allocation information, lock status, etc.
[0063] In this possible implementation, by searching the pre-stored setting index information, it can be quickly determined whether the current target kernel module is an OOT module.
[0064] In one possible implementation, if there is a second memory allocation function in the target kernel module, the following steps can be performed: query the function identification information included in the target kernel module; wherein the function identification information at least includes function name information; if the function identification information is the same as any given pre-stored function identification information, it is determined that there is a second memory allocation function in the target kernel module.
[0065] In this possible implementation, the information of the target kernel module includes function identification information, which at least includes function name information, and the second memory allocation function in the target kernel module can be uniquely identified by the function identification information. The pre-stored given function identification information is a pre-stored data list of function identification information of possible second memory allocation functions, and the list can be stored in the form of a data table. By searching the pre-stored given function identification information, it is determined whether it includes the function identification information in the target kernel module. If the function identification information in the target kernel module is the same as any pre-stored given function identification information, it is determined that the second memory allocation function exists in the target kernel module.
[0066] In this possible implementation, by searching for pre-stored given function identification information, it can be quickly determined whether the second memory allocation function exists in the current target kernel module.
[0067] See also Figure 2 The flowchart of the implementation method of the OOT module memory allocation method is shown below. The implementation of the method is described below with a specific embodiment. The method can be specifically performed according to the following steps:
[0068] 1. When the Linux kernel is initialized, multiple OOT memory pools dedicated to the OOT module and a first memory allocation function bound to each OOT memory pool are created and initialized.
[0069] 2. When loading a module, determine whether it is an OOT module. If not, execute the loading process of a normal module.
[0070] 3. If it is an OOT module, determine whether the OOT module has logic for allocating memory, that is, whether it contains a second memory allocation function. If not, execute the loading process of a normal module.
[0071] 4. If the OOT module contains a second memory allocation function, one is selected from the set of initialized OOT module dedicated memory pools, and a mapping relationship is established with the currently loaded OOT module.
[0072] 5. Find the symbols of the functions related to memory allocation in the OOT module, that is, the symbol information in the second memory allocation function, and redirect these symbols to the first memory allocation function of the OOT dedicated memory pool that has established the mapping.
[0073] The embodiment of the present application provides an OOT module memory allocation method, which involves the Linux kernel. The method establishes a mapping relationship between the OOT module and the OOT memory pool, and a binding relationship between the OOT memory pool and the first memory allocation function, so as to replace the second memory allocation function in the target OOT module with the target first memory allocation function, allocate the memory in the target OOT memory pool to the target OOT module, and isolate the memory used by the OOT module. Furthermore, when the OOT module fails, for example, including but not limited to: use after release, memory out of bounds, etc., the cause of the problem can be quickly located based on the memory used by itself, reducing the time for troubleshooting and repairing, and improving the efficiency of problem handling.
[0074] The present application also provides a method for locating system abnormalities. Figure 3 The flowchart of a method for locating a system abnormality according to an embodiment of the present application is shown. The method may include:
[0075] Step S301, searching the memory of the OOT module.
[0076] In the embodiment of the present application, the memory of the OOT module is isolated from the memory of other modules in the system. Each OOT module has its own dedicated memory, which is allocated by replacing the second memory allocation function in the OOT module with the first memory allocation function bound to the OOT memory pool that has a mapping relationship with the OOT module, and the memory of the OOT memory pool is allocated.
[0077] Step S302, determining the system abnormality location result according to the search result; wherein the memory of the OOT module is allocated according to the above method.
[0078] In the embodiment of the present application, the search result includes address information corresponding to the abnormal information. According to the address information corresponding to the abnormal information, the abnormal position can be quickly located to obtain the abnormal location result.
[0079] In an embodiment of the present application, the target first memory allocation function is specifically used to allocate memory in the target OOT memory pool to the target kernel module, thereby isolating the memory used by the target OOT module. When a failure occurs in the target OOT module, the problem can be quickly defined based on the memory of the target OOT.
[0080] Corresponding to the application scenario and method of the method provided in the embodiment of the present application, the embodiment of the present application also provides an OOT module memory allocation device. Figure 4 The figure shows a structural block diagram of an OOT module memory allocation device according to an embodiment of the present application, and the device may include:
[0081] The memory allocation module 401 is used to replace the second memory allocation function in the OOT module with the first memory allocation function when loading the OOT module, and allocate the memory in the unoccupied OOT memory pool to the OOT module; wherein the OOT memory pool is bound to the first memory allocation function, and the first memory allocation function is used to allocate the memory in the bound OOT memory pool to the OOT module; the second memory allocation function is used to allocate the memory in the public memory pool to the OOT module.
[0082] According to an embodiment of the present application, when loading an OOT module, a first memory allocation function is used to replace a second memory allocation function in the OOT module, and memory in an unoccupied OOT memory pool is allocated to the OOT module; wherein the OOT memory pool is bound to a first memory allocation function, and the first memory allocation function is used to allocate memory in a bound OOT memory pool to the OOT module; and the second memory allocation function is used to allocate memory in a common memory pool to the OOT module. In an embodiment of the present application, the first memory allocation function is specifically used to allocate memory in an unoccupied OOT memory pool to the OOT module. When loading an OOT module, memory in an unoccupied OOT memory pool is allocated, and since the OOT memory pool is bound to a first memory allocation function, memory is allocated to different OOT modules by allocating memory in the OOT memory pool bound to the first memory allocation function to the OOT module through different first memory allocation functions, thereby isolating the memory used by the OOT module, and when an OOT module fails, the problem can be quickly defined based on the memory of the OOT.
[0083] In a possible implementation, allocating memory in an unoccupied OOT memory pool to the OOT module includes: acquiring a mapping relationship between the OOT module and the OOT memory pool; according to the mapping relationship, using the OOT memory pool corresponding to the currently loaded OOT module as an unoccupied OOT memory pool; and allocating memory in the unoccupied OOT memory pool to the currently loaded OOT module.
[0084] In a possible implementation, obtaining a mapping relationship between an OOT module and an OOT memory pool may be performed according to the following steps: initializing multiple OOT memory pools, and generating a first memory allocation function bound to the OOT memory pool; in the case where a target kernel module is an OOT module, if a second memory allocation function exists in the target kernel module, determining a candidate OOT memory pool in the OOT memory pool, and establishing a mapping relationship between the target kernel module and the candidate OOT memory pool.
[0085] In a possible implementation, generating the first memory allocation function bound to the OOT memory pool can be performed according to the following steps: obtaining memory allocation API data; wherein the memory allocation API data is shared by multiple kernel modules; the memory allocation API data is used to allocate memory for the multiple kernel modules; copying the memory allocation API data, and using the copied memory allocation API data as the first memory allocation function bound to the OOT memory pool set in the OOT memory pool.
[0086] In a possible implementation, determining a candidate OOT memory pool in the OOT memory pool may be performed according to the following steps: determining an OOT memory pool randomly or in a specified order from multiple initialized OOT memory pools as a preliminary OOT memory pool; and using the preliminary OOT memory pool as a candidate OOT memory pool if the preliminary OOT memory pool does not have the mapping relationship with any OOT module.
[0087] In a possible implementation, using the first memory allocation function to replace the second memory allocation function existing in the OOT module can be performed according to the following steps: obtaining first address information of the first memory allocation function; replacing the second address information of the second memory allocation function with the first address information to redirect the second memory allocation function to the first memory allocation function.
[0088] In a possible implementation, establishing a mapping relationship between the OOT module and the candidate OOT memory pool can be performed according to the following steps: adding first field information to the OOT module, and using the first field information to store second index information of the candidate OOT memory pool; and adding second field information to the candidate OOT memory pool, and using the second field information to store the first index information of the OOT module; establishing a one-to-one correspondence between the first index information and the second index information to characterize the mapping relationship between the OOT module and the candidate OOT memory pool.
[0089] In a possible implementation, when a target kernel module is an OOT module, the following steps can be performed: obtaining index information of the target kernel module; wherein the index information at least includes index key value information; if the index information is the same as any pre-stored set index information, determining that the target kernel module is an OOT module.
[0090] In one possible implementation, if there is a second memory allocation function in the target kernel module, the following steps can be performed: query the function identification information included in the target kernel module; wherein the function identification information at least includes function name information; if the function identification information is the same as any given pre-stored function identification information, it is determined that there is a second memory allocation function in the target kernel module.
[0091] The functions of each module in each device in the embodiments of the present application can be found in the corresponding description in the above method, and have corresponding beneficial effects, which will not be repeated here.
[0092] Corresponding to the application scenario and method of the method provided in the embodiment of the present application, the embodiment of the present application also provides a system abnormality positioning device. Figure 5 The figure is a structural block diagram of a system abnormality locating device according to an embodiment of the present application, and the device may include:
[0093] The search module 501 is used to search the memory of the OOT module; the positioning module 502 is used to determine the system abnormality positioning result according to the search result; wherein the memory of the OOT module is allocated according to the above method.
[0094] In an embodiment of the present application, the target first memory allocation function is specifically used to allocate memory in the target OOT memory pool to the target kernel module, thereby isolating the memory used by the target OOT module. When a failure occurs in the target OOT module, the problem can be quickly defined based on the memory of the target OOT.
[0095] The functions of each module in each device in the embodiments of the present application can be found in the corresponding description in the above method, and have corresponding beneficial effects, which will not be repeated here.
[0096] Figure 6 FIG. 1 is a block diagram of an electronic device used to implement an embodiment of the present application. Figure 6 As shown, the electronic device includes: a memory 601 and a processor 602. The memory 601 stores a computer program that can be run on the processor 602. When the processor 602 executes the computer program, the method in the above embodiment is implemented. The number of the memory 601 and the processor 602 can be one or more.
[0097] The electronic device also includes:
[0098] The communication interface 603 is used to communicate with external devices and perform data exchange transmission.
[0099] If the memory 601, the processor 602 and the communication interface 603 are implemented independently, the memory 601, the processor 602 and the communication interface 603 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0100] Optionally, in a specific implementation, if the memory 601, the processor 602 and the communication interface 603 are integrated on a chip, the memory 601, the processor 602 and the communication interface 603 can communicate with each other through an internal interface.
[0101] An embodiment of the present application provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present application when the program is executed by a processor.
[0102] An embodiment of the present application provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor, the above method is implemented.
[0103] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes the method provided by the embodiment of the present application.
[0104] An embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the application.
[0105] It should be understood that the above processor can be a processor (Central Processing Unit, CPU), and can also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application-specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. It is worth noting that the processor can be a processor that supports the Advanced RISC Machines (ARM) architecture.
[0106] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of exemplary but not limiting description, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DR RAM).
[0107] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0108] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
[0109] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.
[0110] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0111] Any process or method described in the flow chart or otherwise described herein can be understood as a module, fragment or portion of a code representing one or more executable instructions for implementing the steps of a specific logical function or process. And the scope of the preferred embodiment of the present application includes other implementations, in which the functions may not be performed in the order shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the functions involved.
[0112] The logic and / or steps described in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with these instruction execution systems, apparatuses or devices.
[0113] It should be understood that the various parts of the present application can be implemented with hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented with software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium, and when the program is executed, it includes one of the steps of the method embodiment or a combination thereof.
[0114] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above-mentioned integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a disk or an optical disk, etc.
[0115] The above is only an exemplary embodiment of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various changes or substitutions within the technical scope recorded in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for allocating memory of an OOT module, comprising: When loading the OOT module, the first memory allocation function is used to replace the second memory allocation function existing in the OOT module, and the memory in the unoccupied OOT memory pool is allocated to the OOT module; wherein the OOT memory pool is bound to the first memory allocation function, and the first memory allocation function is used to allocate the memory in the bound OOT memory pool to the OOT module; the second memory allocation function is used to allocate the memory in the public memory pool to the OOT module; the OOT module is an Out-Of-Tree kernel module.
2. The method according to claim 1, wherein: Allocating the memory in the unoccupied OOT memory pool to the OOT module includes: Get the mapping relationship between the OOT module and the OOT memory pool; According to the mapping relationship, the OOT memory pool corresponding to the currently loaded OOT module is used as the unoccupied OOT memory pool; Allocate the memory in the unoccupied OOT memory pool to the currently loaded OOT module.
3. The method according to claim 2, wherein: Get the mapping relationship between the OOT module and the OOT memory pool, including: Initialize multiple OOT memory pools and generate a first memory allocation function bound to the OOT memory pool; In the case where a certain target kernel module is an OOT module, if the target kernel module has a second memory allocation function, a candidate OOT memory pool is determined in the OOT memory pool, and a mapping relationship between the target kernel module and the candidate OOT memory pool is established.
4. The method according to claim 3, wherein: Generating a first memory allocation function bound to the OOT memory pool includes: Acquire memory allocation API data; wherein the memory allocation API data is shared by multiple kernel modules; the memory allocation API data is used to allocate memory for the multiple kernel modules; The memory allocation API data is copied, and the copied memory allocation API data is used as the first memory allocation function for setting the OOT memory pool binding in the OOT memory pool.
5. The method according to claim 3, wherein: Determining a candidate OOT memory pool in the OOT memory pool includes: Determine an OOT memory pool randomly or in a specified order from multiple initialized OOT memory pools as the primary OOT memory pool; When the initially selected OOT memory pool does not have the mapping relationship with any OOT module, the initially selected OOT memory pool is used as a candidate OOT memory pool.
6. The method according to claim 1, wherein: Replacing the second memory allocation function in the OOT module with the first memory allocation function includes: Acquire first address information of the first memory allocation function; The second address information of the second memory allocation function is replaced by the first address information to redirect the second memory allocation function to the first memory allocation function.
7. The method according to claim 3, wherein: Establishing a mapping relationship between the OOT module and the candidate OOT memory pool includes: Adding first field information to the OOT module, and using the first field information to store second index information of the candidate OOT memory pool; and Adding second field information to the candidate OOT memory pool, and using the second field information to store the first index information of the OOT module; A one-to-one correspondence between the first index information and the second index information is established to characterize a mapping relationship between the OOT module and the candidate OOT memory pool.
8. The method according to claim 3, wherein: When a target kernel module is an OOT module, it includes: Obtaining index information of the target kernel module; wherein the index information at least includes index key value information; If the index information is the same as any pre-stored set index information, it is determined that the target kernel module is an OOT module.
9. The method according to claim 3, wherein: If there is a second memory allocation function in the target kernel module, comprising: Querying function identification information included in the target kernel module; wherein the function identification information at least includes function name information; If the function identification information is the same as any pre-stored given function identification information, it is determined that a second memory allocation function exists in the target kernel module.
10. A method for locating system anomalies, wherein: The method comprises: Find the memory of the OOT module; Determine the system abnormality positioning result according to the search result; wherein the memory of the OOT module is allocated according to the method described in any one of claims 1-9.
11. An electronic device comprising a memory, a processor and a computer program stored in the memory, wherein the processor implements the method according to any one of claims 1 to 10 when executing the computer program.
12. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
13. A computer program product, wherein: The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Linux kernel decoupling method and device and readable storage medium
CN115113916A
Memory calling method and related equipment
CN117193999A
Software communication system structure-based packaging method of operator component
CN118466938A
Wrapper for enabling an object otented application to maintain virtual memory using procedural function calls
US5473777A
Memory access control method and apparatus
WO2024082232A1
