Memory allocation method, and electronic device and storage medium
By receiving and allocating memory according to the huge page memory parameters and non-huge page memory parameters, it solves the problem of insufficient non-huge page memory caused by the memory module in the server being damaged or pulled out, and ensures the normal operation of the operating system and high-performance virtual machines.
Patent Information
- Application Number
- PCT/CN2024/071426
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-22
- Filing Date
- 2024-01-09
- Publication Date
- 2024-08-29
AI Technical Summary
In Linux systems, using huge page memory can improve performance, but when allocating huge page memory in the server, if the memory module is damaged or pulled out, it may cause insufficient non-huge page memory available to the system, causing the operating system to fail to run normally. .
By receiving the huge page memory parameters and non-huge page memory parameters of the target node, it accurately allocates huge page memory and ordinary memory, optimizes the memory allocation method, and ensures that the operating system has enough available memory.
It avoids the problem of insufficient non-huge page memory caused by damaged or unplugged memory modules, ensures the normal operation of the operating system, and optimizes the memory allocation method to ensure the normal operation of high-performance virtual machines and programs.
Smart Images

Figure CN2024071426_29082024_PF_FP_ABST
Abstract
Description
Memory allocation method, electronic device and storage medium
[0001] Cross-references
[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on February 22, 2023, with application number 202310197516.9 and application name “Memory allocation method, electronic device and storage medium”. The entire contents of the application are incorporated by reference into this application. Technical Field
[0003] The present application belongs to the field of memory management technology, and specifically relates to a memory allocation method, electronic device, and storage medium. Background Art
[0004] In Linux systems, using huge page memory for applications can significantly improve performance. This is especially true in cloud environments and virtualization scenarios. VMs using huge page memory perform much better than VMs without huge page memory. However, allocating huge page memory in the system reduces the available memory for the operating system itself.
[0005] Currently, servers generally use a non-uniform memory access (NUMA) architecture, which can be divided into multiple nodes. Each node may have different or equal amounts of memory. During server operation, high-performance VMs require huge pages of memory within the node, while operating system processes and other processes require non-huge pages of memory. In a multi-node environment, the operating system allocates huge pages to each node evenly.
[0006] However, using the existing memory allocation method, if the server memory stick is damaged or individual memory sticks are removed, since the memory allocation method remains unchanged, the number of huge page memory allocations on the node may be too large, resulting in insufficient non-huge page memory available to the system and causing the operating system to malfunction.
[0007] Summary of the Invention
[0008] The embodiments of the present application provide a memory allocation method, electronic device, and storage medium, which can solve the problem that the operating system cannot run normally due to insufficient non-huge page memory available to the system.
[0009] In a first aspect, an embodiment of the present application provides a method for memory allocation, the method comprising: receiving huge page memory parameters corresponding to a target node; and allocating huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters.
[0010] In a second aspect, an embodiment of the present application provides a memory allocation device, which includes: a receiving module for receiving huge page memory parameters corresponding to a target node; and an allocation module for allocating huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters.
[0011] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0012] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] FIG1 is a flow chart of a memory allocation method provided in an embodiment of the present application;
[0014] FIG2 is a schematic diagram of node memory allocation provided by an embodiment of the present application;
[0015] FIG3 is a flow chart of another memory allocation method provided in an embodiment of the present application;
[0016] FIG4 is a schematic diagram of the structure of a memory allocation device provided in an embodiment of the present application;
[0017] FIG5 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0019] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.
[0020] The memory allocation method, electronic device, and storage medium provided in the embodiments of the present application are described in detail below with reference to specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0021] FIG1 illustrates a memory allocation method provided by an embodiment of the present application. The method may be executed by an electronic device, which may include a server and / or a terminal device, such as a vehicle-mounted terminal or a mobile phone terminal. In other words, the method may be executed by software or hardware installed in the electronic device, and includes the following steps:
[0022] Step 102: Receive huge page memory parameters corresponding to the target node.
[0023] In this step, the huge page memory of the target node can be allocated during the operating system startup phase or after the operating system is started, and the specific time for allocating the huge page memory is not specifically limited here. When performing memory allocation of the target node, the huge page memory parameters corresponding to the target node can be received. It should be understood that the huge page memory parameters corresponding to the target node can be received during the system startup phase, and the electronic device can save the huge page memory parameters, and then perform memory allocation through the stored huge page memory parameters when memory allocation of the target node needs to be performed. The above-mentioned huge page memory parameters can be pre-configured by the user, that is, before allocating the memory of the target node, the user needs to configure the above-mentioned huge page memory parameters according to the memory allocation method of the pre-deployed plan.
[0024] Step 104: Allocate huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters.
[0025] Specifically, when performing memory allocation of the target node, the memory corresponding to the huge page memory parameter in the target node's memory to be allocated can be allocated as huge page memory according to the huge page memory parameter, that is, the electronic device can parse the huge page memory parameter, determine the number of huge page memories that the target node needs to allocate, and allocate the target node's huge page memory in the target node's memory to be allocated according to the number of huge page memories that the target node needs to allocate. The above-mentioned huge page memory can be used for high-performance virtual machines or high-performance programs. In addition, the memory other than the huge page memory can be allocated as ordinary memory for the normal operation of the operating system. As an example, assuming that the target node's memory to be allocated is 10 gigabytes (GB) and the huge page memory parameter received is 6GB, then when performing memory allocation of the target node, 6GB of the target node's 10GB memory can be allocated as huge page memory, and then 4G of the target node's memory other than the huge page memory can be allocated as ordinary memory for the normal operation of the operating system.
[0026] The memory allocation method provided in the embodiment of the present application receives huge page memory parameters corresponding to the target node; according to the huge page memory parameters, the huge page memory is allocated in the to-be-allocated memory of the target node. The memory of the target node can be accurately allocated according to the pre-configured huge page memory parameters for the target node, ensuring that the operating system has available memory, optimizing the memory allocation method, and optimizing the ratio of huge page memory to ordinary memory on the target node. This avoids the problem that the target node may allocate too many huge page memories after the server memory bar is damaged or individual memory is pulled out, resulting in insufficient non-huge page memory available to the system, causing the operating system to fail to operate normally, thereby ensuring the normal operation of the operating system.
[0027] In one implementation, before allocating huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters, it also includes: receiving non-huge page memory parameters corresponding to the target node; determining non-huge page memory according to the non-huge page memory parameters; and determining the memory of the target node other than the non-huge page memory as the to-be-allocated memory.
[0028] Specifically, due to the normal operation of the operating system, non-huge page memory (ordinary memory) is required for protection. In this application, before allocating the huge page memory of the target node according to the huge page memory parameters, the non-huge page memory parameters corresponding to the target node can be received. Similarly, the non-huge page memory parameters can also be pre-configured by the user, that is, before allocating the memory of the target node, the user needs to configure the above-mentioned non-huge page memory parameters according to the pre-deployed planned memory allocation method.
[0029] The non-huge page memory parameter takes precedence over the huge page memory parameter. Specifically, when both the non-huge page memory parameter and the huge page memory parameter are received, the non-huge page memory parameter is parsed first to determine the amount of non-huge page memory required for the target node. Based on the amount of non-huge page memory required for the target node, the target node's non-huge page memory is allocated within the target node's memory. After the target node's non-huge page memory is allocated, the remaining memory in the target node's memory, excluding the non-huge page memory, can be identified as unallocated memory. The memory in the unallocated memory corresponding to the huge page memory parameter can then be allocated as huge page memory.
[0030] As an example, assume that the target node has 20 GB of memory, the received non-huge page memory parameter is 11 GB, and the received huge page memory parameter is 6 GB. Then, when allocating memory, 11 GB of the 20 GB of memory corresponding to the target node needs to be allocated as non-huge page memory, and 9 GB of memory other than the non-huge page memory needs to be determined as unallocated memory. Then, based on the huge page memory parameter, 6 GB of the 9 GB of unallocated memory needs to be allocated as huge page memory.
[0031] In this way, before allocating huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters, the non-huge page memory parameters corresponding to the target node are received; the non-huge page memory is determined according to the non-huge page memory parameters; the memory other than the huge page memory in the memory of the target node is determined as the to-be-allocated memory, and the non-huge page memory (ordinary memory) for the normal operation of the operating system can be reserved in advance, thereby ensuring the normal operation of the operating system.
[0032] In one implementation, when only the non-huge page memory parameters corresponding to the target node are received and the huge page memory parameters corresponding to the target node are not received, the non-huge page memory corresponding to the target node can be allocated only according to the non-huge page memory parameters corresponding to the target node, and the memory other than the huge page memory in the memory of the target node is determined as the memory to be allocated. When allocating the huge page memory parameters corresponding to the target node, the huge page memory of the target node can be allocated in the memory to be allocated according to the system default policy. In addition, when the target node has already allocated huge page memory, it is not necessary to allocate the huge page memory of the target node according to the system default policy. In this way, the non-huge page memory (ordinary memory) for the normal operation of the operating system can be reserved in advance, thereby ensuring the normal operation of the operating system.
[0033] In one implementation, allocating huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters includes: when the to-be-allocated memory of the target node is less than or equal to the memory corresponding to the huge page memory parameters, allocating the to-be-allocated memory of the target node as the huge page memory.
[0034] Specifically, when allocating huge page memory to a target node based on its corresponding huge page memory parameters, if the target node's remaining memory is less than or equal to the huge page memory parameters, the entire remaining memory can be allocated as huge page memory. This ensures that the required huge page memory is provided as much as possible when allocating huge page memory to the target node.
[0035] In one implementation, after allocating the to-be-allocated memory as the huge page memory, the method further includes: ending the allocation of the huge page memory of the target node.
[0036] Specifically, if the target node's to-be-allocated memory is less than or equal to the huge page memory parameter, after allocating the to-be-allocated memory as huge page memory, the huge page memory allocation for the target node can be terminated to ensure that the huge page memory allocated to the target node is less than or equal to the to-be-allocated memory, thereby avoiding the additional use of memory from other nodes for huge page memory allocation for the target node.
[0037] In one implementation, after completing the allocation of the huge page memory of the target node, it also includes: receiving huge page memory parameters corresponding to other nodes except the target node; traversing the other nodes, and allocating the huge page memory corresponding to the other nodes in the to-be-allocated memory corresponding to the other nodes according to the huge page memory parameters corresponding to the other nodes.
[0038] Specifically, a server environment using the NUMA architecture usually includes multiple nodes, so after completing the allocation of the huge page memory of the target node, the memory of other nodes can continue to be allocated. When receiving the huge page memory parameters of the target node, the huge page memory parameters of other nodes other than the target node can be received at the same time. The memory allocation method of other nodes is the same as the memory allocation method of the target node. Specifically, other nodes can be traversed, and according to the huge page memory parameters corresponding to other nodes, the memory corresponding to the huge page memory parameters in the memory to be allocated corresponding to other nodes can be allocated as huge page memory. It should be understood that when receiving the non-huge page memory parameters corresponding to other nodes, before allocating the huge page memory corresponding to other nodes according to the huge page memory parameters corresponding to other nodes, it is also necessary to prioritize the allocation of non-huge page memory of other nodes according to the non-huge page memory parameters corresponding to other nodes, and then determine the memory corresponding to other nodes other than the huge page memory as the memory to be allocated for other nodes.
[0039] As an example, as shown in the node memory allocation diagram of FIG2 , the server environment includes a first node 210, a second node 220, and a third node 230. During the system startup phase or the memory allocation phase, the huge page memory parameters and non-huge page memory parameters corresponding to the first node 210 may be received, the non-huge page memory of the first node 210 may be allocated based on the non-huge page memory parameters corresponding to the first node 210, and the huge page memory corresponding to the first node 210 may be allocated based on the huge page memory parameters corresponding to the first node 210. Similarly, during the system startup phase or the memory allocation phase, the huge page memory parameters and non-huge page memory parameters corresponding to the second node 220 may be received, the non-huge page memory of the second node 210 may be allocated based on the non-huge page memory parameters corresponding to the second node 220, and the huge page memory corresponding to the second node 220 may be allocated based on the huge page memory parameters corresponding to the second node 220. Similarly, during the system startup phase or the memory allocation phase, the huge page memory parameters and non-huge page memory parameters corresponding to the third node 230 can be received, and the non-huge page memory of the third node 230 can be allocated according to the non-huge page memory parameters corresponding to the third node 230, and the huge page memory corresponding to the third node 230 can be allocated according to the huge page memory parameters corresponding to the third node 230.
[0040] In this way, it can be ensured that the memory of multiple nodes in the NUMA architecture server environment are accurately allocated huge page memory according to the pre-configured huge page memory parameters, or non-huge page memory is allocated according to the pre-configured non-huge page memory parameters, ensuring that the operating system has available non-huge page memory, ensuring the normal operation of the operating system, and also ensuring that high-performance virtual machines or high-performance programs have available huge page memory.
[0041] In one implementation, the huge page memory allocated to the target node is less than or equal to the memory to be allocated.
[0042] Specifically, the huge page memory allocated to the target node should be less than or equal to the target node's unallocated memory. This ensures that the target node can provide huge page memory as much as possible without using the memory of other nodes, ensuring the normal operation of high-performance programs such as high-performance virtual machines, while ensuring that there is enough non-huge page memory to ensure the normal operation of the operating system.
[0043] In one implementation, receiving the huge page memory parameters corresponding to the target node includes: receiving the huge page memory parameters through a first interface; or receiving the non-huge page memory parameters corresponding to the target node includes: receiving the non-huge page memory parameters through a second interface.
[0044] Specifically, before allocating the memory of the target node, a first configuration item can be added in advance through the multi-operating system boot program (GRand Unified Bootloader, GRUB), and the first configuration item is used as the first interface. The first configuration item can be, for example, an input box for inputting huge page memory parameters. The user inputs the huge page memory parameters through the input box, and the electronic device can receive the huge page memory parameters input by the user through the first configuration item. That is, the first interface can be used to receive the huge page memory parameters input by the user. Optionally, the first interface can also be used only to receive huge page memory parameters, that is, not to receive non-huge page memory parameters.
[0045] Similarly, a second configuration item can be pre-configured through a multi-operating system startup program, and this second configuration item can be used as a second interface. This second configuration item can, for example, be an input box for inputting non-huge page memory parameters. The user inputs the non-huge page memory parameters through this input box, and the electronic device can receive the non-huge page memory parameters input by the user through the second configuration item. That is, the second interface can be used to receive the non-huge page memory parameters input by the user. Optionally, the second interface can also be used only to receive non-huge page memory parameters, that is, not to receive huge page memory parameters.
[0046] As an example, assume that the user enters a hugepage memory parameter of 6GB in the first configuration item and a non-hugepage memory parameter of 3GB in the second configuration item. The electronic device can receive the hugepage memory parameter through the first configuration item to determine that the target node needs to allocate 6GB of hugepage memory, and can receive the non-hugepage memory parameter through the second configuration item to determine that the target node needs to allocate 3GB of non-hugepage memory.
[0047] Therefore, the embodiment of the present application realizes that the huge page memory parameters and non-huge page memory parameters can be actively configured by the user, ensuring that the huge page memory or non-huge page memory of the target node can be allocated according to actual needs, ensuring the normal operation of high-performance programs such as the operating system and high-performance virtual machines, and avoiding the problem that when the server memory bar is damaged or individual memory is pulled out, the target node huge page memory allocation amount may be too much, resulting in insufficient non-huge page memory available to the system, causing the operating system to be unable to operate normally.
[0048] In one implementation, the huge page memory parameter is the value of the huge page memory or the percentage of the huge page memory in the memory to be allocated; or the non-huge page memory parameter is the value of the non-huge page memory or the percentage of the huge page memory in the memory of the target node.
[0049] Specifically, the huge page memory parameter can be a specific huge page memory value, for example, the huge page memory parameter can be 10GB. The huge page memory parameter can also be a percentage of the huge page memory in the to-be-allocated memory. For example, if the huge page memory parameter is 10%, when allocating huge pages in the to-be-allocated memory, 10% of the to-be-allocated memory can be allocated as huge pages.
[0050] In addition, the non-huge page memory parameter can be a specific non-huge page memory value, for example, the non-huge page memory parameter can be 5GB. The non-huge page memory parameter can also be the percentage of non-huge page memory in the target node's memory. For example, if the non-huge page memory parameter is 20%, 20% of the target node's memory can be allocated as non-huge page memory. In this way, the huge page memory parameter or non-huge page memory parameter can be expressed in a variety of forms. The huge page memory parameter or non-huge page memory parameter can also be a parameter in other forms. The form of the huge page memory parameter or non-huge page memory parameter is not specifically limited here.
[0051] FIG3 is a flow chart of another memory allocation method provided in an embodiment of the present application. As shown in FIG3 , the memory allocation method includes the following steps:
[0052] Step 302: Configure non-huge page memory parameters and / or huge page memory parameters corresponding to each node.
[0053] Specifically, before allocating memory to the target node, a first configuration item can be pre-configured using the GRand Unified Bootloader (GRUB), with the first configuration item serving as the first interface. The first configuration item can be an input box for inputting huge page memory parameters. Thus, the user can input huge page memory parameters in the first configuration item.
[0054] Specifically, a second configuration item can be pre-configured through a multi-operating system startup program, and the second configuration item can be used as the second interface. The first configuration item can be an input box for inputting non-huge page memory parameters. In this way, the user can input non-huge page memory parameters in the second configuration item.
[0055] Step 304: Receive non-huge page memory parameters and / or huge page memory parameters corresponding to each node.
[0056] The electronic device may receive huge page memory parameters corresponding to the target node through the first interface.
[0057] The electronic device may receive non-huge page memory parameters corresponding to the target node through the second interface.
[0058] Step 306: Whether non-huge page memory parameters are received.
[0059] Specifically, each node is traversed, and if the corresponding non-huge page memory parameter is received, step 308 is executed; if the corresponding non-huge page memory parameter is not received, step 310 is executed.
[0060] Step 308: Allocate non-huge page memory according to the non-huge page memory parameters.
[0061] Specifically, traverse each node, and if the corresponding non-huge page memory parameters are received, the memory corresponding to the non-huge page memory parameters in the memory of the target node can be allocated as non-huge page memory according to the non-huge page memory parameters, that is, the electronic device can parse the non-huge page memory parameters, determine the amount of non-huge page memory that needs to be allocated to the target node, and allocate the non-huge page memory of the target node according to the amount of non-huge page memory that needs to be allocated to the target node; execute step 310.
[0062] Step 310: Whether huge page memory parameters are received.
[0063] Specifically, each node is traversed, and if the corresponding huge page memory parameter is received, step 312 is executed; if the corresponding huge page memory parameter is not received, step 314 is executed.
[0064] Step 312: Allocate huge page memory according to huge page memory parameters.
[0065] Specifically, when traversing each node, if a huge page memory parameter corresponding to the target node is received, the memory corresponding to the huge page memory parameter in the target node's to-be-allocated memory can be allocated as huge page memory based on the huge page memory parameter. That is, the electronic device can determine the amount of huge page memory required to be allocated to the target node based on the huge page memory parameter, and allocate the target node's huge page memory in the target node's to-be-allocated memory based on the amount of huge page memory required to be allocated to the target node. In addition, if the node's to-be-allocated memory is less than or equal to the huge page memory parameter, after allocating the to-be-allocated memory as huge page memory, the allocation of the target node's huge page memory can be terminated, ensuring that the target node's allocated huge page memory is less than or equal to the to-be-allocated memory, thereby avoiding the additional use of memory from other nodes for the target node's huge page memory allocation; and executing step 316.
[0066] Step 314: Allocate huge page memory according to the default policy.
[0067] Specifically, when no huge page memory parameter is received, huge page memory is allocated in the to-be-allocated memory corresponding to each node according to the system default policy; and step 316 is executed.
[0068] Step 316: End memory allocation.
[0069] End up allocating memory for each node.
[0070] Through the memory allocation method provided in the embodiment of the present application, the memory of the target node can be accurately allocated for each node according to the pre-configured huge page memory parameters or non-huge page memory parameters, ensuring that the operating system has available memory, optimizing the memory allocation method, and optimizing the ratio of huge page memory to ordinary memory on the target node. This avoids the problem that when the server memory bar is damaged or individual memory is pulled out, the target node may allocate too many huge page memories, resulting in insufficient non-huge page memory available to the system, causing the operating system to fail to operate normally, thereby ensuring the normal operation of the operating system.
[0071] It should be noted that the memory allocation method provided in the embodiments of the present application can be executed by a memory allocation device or a control module in the memory allocation device for executing the memory allocation method. In the embodiments of the present application, the memory allocation device provided in the embodiments of the present application is described by taking the memory allocation device executing the memory allocation method as an example.
[0072] FIG4 is a schematic diagram of the structure of a memory allocation apparatus according to an embodiment of the present application. As shown in FIG4 , the memory allocation apparatus 400 includes: a receiving module 410 and an allocating module 420 .
[0073] The receiving module 410 is configured to receive huge page memory parameters corresponding to a target node; and the allocating module 420 is configured to allocate huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters.
[0074] In one implementation, the receiving module 410 is further used to receive non-huge page memory parameters corresponding to the target node; determine non-huge page memory based on the non-huge page memory parameters; and determine the memory of the target node other than the non-huge page memory as the memory to be allocated.
[0075] In one implementation, the allocation module 420 is configured to allocate the target node's to-be-allocated memory as the huge page memory if the target node's to-be-allocated memory is less than or equal to the memory corresponding to the huge page memory parameter.
[0076] In one implementation, the allocation module 420 is configured to end allocation of the huge page memory of the target node.
[0077] In one implementation, the allocation module 420 receives huge page memory parameters corresponding to other nodes except the target node; traverses the other nodes, and allocates the huge page memory corresponding to the other nodes in the to-be-allocated memory corresponding to the other nodes according to the huge page memory parameters corresponding to the other nodes.
[0078] In one implementation, the huge page memory allocated to the target node is less than or equal to the memory to be allocated.
[0079] In one implementation, the receiving module 410 is configured to receive the huge page memory parameters through a first interface; or receive the non-huge page memory parameters through a second interface.
[0080] In one implementation, the huge page memory parameter is the value of the huge page memory or the percentage of the huge page memory in the memory to be allocated; or the non-huge page memory parameter is the value of the non-huge page memory or the percentage of the huge page memory in the memory of the target node.
[0081] In one implementation, the huge page memory parameters and the non-huge page memory parameters are carried in the same configuration information.
[0082] The memory allocation device in the embodiments of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc., and the embodiments of the present application do not specifically limit this.
[0083] The memory allocation device in the embodiment of the present application can be a device having an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0084] The memory allocation device provided in the embodiment of the present application can implement each process implemented in the method embodiments of Figures 1 to 3. To avoid repetition, they will not be described here.
[0085] Optionally, as shown in Figure 5, an embodiment of the present application further provides an electronic device 500, including a processor 501 and a memory 502, wherein the memory 502 stores a program or instruction that can be run on the processor 501, and when the program or instruction is executed by the processor 501, it implements: receiving huge page memory parameters corresponding to the target node; allocating huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters.
[0086] In one implementation, before allocating huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters, non-huge page memory parameters corresponding to the target node are received; non-huge page memory is determined according to the non-huge page memory parameters; and memory in the memory of the target node other than the non-huge page memory is determined as the to-be-allocated memory.
[0087] In one implementation, when the memory to be allocated of the target node is less than or equal to the memory corresponding to the huge page memory parameter, the memory to be allocated of the target node is allocated as the huge page memory.
[0088] In one implementation, after allocating the to-be-allocated memory as the huge page memory, allocating the huge page memory of the target node is finished.
[0089] In one implementation, after completing the allocation of the huge page memory of the target node, it also includes: receiving huge page memory parameters corresponding to other nodes except the target node; traversing the other nodes, and allocating the huge page memory corresponding to the other nodes in the to-be-allocated memory corresponding to the other nodes according to the huge page memory parameters corresponding to the other nodes.
[0090] In one implementation, the huge page memory allocated to the target node is less than or equal to the memory to be allocated.
[0091] In one implementation, the huge page memory parameter is received through a first interface; or the non-huge page memory parameter is received through a second interface.
[0092] In one implementation, the huge page memory parameter is the value of the huge page memory or the percentage of the huge page memory in the memory to be allocated; or the non-huge page memory parameter is the value of the non-huge page memory or the percentage of the huge page memory in the memory of the target node.
[0093] In one implementation, the huge page memory parameters and the non-huge page memory parameters are carried in the same configuration information.
[0094] The specific execution steps can refer to the various steps of the above-mentioned memory allocation method embodiment, and can achieve the same technical effect. To avoid repetition, they will not be repeated here.
[0095] It should be noted that the electronic devices in the embodiments of the present application include: servers, terminals, or other devices other than terminals.
[0096] The above electronic device structure does not constitute a limitation of the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, the input unit may include a graphics processing unit (GPU) and a microphone, and the display unit may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. to configure the display panel. The user input unit includes a touch panel and at least one of other input devices. The touch panel is also called a touch screen. Other input devices may include but are not limited to a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0097] The memory can be used to store software programs and various data. The memory may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory may include a volatile memory or a non-volatile memory, or the memory may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. Volatile memory can be random access memory (RAM), 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 DRAM (SLDRAM) and direct rambus random access memory (DRRAM).
[0098] The processor may include one or more processing units; optionally, the processor may integrate an application processor and a modem processor, wherein the application processor primarily handles operations related to the operating system, user interface, and application programs, and the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into the processor.
[0099] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned memory allocation method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0100] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer-readable storage medium, such as ROM, RAM, magnetic disk or optical disk.
[0101] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0102] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0103] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.
Claims
1. A method for memory allocation, comprising: Receive the huge page memory parameters corresponding to the target node; Allocate huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameters.
2. The method according to claim 1, wherein: Before allocating the huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameter, the method further includes: Receive non-huge page memory parameters corresponding to the target node; Determining non-huge page memory according to the non-huge page memory parameter; The memory of the target node other than the non-huge page memory is determined as the memory to be allocated.
3. The method according to claim 1, wherein: Allocating huge page memory in the to-be-allocated memory of the target node according to the huge page memory parameter includes: When the memory to be allocated of the target node is less than or equal to the memory corresponding to the huge page memory parameter, the memory to be allocated of the target node is allocated as the huge page memory.
4. The method according to claim 3, wherein: After allocating the memory to be allocated as the huge page memory, the method further includes: Finish allocating hugepage memory for the target node.
5. The method according to claim 4, wherein: After allocating the huge page memory of the target node, the method further includes: Receive huge page memory parameters corresponding to other nodes except the target node; The other nodes are traversed, and according to the huge page memory parameters corresponding to the other nodes, the huge page memory corresponding to the other nodes is allocated in the to-be-allocated memory corresponding to the other nodes.
6. The method according to claim 2, wherein: The huge page memory allocated to the target node is less than or equal to the memory to be allocated.
7. The method according to claim 2, wherein: The huge page memory parameters corresponding to the receiving target node include: Receiving the huge page memory parameter via a first interface; or The non-huge page memory parameters corresponding to the receiving target node include: The non-huge page memory parameters are received via a second interface.
8. The method according to claim 2, wherein: The huge page memory parameter is a value of the huge page memory or a percentage of the huge page memory to be allocated memory; or The non-huge page memory parameter is a value of the non-huge page memory or a percentage of the huge page memory in the memory of the target node.
9. An electronic device comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the memory allocation method as described in any one of claims 1 to 8.
10. A readable storage medium storing a program or instruction, wherein the program or instruction, when executed by a processor, implements the steps of the memory allocation method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Service data processing method and device for cloud edge fusion system
CN111737016A
Network card testing method and device, computer equipment and computer readable storage medium
CN113849277A
Non-Uniform Memory Access (NUMA) Database Management System
US20170031718A1
Cited By
Method for accessing memory and on-chip bus interconnection system
CN121478722A
