Heterogeneous dual-system memory allocation method, terminal and storage medium

By obtaining the actual size of the heterogeneous dual system memory and dynamically adjusting the memory partition, the problem of poor applicability of the memory allocation scheme in the existing technology is solved, the stability and performance of the system operation are improved, the functional requirements are met, and the memory utilization is improved. .

CN118642858APending Publication Date: 2024-09-13SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411001751.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-09-13

AI Technical Summary

Technical Problem

The existing memory allocation scheme of heterogeneous dual systems has poor applicability and cannot dynamically change memory partitions, which affects the smoothness and performance of system operation.

Method used

By obtaining the actual size of the memory, generate partition information based on pre-set dual system memory partition rules, and write it into the electrically erasable programmable read-only memory to realize the reallocation of memory when the system starts and dynamically adjust the memory partition to adapt to the memory Size changes.

Benefits of technology

It improves system operation stability and performance, meets the memory usage requirements of various functions, prevents partitions from affecting each other, and improves memory utilization through dynamic memory partitioning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118642858A
    Figure CN118642858A
Patent Text Reader

Abstract

The invention relates to the technical field of servers, and particularly provides a heterogeneous dual-system memory allocation method, a terminal and a storage medium, and the method comprises the following steps: obtaining the actual size of a memory; generating partition information based on a preset dual-system memory partition rule and the actual size of the memory; and writing the partition information into a live-line erasable programmable read-only memory, and completing system loading and starting based on the partition information in the live-line erasable programmable read-only memory. According to the method, the system operation stability is improved, and the formulated partition rule based on the proportion not only meets the requirements of each function on memory use, but also ensures the independence of partition used by each function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of servers, and in particular relates to a memory allocation method, a terminal and a storage medium for a heterogeneous dual system. Background Art

[0002] BMC processor chip designs are becoming increasingly complex. Heterogeneous dual-system systems (HBMSs) refer to BMC chips containing two cores, each running a different operating system. Both systems require memory, and how memory is allocated between them affects BMC system performance, stability, and memory utilization.

[0003] Memory allocation solutions for heterogeneous dual systems typically pre-define memory partitions and embed them in the code. However, code modifications are required when memory specifications change. Consequently, current memory allocation solutions are less adaptable and cannot dynamically change the memory partitions of each system during operation. This makes them unable to adapt to the dynamic needs of both systems, impacting system operation smoothness. Summary of the Invention

[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a memory allocation method, terminal and storage medium for a heterogeneous dual system to solve the above-mentioned technical problems.

[0005] In a first aspect, the present invention provides a memory allocation method for a heterogeneous dual system, comprising: Get the actual size of the memory; Generate partition information based on a preset dual-system memory partition rule and the actual size of the memory; The partition information is written into an electrically erasable programmable read-only memory, and system loading and startup are completed based on the partition information in the electrically erasable programmable read-only memory.

[0006] In an optional embodiment, the method further comprises: Powering on and waking up the first kernel, the first kernel running a diskless boot interface, the diskless boot interface loading and booting an initialization process; The initialization process performs memory initialization and triggers memory reallocation.

[0007] By triggering memory reallocation during the system startup phase, the memory allocation plan can be updated in a timely manner. When the memory is changed, the memory size changes. The chip automatically calculates the new memory size during the restart process and partitions the memory based on the memory size.

[0008] In an optional implementation, obtaining the actual size of the memory includes: Set up and cache test data; Save various memory specifications supported by heterogeneous dual system chips to the specification list, including 521MB, 1GB, 2GB, and 4GB; Select the maximum memory size from the list of specifications as the assumed value for the memory size; Perform a write operation to write the test data to a target address in the memory, where the target address is the assumed value + 1KB of space; Perform a read operation to read data from the target address in memory; Compare the read data with the test data using a loop statement to see if they are consistent, and if they are consistent, determine that the assumed value is the actual value in the memory; If the read data is inconsistent with the test data, the assumed value is halved, and the read and write test is re-executed based on the updated assumed value, and the iteration is repeated until the actual value of the memory is obtained; Check whether the actual value is in the specification list. If the actual value is in the specification list, output the actual value as the actual size of the memory. If the actual value is not in the specification list, filter out the memory specification that is closest to the actual value and larger than the actual value as the actual size of the memory.

[0009] Based on the principle of memory overflow, the actual memory size is quickly calculated. If the assumed value does not exceed the actual memory size, the write operation succeeds, and the read data is consistent with the test data. If the assumed value exceeds the actual memory size, the write operation fails, and the read data is inconsistent with the test data. A two-fold iteration method is used to quickly match the assumed value to the actual memory size. Furthermore, by matching the chip's supported memory specifications, the actual memory size is accurately obtained.

[0010] In an optional embodiment, setting the test data includes: 0x12345678 is set as test data, and the test data is written into the non-volatile memory.

[0011] In an optional embodiment, the dual-system memory partitioning rules include: Multiple memory areas, including a first system partition, a second system partition, a dynamic memory partition, and multiple necessary program partitions. The dual system includes a first system and a second system, the first system runs in the first core of the BMC, and the second system runs in the second core of the BMC. The multiple necessary program partitions include an inter-core communication partition, a communication partition between the BMC and the host node, a partition used by the display component, and a partition used by the memory detection program. The percentage configured for each region.

[0012] By setting up dynamic memory partitions, you can ensure dynamic memory allocation for subsequent systems and ensure smooth business operations. By customizing memory partitions and setting the proportion of each partition, you can ensure balanced memory distribution, avoid memory bottlenecks, and improve overall operational performance.

[0013] In an optional embodiment, generating partition information based on a preset dual-system memory partition rule and the actual size of the memory includes: The product of the proportion of each area and the actual size is used as the partition size of each area; Generate a starting address for each region based on the partition size of each region; Store the starting address and partition size of each region as a structure.

[0014] In an optional embodiment, writing the partition information into an electrically erasable programmable read-only memory, and completing system loading and startup based on the partition information in the electrically erasable programmable read-only memory, includes: Writing the structure carrying the partition information into the electrically erasable programmable read-only memory; Perform memory initialization through the initialization process; Confirming that the first core has been awakened, waking up the second core through an initialization process, loading the first system image file from the flash memory into the first system partition in the memory, and booting the first system to run, wherein the first system reads its own partition first address and partition size from the partition information of the electrically erasable programmable read-only memory; The boot loader is started through an initialization process, and the boot loader guides the second system to start. The second system reads its own related partition first address and partition size from the partition information of the electrically erasable programmable read-only memory.

[0015] The boot system reads partition information from the electrically erasable programmable read-only memory to obtain the corresponding memory partition, thereby ensuring the stability of the memory allocation process and avoiding memory allocation failure caused by partition information loss or damage.

[0016] In an optional embodiment, the method further comprises: monitoring the used memory of the first system and the used memory of the second system; Calculating the difference between the size of the first system partition and the used memory of the first system to obtain the available memory of the first system; Calculate the difference between the size of the second system partition and the used memory of the second system to obtain the available memory of the second system; If the available memory of the first system is lower than a preset memory threshold, applying for memory from the dynamic memory partition for the newly created program of the first system using a memory allocation function; If the available memory of the second system is lower than a preset memory threshold, a memory allocation function is used to apply for memory from the dynamic memory partition for the newly created program of the second system.

[0017] By monitoring the memory usage of the dual systems, when the business volume of one system is large, memory is requested from the dynamic memory partition for its new program. Since the memory threshold is set, the system's own memory partition has a certain margin, which ensures the memory usage of existing programs, and the data of the new program is cached in the newly requested memory, ensuring the uniformity of the data path and improving the stability of program operation.

[0018] In a second aspect, the present invention provides a memory allocation system for a heterogeneous dual system, comprising: Size acquisition module, used to obtain the actual size of the memory; An information generating module, configured to generate partition information based on a preset dual-system memory partition rule and the actual size of the memory; The information storage module is used to write the partition information into the electrically erasable programmable read-only memory, and complete system loading and startup based on the partition information in the electrically erasable programmable read-only memory.

[0019] According to a third aspect, a terminal is provided, including: processor, memory, wherein The memory is used to store computer programs, The processor is used to call and run the computer program from the memory, so that the terminal executes the above-mentioned terminal method.

[0020] In a fourth aspect, a computer storage medium is provided, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the methods described in the above aspects.

[0021] The beneficial effects of the present invention are that the memory allocation method, terminal, and storage medium for heterogeneous dual systems provided by the present invention trigger the recalculation and allocation of memory size during the startup phase. When the memory size changes, the memory allocation plan is promptly changed, thereby improving the stability of system operation. The formulated partitioning rules based on proportions not only meet the memory usage requirements of various functions, but also ensure the independence of the partitions used by each function to prevent mutual interference. At the same time, a dynamic memory partition is added, and for temporarily used memory, dynamic application and release are adopted to improve memory utilization.

[0022] In addition, the present invention has a reliable design principle, a simple structure and a very broad application prospect. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0024] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention.

[0025] Figure 2 It is a schematic diagram of the hardware topology structure of an embodiment of the present invention.

[0026] Figure 3 It is a schematic flow chart of the startup process of the method according to one embodiment of the present invention.

[0027] Figure 4 The figure is a schematic flow chart of a method for calculating memory size according to an embodiment of the present invention.

[0028] Figure 5 FIG. 4 is a schematic diagram of DDR space partitioning of a method according to an embodiment of the present invention.

[0029] Figure 6 FIG. 4 is a schematic block diagram of a system according to an embodiment of the present invention.

[0030] Figure 7 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0033] The key terms appearing in the present invention are explained below.

[0034] BMC: Baseboard management controller, is a server platform management and control chip that can monitor the server's health status, remotely power on and off, collect temperature (voltage) data, and perform fault diagnosis.

[0035] BIOS: basic input and output system, is a set of programs fixed on a ROM chip on the computer's motherboard. It stores the computer's most important basic input and output programs, self-test programs after power-on, and system startup programs. It can read and write specific information of system settings from CMOS.

[0036] CPU: central processing unit.

[0037] RTOS: Designed specifically for embedded system design and real-time application development, it aims to provide reliable and efficient solutions, especially suitable for those occasions with high real-time requirements.

[0038] DDR: It is a memory name, which means double data rate synchronous dynamic random access memory, and is one type of memory.

[0039] The memory allocation method for the heterogeneous dual system provided by the embodiment of the present invention is executed by a computer device. Accordingly, the memory allocation system for the heterogeneous dual system runs in the computer device.

[0040] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention. Figure 1 The execution subject can be a memory allocation system of a heterogeneous dual system. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.

[0041] like Figure 1 As shown, the method includes: Step 110, obtaining the actual size of the memory; Step 120: Generate partition information based on the preset dual-system memory partition rules and the actual size of the memory; Step 130 : writing the partition information into the electrically erasable programmable read-only memory, and completing system loading and startup based on the partition information in the electrically erasable programmable read-only memory.

[0042] After replacing the memory, the actual memory size can be entered. After restarting, the entered actual memory size is read. Based on the specified memory partitions and their proportions, such as two system partitions or other partitions, the corresponding partitions are created in memory using the memory partition creation function. Information about the user object is stored in the first memory block of each partition. The user object, starting address, and partition size of each partition are written to the electrically erasable programmable read-only memory (EEPM). Memory initialization is then performed to validate the memory allocation.

[0043] To facilitate understanding of the present invention, the memory allocation method for heterogeneous dual systems provided by the present invention is further described below based on the principle of the memory allocation method for heterogeneous dual systems of the present invention and the process of allocating memory for the heterogeneous dual systems in the embodiment.

[0044] Please refer to Figure 2 Taking DDR memory as an example, the hardware topology consists of two cores, CPU0 and CPU1. CPU0 runs the Linux system, while CPU1 runs the RTOS system. The Linux system primarily handles most routine BMC tasks, while the RTOS system handles critical tasks that require high practicality or require processing when the Linux system fails, such as fan control. Communication between the Linux and RTOS systems uses an inter-core intermediate memory plus shared memory. Big data communication between the BMC system and the host node also primarily uses shared memory, primarily through the H2B and VGA modules.

[0045] For details, please refer to Figure 3 ,The startup process of heterogeneous dual systems includes: S1. Power on and wake up a first core, wherein the first core runs a diskless boot interface, and the diskless boot interface loads and boots an initialization process.

[0046] After power-on, the first core CPU0 will be awakened and the diskless boot interface BootRom will be run. The diskless boot interface BootRom will load the boot initialization process SPL to start.

[0047] S2. The initialization process performs memory initialization, triggering memory reallocation.

[0048] When the SPL initialization process starts, it initializes some hardware modules, such as the DDR. During DDR initialization, memory is reallocated. This reallocation involves obtaining the actual DDR size, partitioning the DDR based on the actual DDR size and predefined partitioning rules, and writing the partition information to the electrically erasable programmable read-only memory (EEPROM).

[0049] S3. Continue to perform hardware initialization based on the partition information in the memory and complete the startup.

[0050] The initialization process (SPL) wakes up the second core, CPU1, loads the RTOS system image from the flash memory into the corresponding memory partition, and boots the RTOS system. Once the RTOS system is running, it reads the DDR partition information from the EEPROM to obtain the available partition starting addresses and sizes, such as the memory partition information used for inter-core communication. Simultaneously, the SPL initialization process also loads the uboot (boot loader). After uboot starts, it boots the Linux system. After the Linux system boots, it reads the DDR partition information from the EEPROM to obtain the available partition starting addresses and sizes.

[0051] The initialization process SPL sets the timing, ECC, etc. based on the partition information.

[0052] In one embodiment, still taking DDR as an example, the memory allocation method specifically includes the following steps: S1. Get the actual size of the memory.

[0053] The DDR size in this embodiment is not hard-coded in the code, but is dynamically calculated. The calculation process is shown in the attached figure. Figure 4 Supporting DDR dynamic calculation requires that read / write overflows occur and then cyclically read / write occurs. For example, if the actual DDR size is 512MB and the read / write address offset is 4GB+1KB, this address clearly exceeds the actual DDR size, causing a read / write overflow. The actual read / write address is the address with a 1KB DDR offset. This invention is applicable to DDR sizes that increase by a factor of 2. For example, the supported DDR sizes are: 521MB, 1GB, 2GB, and 4GB.

[0054] The specific process is as follows: (1) Set and cache test data, the test data is 0x12345678; (2) Save the various memory specifications supported by the heterogeneous dual system chip to the specification list, including 521MB, 1GB, 2GB, and 4GB; (3) Select the maximum memory specification from the specification list as the assumed value of the memory size; that is, set ddr_size=4GB; (4) Execute a write operation to write the test data to the target address of the memory, where the target address is the space of the assumed value + 1KB; that is, the target address is ddr_size + 1KB; (5) Perform a read operation and read data from the target address ddr_siz+1KB of the memory; (6) Use a loop statement to compare the read data with the test data to see if they are consistent. If they are consistent, it means that 4GB does not exceed the actual size of the memory and the read and write operations are normal. Then, it is determined that the assumed value is the actual value of the memory; (7) If the read data is inconsistent with the test data, the assumed value is halved and updated to 2GB, that is, ddr_size = 2GB, and step (4) is continued; (8) Check whether the actual value is in the specification list. If the actual value is in the specification list, output the actual value as the actual size of the memory. If the actual value is not in the specification list, filter out the memory specification that is closest to the actual value and larger than the actual value as the actual size of the memory.

[0055] S2. Generate partition information based on a preset dual-system memory partition rule and the actual size of the memory.

[0056] The dual-system memory partitioning rules include: multiple memory areas, including the first system partition (Linux system partition), the second system partition (RTOS partition), the dynamic memory partition (Malloc partition), and multiple necessary program partitions. The dual system includes the first system and the second system, the first system runs in the first core of the BMC, and the second system runs in the second core of the BMC; the multiple necessary program partitions include the inter-core communication partition, the communication partition between the BMC and the host node (H2B partition), the partition used by the display component (VGA partition), and the partition used by the memory detection program (ECC partition); and the proportion configured for each area.

[0057] As attached Figure 5 As shown, the functions of each partition are as follows: System partition: memory used when uboot and Linux system are running; RTOS partition: memory used when the RTOS system is running; Inter-core communication partition: shared memory used by the Linux system and RTOS system for inter-core communication; H2B partition: memory used for communication between BMC and HOST through H2B; VGA partition: Memory used by the host VGA, which is also used by the BMC KVM display; Malloc partition: an area where memory is dynamically allocated and released. For example, Linux and RTOS systems can dynamically allocate and release memory in this area. ECC partition: Memory used by the DDR ECC function. The size of the ECC partition is generally 1 / 8 of the total memory size.

[0058] The product of the proportion of each area and the actual size is used as the partition size of each area; a starting address is generated for each area in sequence based on the partition size of each area; and the starting address and partition size of each area are stored as a structure.

[0059] Specifically, the partitioning method includes the following steps: (1) Calculation of proportion and partition size: First, based on the system's overall memory resources and the preset allocations (e.g., percentages or fixed ratios) for each memory region, the partition size for each region is calculated by multiplying the region's allocation by the overall memory size. This process ensures that resources are allocated according to pre-defined priorities and needs.

[0060] For example, if the total memory is 4 GB and the first system partition is configured to occupy 30% of the total memory, its partition size will be calculated as 1.2 GB.

[0061] (2) Starting address generation: After determining the partition size of each region, you need to assign them a starting address in memory. The starting address allocation usually starts from the base address of the memory and proceeds in the order in which the regions are divided.

[0062] The generation of the starting address follows the principle of "fixed first, dynamic later", that is, first allocate addresses to areas with high fixed size and location requirements (such as system partitions and necessary program partitions), and then reserve space for dynamic memory partitions.

[0063] For example, if the first system partition is located at the beginning of the memory, then its starting address is the base address of the memory, followed by the second system partition, then the necessary program partitions (such as inter-core communication partition, communication partition, etc.), and finally the space reserved for dynamic memory allocation.

[0064] Methods for creating memory partitions include: Define the Partition_Create() function, int Partition_Create(size_t size, void *partition_ptr); Among them, size is the total size of the requested memory partition (including the partition object itself and subsequent memory blocks), and partition_ptr is an output parameter used to return the address of the newly created partition object (that is, the starting position of the partition object in memory).

[0065] Memory allocation: First, sufficient space is allocated from the system's heap memory (or a designated memory management area) based on the requested size plus the space required for the partition object itself (for example, the size of the structure containing information such as the partition size, status, and linked list nodes). If the allocation fails, an error code (such as -1 or other error indicator) is returned.

[0066] Partition object initialization: In the first part of the allocated memory block (that is, the partition object itself), initialize the various fields of the partition object, such as the partition size, the current amount of used memory, and the status (such as whether it is valid, whether it is sorted, etc.).

[0067] Return the new partition: Set the address of the new partition object (that is, the address pointed to by partition_ptr) to the starting address of the newly allocated memory block (that is, the part after the partition object, used to store the actual memory block). Return a success code (such as 0 or other success indicator).

[0068] (3) Structure storage: For easy management and access, the starting address and partition size of each memory region are stored in a structure. These structures contain all the key information about the memory region, such as region type, starting address, partition size, etc.

[0069] The analysis information structure is as follows: typedef struct { uint32_t SystemPartAddr; / / Start address of system partition; uint32_t SystemPartSize; / / Size of the system partition; uint32_t RTOSPartAddr; / / Start address of RTOS partition; uint32_t RTOSPartSize; / / The size of the RTOS partition; uint32_t IPIPartAdd; / / Starting address of inter-core communication partition; uint32_t IPIPartSize; / / Size of the inter-core communication partition; uint32_t H2BPartAddr; / / Start address of H2B partition; uint32_t H2BPartSize; / / Size of H2B partition; uint32_t VGAPartAddr; / / Start address of VGA partition; uint32_t VGAPartSize; / / VGA partition size; uint32_t MallocPartAddr; / / Starting address of Malloc partition; uint32_t MallocPartSize; / / Size of Malloc partition; uint32_t ECCPartAddr; Starting address of ECC partition; uint32_t ECCPartSize; / / The size of the ECC partition; }MallocMemInfo_T.

[0070] S3. Writing the partition information into an electrically erasable programmable read-only memory, and completing system loading and startup based on the partition information in the electrically erasable programmable read-only memory.

[0071] The structure carrying the partition information is written into the electrically erasable programmable read-only memory.

[0072] In one embodiment of the present invention, dynamic memory allocation is performed on dual systems, and the specific method includes: (1) Monitor the used memory of the first system and the used memory of the second system.

[0073] Use system-provided APIs or command-line tools (such as Linux's free and vmstat, or Windows' tasklist / FI "MEMUSAGE ge 1", typeperf "\Memory\Available MBytes") to obtain real-time memory usage. Parse the output of these tools to obtain the amount of used memory for each system (which may refer to different operating system instances, virtual machines, or containers). Consider setting a monitoring frequency, such as every 5 minutes, or dynamically adjust it based on system load to account for performance impacts.

[0074] (2) Calculate the difference between the size of the first system partition and the used memory of the first system to obtain the available memory of the first system.

[0075] (3) Calculate the difference between the size of the second system partition and the used memory of the second system to obtain the available memory of the second system.

[0076] (4) If the available memory of the first system is lower than the preset memory threshold, the memory allocation function Malloc is used to apply for memory from the dynamic memory partition for the new program of the first system; A memory threshold is preset based on system requirements, stability, and performance considerations.

[0077] When it is detected that the available memory of the first system is lower than the threshold, the memory allocation logic is triggered.

[0078] Use malloc to allocate additional memory from the system's dynamic memory partition.

[0079] Pay attention to handling the case where malloc returns NULL, which indicates that the memory allocation failed and you may need to take additional error handling measures, such as freeing unnecessary memory, rejecting the request to create a new program, or increasing the system's physical memory.

[0080] (5) If the available memory of the second system is lower than the preset memory threshold, the memory allocation function Malloc is used to apply for memory from the dynamic memory partition for the new program of the second system.

[0081] The specific method is similar to step (4).

[0082] The present invention includes a module for dynamically allocating and releasing memory between the two systems, managing the Malloc partition. When a Linux or RTOS system needs to temporarily use memory, it can call this module to dynamically allocate a block of memory from the Malloc partition. Once memory is used, it can then be dynamically allocated again. This improves memory utilization.

[0083] In some embodiments, the memory allocation system of the heterogeneous dual system may include multiple functional modules composed of computer program segments. The computer program of each program segment in the memory allocation system of the heterogeneous dual system may be stored in a memory of a computer device and executed by at least one processor to perform (see Figure 1 Description) Memory allocation function for heterogeneous dual systems.

[0084] In this embodiment, the memory allocation system of the heterogeneous dual system can be divided into multiple functional modules according to the functions it performs, such as Figure 6 As shown. The functional modules of system 600 may include: a size acquisition module 610, an information generation module 620, and an information storage module 630. A module as referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, and is stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0085] Size acquisition module, used to obtain the actual size of the memory; An information generating module, configured to generate partition information based on a preset dual-system memory partition rule and the actual size of the memory; The information storage module is used to write the partition information into the electrically erasable programmable read-only memory, and complete system loading and startup based on the partition information in the electrically erasable programmable read-only memory.

[0086] Optionally, as an embodiment of the present invention, the method further includes: Powering on and waking up the first kernel, the first kernel running a diskless boot interface, the diskless boot interface loading and booting an initialization process; The initialization process performs memory initialization and triggers memory reallocation.

[0087] Optionally, as an embodiment of the present invention, obtaining the actual size of the memory includes: Set up and cache test data; Save various memory specifications supported by heterogeneous dual system chips to the specification list, including 521MB, 1GB, 2GB, and 4GB; Select the maximum memory size from the list of specifications as the assumed value for the memory size; Perform a write operation to write the test data to a target address in the memory, where the target address is the assumed value + 1KB of space; Perform a read operation to read data from the target address in memory; Compare the read data with the test data using a loop statement to see if they are consistent, and if they are consistent, determine that the assumed value is the actual value in the memory; If the read data is inconsistent with the test data, the assumed value is halved, and the read and write test is re-executed based on the updated assumed value, and the iteration is repeated until the actual value of the memory is obtained; Check whether the actual value is in the specification list. If the actual value is in the specification list, output the actual value as the actual size of the memory. If the actual value is not in the specification list, filter out the memory specification that is closest to the actual value and larger than the actual value as the actual size of the memory.

[0088] Optionally, as an embodiment of the present invention, setting the test data includes: Set 0x12345678 as test data and write the test data into the non-volatile memory Optionally, as an embodiment of the present invention, the dual-system memory partitioning rules include: Multiple memory areas, including a first system partition, a second system partition, a dynamic memory partition, and multiple necessary program partitions. The dual system includes a first system and a second system, the first system runs in the first core of the BMC, and the second system runs in the second core of the BMC. The multiple necessary program partitions include an inter-core communication partition, a communication partition between the BMC and the host node, a partition used by the display component, and a partition used by the memory detection program. The percentage configured for each region.

[0089] Optionally, as an embodiment of the present invention, generating partition information based on a preset dual-system memory partition rule and the actual size of the memory includes: The product of the proportion of each area and the actual size is used as the partition size of each area; Generate a starting address for each region based on the partition size of each region; Store the starting address and partition size of each region as a structure.

[0090] Optionally, as an embodiment of the present invention, writing the partition information into an electrically erasable programmable read-only memory, and completing system loading and startup based on the partition information in the electrically erasable programmable read-only memory, includes: Writing the structure carrying the partition information into the electrically erasable programmable read-only memory; Perform memory initialization through the initialization process; Confirming that the first core has been awakened, waking up the second core through an initialization process, loading the first system image file from the flash memory into the first system partition in the memory, and booting the first system to run, wherein the first system reads its own partition first address and partition size from the partition information of the electrically erasable programmable read-only memory; The boot loader is started through an initialization process, and the boot loader guides the second system to start. The second system reads its own related partition first address and partition size from the partition information of the electrically erasable programmable read-only memory.

[0091] Optionally, as an embodiment of the present invention, the method further includes: monitoring the used memory of the first system and the used memory of the second system; Calculating the difference between the size of the first system partition and the used memory of the first system to obtain the available memory of the first system; Calculate the difference between the size of the second system partition and the used memory of the second system to obtain the available memory of the second system; If the available memory of the first system is lower than a preset memory threshold, applying for memory from the dynamic memory partition for the newly created program of the first system using a memory allocation function; If the available memory of the second system is lower than a preset memory threshold, a memory allocation function is used to apply for memory from the dynamic memory partition for the newly created program of the second system.

[0092] Figure 7 This is a structural diagram of a terminal 700 provided in an embodiment of the present invention. The terminal 700 can be used to execute the memory allocation method for heterogeneous dual systems provided in an embodiment of the present invention.

[0093] The terminal 700 may include a processor 710, a memory 720, and a communication unit 730. These components communicate via one or more buses. Those skilled in the art will appreciate that the server structure shown in the figure does not limit the present invention. The server structure may be a bus structure or a star structure, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.

[0094] The memory 720 can be used to store execution instructions of the processor 710. The memory 720 can be implemented by any type of volatile or non-volatile storage terminal, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 720 are executed by the processor 710, the terminal 700 can perform some or all of the steps in the following method embodiments.

[0095] The processor 710 is the control center of the storage terminal. It uses various interfaces and lines to connect various parts of the entire electronic terminal. It executes various functions of the electronic terminal and / or processes data by running or executing software programs and / or modules stored in the memory 720, and calling data stored in the memory. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 710 can only include a central processing unit (CPU). In the embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.

[0096] The communication unit 730 is configured to establish a communication channel so that the storage terminal can communicate with other terminals, receive user data sent by other terminals, or send user data to other terminals.

[0097] The present invention also provides a computer storage medium, wherein the computer storage medium may store a program that, when executed, may include some or all of the steps of each embodiment provided herein. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0098] Therefore, the present invention triggers the recalculation and allocation of memory size during the startup phase. When the memory size changes, the memory allocation scheme is promptly modified, thereby improving the stability of system operation. The partitioning rules formulated based on the proportion not only meet the memory usage requirements of each function, but also ensure the independence of the partitions used by each function to prevent mutual interference. At the same time, a dynamic memory partition is added. For temporary memory use, dynamic application and release are adopted to improve memory utilization. The technical effects that can be achieved by this embodiment can be found in the description above and will not be repeated here.

[0099] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus a necessary general-purpose hardware platform. Based on this understanding, the technical solutions in the embodiments of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, among other media capable of storing program code, and includes instructions for causing a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention.

[0100] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the terminal embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.

[0101] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or modules, and can be electrical, mechanical or other forms.

[0102] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules may be selected to achieve the purpose of the present embodiment according to actual needs.

[0103] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0104] Although the present invention has been described in detail with reference to the accompanying drawings and in conjunction with preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, persons of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and such modifications or substitutions shall be within the scope of the present invention. Any changes or substitutions that can be easily conceived by persons skilled in the art within the technical scope disclosed in the present invention shall be within the scope of protection of the present invention.

Claims

1. A memory allocation method for heterogeneous dual systems, characterized in that: include: Get the actual size of the memory; Generate partition information based on the preset dual-system memory partition rule and the actual size of the memory; The partition information is written into an electrically erasable programmable read-only memory, and system loading and startup are completed based on the partition information in the electrically erasable programmable read-only memory.

2. The method according to claim 1, characterized in that The method further comprises: Powering on and waking up the first kernel, the first kernel running a diskless boot interface, the diskless boot interface loading and booting an initialization process; The initialization process performs memory initialization and triggers memory reallocation.

3. The method according to claim 1, characterized in that Get the actual size of the memory, including: Set up and cache test data; Save various memory specifications supported by heterogeneous dual system chips to the specification list, including 521MB, 1GB, 2GB, and 4GB; Select the maximum memory size from the Specification list as the assumed value for the memory size; Execute a write operation to write the test data to a target address in the memory, where the target address is a space of the assumed value + 1KB; Perform a read operation to read data from the target address in memory; Using a loop statement to compare the read data with the test data to see if they are consistent, if the two are consistent, determining that the assumed value is the actual value of the memory; If the read data is inconsistent with the test data, the assumed value is halved, and the read and write test is re-executed based on the updated assumed value, and the iteration is repeated until the actual value of the memory is obtained; Check whether the actual value is in the specification list. If the actual value is in the specification list, output the actual value as the actual size of the memory. If the actual value is not in the specification list, filter out the memory specification that is closest to the actual value and larger than the actual value as the actual size of the memory.

4. The method according to claim 3, characterized in that Setting the test data includes: 0x12345678 is set as test data, and the test data is written into the non-volatile memory.

5. The method according to claim 1, characterized in that The dual system memory partition rules include: Multiple memory areas, the multiple memory areas include a first system partition, a second system partition, a dynamic memory partition and multiple necessary program partitions, the dual system includes a first system and a second system, the first system runs on a first kernel of the BMC, and the second system runs on a second kernel of the BMC; the multiple necessary program partitions include an inter-core communication partition, a communication partition between the BMC and a host node, a partition used by a display component, and a partition used by a memory detection program; The percentage configured for each region.

6. The method according to claim 5, characterized in that Based on the preset dual system memory partitioning rules and the actual size of the memory, partition information is generated, including: The product of the proportion of each area and the actual size is used as the partition size of each area; Generate a start address for each region in turn based on the partition size of each region; Store the starting address and partition size of each region as a structure.

7. The method according to claim 6, characterized in that Writing the partition information into an electrically erasable programmable read-only memory, and completing system loading and startup based on the partition information in the electrically erasable programmable read-only memory, including: Writing the structure carrying the partition information into the electrically erasable programmable read-only memory; Perform memory initialization through the initialization process; Confirming that the first kernel has been awakened, awakening the second kernel through an initialization process, loading the first system image file from the flash memory into the first system partition in the memory, and guiding the first system to run, wherein the first system reads the first partition address and the partition size related to itself from the partition information of the electrically erasable programmable read-only memory; The boot loader is started through the initialization process, and the boot loader guides the second system to start. The second system reads the partition head address and partition size related to itself from the partition information of the electrically erasable programmable read-only memory.

8. The method according to claim 5, characterized in that The method further comprises: monitoring the used memory of the first system and the used memory of the second system; Calculate the difference between the size of the first system partition and the used memory of the first system to obtain the available memory of the first system; Calculate the difference between the size of the second system partition and the used memory of the second system to obtain the available memory of the second system; If the available memory of the first system is lower than a preset memory threshold, applying for memory from the dynamic memory partition for the newly created program of the first system using a memory allocation function; If the available memory of the second system is lower than a preset memory threshold, a memory allocation function is used to apply for memory from the dynamic memory partition for the newly created program of the second system.

9. A terminal, characterized in that: include: A memory, used for storing a memory allocation program of the heterogeneous dual system; A processor is used to implement the steps of the memory allocation method for the heterogeneous dual system as described in any one of claims 1 to 8 when executing the memory allocation program of the heterogeneous dual system.

10. A computer-readable storage medium storing a computer program, characterized in that: The readable storage medium stores a memory allocation program for a heterogeneous dual system, and when the memory allocation program for the heterogeneous dual system is executed by a processor, the steps of the memory allocation method for a heterogeneous dual system as claimed in any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Starting method and device of SMP equipment, equipment and storage medium

    CN121433736A