External device memory management method and system
By building a device priority database and dividing the memory into sub-pools, the problem of low management efficiency caused by fluctuating memory demands in high-density external device scenarios is solved, and dynamic adjustment and efficient memory resource management are achieved.
Patent Information
- Application Number
- CN202510884520.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-06-27
AI Technical Summary
In high-density external device scenarios, when memory demand fluctuates, existing technologies cannot perform dynamic adjustments, resulting in low memory management efficiency.
By obtaining the device information of external devices and building a device priority database, the system runtime memory is divided into multiple sub-memory pools based on the priority of the devices in the device priority database, and managed using preset management rules corresponding to the sub-memory pools, including the division and management of emergency pools, dynamic pools and cache pools.
It achieves dynamic adjustment of memory resources in high-density device scenarios, improves the efficiency of memory management, ensures that the memory needs of key devices are met in a timely manner, and avoids system crashes.
Smart Images

Figure CN120386639B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and system for managing memory of an external device. Background Art
[0002] Related memory management solutions rely on manual intervention, such as adjusting basic input and output system settings or disabling non-critical devices, and usually use static memory allocation. This mode can meet the needs in scenarios with a small number of external devices and stable task loads. However, in scenarios with high-density external devices, dynamic adjustments cannot be made when memory demand fluctuates, resulting in low efficiency in external device memory management. Summary of the Invention
[0003] The present application provides a method and system for external device memory management to at least solve the problem in the related art that in high-density external device scenarios, dynamic adjustment cannot be performed when memory demand fluctuates, resulting in low memory management efficiency.
[0004] This application provides a method for managing memory of an external device, including:
[0005] Get device information of external devices;
[0006] Based on the device information, a device priority database is constructed, where the device priority database includes at least the device type, device hot-swap status, external device resource occupancy, and priority;
[0007] Based on the device priority in the device priority database, the system runtime memory is divided into multiple sub-memory pools. The sub-memory pools are used to process memory requests from devices with preset importance levels.
[0008] The sub-memory pool is managed by using the preset management rules corresponding to the sub-memory pool, so as to manage the memory of the external device.
[0009] The present application provides a memory management system, which includes an external device module, a firmware module, a memory management module and a real-time monitoring module;
[0010] The external device module is used to obtain external devices on the bus;
[0011] The firmware module is used to obtain device information corresponding to external devices and build a device priority database based on the device information;
[0012] The memory management module is used to divide the system runtime memory into multiple sub-memory pools based on the device priority in the device priority database, and manage the sub-memory pools using preset management rules corresponding to the sub-memory pools to manage the memory of the external device;
[0013] The real-time monitoring module is used to obtain the operating status information of the system and update the device priority database based on the priority of the device in the device priority database and the operating status information of the system.
[0014] The present application also provides a memory management device, comprising:
[0015] An acquisition unit, used to acquire device information of an external device;
[0016] A construction unit, configured to construct a device priority database based on the device information, wherein the device priority database includes at least a device type field, a device hot plug state field, an external device resource occupancy field, and a priority field;
[0017] A partitioning unit, configured to partition the system runtime memory into a plurality of sub-memory pools based on the priorities of the devices in the device priority database, wherein the sub-memory pools are used to process memory requests of devices with preset importance levels;
[0018] The memory management unit is used to manage the sub-memory pool by using preset management rules corresponding to the sub-memory pool, so as to manage the memory of the external device.
[0019] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned external device memory management methods when executing the computer program.
[0020] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned external device memory management methods are implemented.
[0021] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned external device memory management methods when executed by a processor.
[0022] Through this application, device information of external devices is obtained; based on the device information, a device priority database is constructed, and the device priority database includes at least device type, device hot-plug status, external device resource occupancy and priority; based on the priority of the device in the device priority database, the system runtime memory is divided into multiple sub-memory pools, and the sub-memory pools are used to process memory requests of devices with preset importance; the sub-memory pools are managed using preset management rules corresponding to the sub-memory pools to manage the memory of external devices, thereby solving the technical problem of low memory management efficiency due to the inability to perform dynamic adjustments when memory demand fluctuates in high-density device scenarios, and achieving the technical effect of dynamically adjusting memory resources and improving memory management efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0024] Figure 1 A flowchart of a method for managing memory of an external device provided in an embodiment of the present application;
[0025] Figure 2 A flowchart of a memory allocation method provided in an embodiment of the present application;
[0026] Figure 3 A flowchart of a method for managing memory of an external device provided in an embodiment of the present application;
[0027] Figure 4 A schematic diagram of the structure of a memory management device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the accompanying 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 only 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.
[0029] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such 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 elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0030] In order to facilitate those skilled in the art to better understand the technical solutions described in the embodiments of the present disclosure, the technical terms in the embodiments of the present disclosure are explained as follows before introducing the embodiments of the present disclosure.
[0031] Peripheral Component Interconnect Express (PCIE): A high-speed serial bus protocol used to connect high-performance peripherals to computer motherboards. An upgraded version of the traditional parallel PCI bus, it uses a point-to-point communication architecture and supports multi-channel aggregation. It offers high bandwidth, low latency, and strong scalability.
[0032] Basic Input Output System (BIOS): BIOS is the firmware in a computer that performs hardware initialization and provides runtime services for the operating system. It plays a vital role in the computer startup process, responsible for detecting and initializing hardware components (such as the hard drive, keyboard, mouse, etc.) and loading the operating system.
[0033] Unified Extensible Firmware Interface (UEFI) system: a modern firmware interface standard used to replace traditional BIOS.
[0034] Hardware Initialization Information (HII): In the UEFI firmware environment, this structure describes how a hardware module (such as a driver or firmware image) initializes its associated hardware. It is typically provided by the firmware and called during platform boot to complete device initialization.
[0035] Runtime Boot Services Memory (RTB): A memory area that remains and is not released after the operating system is started. It is used to support firmware functions that still need to be accessed while the operating system is running. It is referred to as runtime memory in this application.
[0036] Central Processing Unit (CPU): The CPU is the core component of the computer, responsible for executing instructions in the instruction set to process data. It is the brain of the computer, performing arithmetic and logical operations, controlling data flow, and executing instructions of the operating system.
[0037] Baseboard Management Controller (BMC): A BMC is a dedicated microcontroller that monitors the physical status of the server, including temperature, voltage, fan speed, etc., and supports remote management and diagnostic functions.
[0038] The HII table of PCIE peripheral devices occupies RTB memory. As a core data structure for device enumeration and configuration, its memory usage grows superlinearly with the number of devices. In deployments of tens of thousands of devices, the HII table memory requirement can increase by more than a thousand times, far exceeding the capacity expected by traditional fixed allocation strategies. This conflict leads to rapid depletion of non-region protected (Non-RP) memory, forcing the system to compress critical control channels, resulting in a 30%-50% increase in device initialization failure rates. Furthermore, 5%-15% of available memory is inefficiently occupied due to fragmentation.
[0039] Related memory management solutions rely on manual intervention, such as adjusting BIOS settings or disabling non-critical devices, and lack dynamic adaptability. Traditional Peripheral Component Interconnect (PCI) resource management mechanisms use static address allocation, which cannot cope with the fluctuating memory demands of high-density external devices. For example, when a new device is connected, a fixed allocation strategy may trigger resource conflicts due to insufficient reserved space. Manual capacity expansion requires downtime, which cannot meet the 24 / 7 operation requirements of data centers.
[0040] The following briefly introduces three solutions for external device memory management methods in related technologies:
[0041] Solution A: Solution A proposes a method for implementing memory access to address the problem of insufficient computer memory space. By enabling the computer's operating system to call the UEFI BIOS interface, the computer can use the memory space in the external memory pool. It focuses on technical improvements in memory access and space expansion.
[0042] Solution B: Solution B proposes a method to initialize the configuration space of PCIE devices. For PCIE device initialization, it proposes to build a root bridge structure array in the PEI stage to dynamically allocate bus resources. The root bridge structure array encapsulates device information and bus resources to achieve dynamic control in the PEI stage.
[0043] Solution C: Solution C proposes a method for initializing PCIE devices. It proposes to collaboratively enumerate and match devices through BIOS and BMC during server startup to solve the problem of PCIE device card dropout and improve system stability and diversity.
[0044] The above scheme also has the following disadvantages:
[0045] Lack of dynamic adaptability and inability to allocate resources based on priority. Critical devices (such as HCA cards) and non-critical devices (such as USB hubs) share the same memory pool, which may cause critical tasks to crash due to insufficient resources. The system cannot respond to load changes and cannot dynamically adjust memory policies based on the load during device operation. For example, when the HII table memory demand surges, it cannot automatically expand the capacity, resulting in rapid exhaustion of the non-protected area (Non-RP).
[0046] Insufficient monitoring and flexibility. There is no real-time monitoring mechanism, and it is impossible to track the memory usage trend of the HII table and trigger an early warning. It needs to rely on manual intervention or passive repair after crash. The flexibility is poor. The memory size is fixed at compile time. If it is underestimated, it will lead to resource exhaustion, and over-allocation will cause waste. This contradiction is particularly prominent in high-density PCIE device scenarios.
[0047] Through this application, device information of external devices is obtained; based on the device information, a device priority database is constructed, and the device priority database includes at least device type, device hot-plug status, external device resource occupancy and priority; based on the priority of the device in the device priority database, the system runtime memory is divided into multiple sub-memory pools, and the sub-memory pools are used to process memory requests of devices with preset importance; the sub-memory pools are managed using preset management rules corresponding to the sub-memory pools to manage the memory of external devices, thereby solving the technical problem of low memory management efficiency due to the inability to perform dynamic adjustments when memory demand fluctuates in high-density device scenarios, and achieving the technical effect of dynamically adjusting memory resources and improving memory management efficiency.
[0048] An embodiment of the present disclosure provides a method for managing memory of an external device. The method can be applied to PCIE external devices in a server system. The server system is usually connected to a variety of PCIE external devices, and these external devices have very different requirements for memory resources. The server system in this application can be a storage server, a computing server, an artificial intelligence (AI) server, etc.; the method can also be applied to memory resource scheduling in UEFI firmware. During the UEFI startup process, the system has not yet loaded the complete operating system driver, and memory resources need to be reserved for various external devices. The external device memory management method provided in this application can be executed by the UEFI firmware, the memory management module in the operating system kernel, or a dedicated memory management module.
[0049] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0050] Figure 1 A flowchart of a method for managing memory of an external device provided by an embodiment of the present disclosure is provided.
[0051] like Figure 1 As shown, the method comprises the following steps:
[0052] Step 101, obtaining device information of an external device;
[0053] In some embodiments, an external device refers to a hardware module connected to the motherboard through a bus interface, such as PCIE, Universal Serial Bus (USB), Non-Volatile Memory Express (NVME), etc., such as a graphics processing unit (GPU), NVME hard disk, host channel adapter (HCA) card, smart network card, etc.
[0054] In some embodiments, the device information of the external device is used to identify and manage the basic attribute data of the device, including but not limited to the device type, vendor ID (Vendor ID), device ID (Device ID), configuration space field, current hot plug status and current resource usage, such as bandwidth, cache usage, etc.
[0055] In some embodiments, during the UEFI firmware execution phase, device information of external devices can be obtained by enumerating all devices on the PCI / PCIE bus. Specifically, after scanning the external PCIE device, the firmware reads the device configuration space through the device protocol layer module, such as the PCI / PCIE bus protocol, to obtain key information such as Vendor ID and Device ID.
[0056] Step 102: Building a device priority database based on the device information. The device priority database includes at least device type, device hot-swap status, external device resource occupancy, and priority.
[0057] In some embodiments, the device priority database is used to record and manage the data structure of the priorities of all external devices, supporting dynamic query and update. The device priority database can be implemented in the form of a structure, array or hash table, with each device corresponding to a record. For PCIE devices that undertake critical data transmission tasks, higher priority is given to prioritize their memory supply; for some non-critical devices, the priority is appropriately lowered.
[0058] In some embodiments, device types may include graphics cards (PCIE x16), NVME solid-state drives (PCIE x4), USB controllers, etc., and basic priorities may be preset for different device types. The initial priority is determined by the device type, such as the priority of NVME solid-state drives is higher than the priority of USB); the device hot-plug status includes real-time updates of the device connection status, and the priority of hot-plug devices is dynamically improved; the external device resource occupancy includes monitoring memory / CPU occupancy, and automatically reducing the bandwidth of low-priority devices when resources are tight; the priority is calculated by the basic priority and the dynamic adjustment factor to determine the order of memory resource allocation. During runtime, the priority is dynamically adjusted according to the external device resource occupancy and hot-plug status.
[0059] In some embodiments, the device type determines the hardware basis for task execution, and different types of devices have different processing capabilities and requirements; the hot-swap status reflects the access and removal of the device in real time, so that resource allocation can be adjusted in a timely manner; and the resource occupancy rate intuitively presents the current resource usage status.
[0060] Step 103: Based on the device priorities in the device priority database, the system runtime memory is divided into multiple sub-memory pools, and the sub-memory pools are used to process memory requests of devices with preset importance levels;
[0061] In some embodiments, system runtime memory refers to the memory area reserved during the runtime boot service memory stage, which is accessed during the operation of the operating system and is commonly used for variable services, device context maintenance, etc. The system runtime memory size can be obtained from the system management mode.
[0062] In some embodiments, the sub-memory pool divides the RTB memory into several small memory pools with different uses, each serving devices of different priorities.
[0063] In some embodiments, by dividing the system runtime memory into multiple sub-memory pools, finer-grained resource control and optimized memory utilization can be achieved.
[0064] In some embodiments, the memory request of the device with a preset importance is to set different memory service quality levels according to the device priority, such as emergency pool, dynamic pool, cache pool, etc.
[0065] In some embodiments, the UEFI interface is used to apply for and manage memory, and a memory timeout release mechanism can be combined to improve memory utilization.
[0066] Step 104 : managing the sub-memory pool using a preset management rule corresponding to the sub-memory pool to manage the memory of the external device.
[0067] In some embodiments, the preset management rules refer to memory allocation, access, and reclamation policies established for each sub-memory pool. The allocation policy may determine a maximum allocation limit, access control may include only allowing high-priority devices to access the emergency pool, and memory reclamation policies may employ a least recently used (LRU) algorithm or a first-in, first-out (FIFO) algorithm.
[0068] In some embodiments, when a memory request arrives, the sub-memory pool is matched according to the device priority. If there is no available memory pool, memory is attempted to be allocated from a low-priority pool. If the request cannot be met, the exception handling process is triggered, logging is performed, and the system falls back to safe mode.
[0069] Through this application, device information of external devices is obtained; based on the device information, a device priority database is constructed, and the device priority database includes at least device type, device hot-plug status, external device resource occupancy and priority; based on the priority of the device in the device priority database, the system runtime memory is divided into multiple sub-memory pools, and the sub-memory pools are used to process memory requests of devices with preset importance; the sub-memory pools are managed using preset management rules corresponding to the sub-memory pools to manage the memory of external devices, thereby solving the technical problem of low memory management efficiency due to the inability to perform dynamic adjustments when memory demand fluctuates in high-density device scenarios, and achieving the technical effect of dynamically adjusting memory resources and improving memory management efficiency.
[0070] In some embodiments, after constructing a device priority database based on device information, the external device memory management method includes:
[0071] Get the system's operating status information;
[0072] In some embodiments, the system's operating status information refers to indicator data of the current computer system's operating status, including but not limited to CPU usage, memory usage, peripheral activity, temperature, power consumption, fan speed and other hardware health status and operating system or firmware load conditions, among which the peripheral activity can be measured by the input / output request frequency of the PCIE device.
[0073] In some embodiments, the hardware status can be read using an interface provided by the HII, and CPU / memory usage can be monitored using performance counters.
[0074] The device priority database is updated based on the priority of the device in the device priority database and the operating status information of the system.
[0075] In some embodiments, based on the priority of the device in the device priority database and the operating status information of the system, the device priority database can be updated periodically, or it can be updated when a specific event occurs. The specific event can be a new device insertion event or a system load mutation event.
[0076] In some embodiments, the database has the ability to dynamically update priorities. When the system operating status changes, such as when a device is connected or when task resource requirements suddenly change, the database can quickly re-evaluate and update task priorities to ensure that resource allocation is always reasonable and efficient.
[0077] In some embodiments, by collecting system operation status information and combining it with device priority information in a device priority database, the device priority is dynamically adjusted, thereby achieving intelligent scheduling and efficient utilization of system resources.
[0078] In some embodiments, the sub-memory pool includes an emergency pool, a dynamic pool, and a cache pool. The emergency pool is used to process memory requests from critical devices, the dynamic pool is used to process memory requests from high-priority devices, and the cache pool is used to process memory requests from low-priority devices.
[0079] In some embodiments, the cache strategy is as shown in the following table: the emergency pool is a memory area that ensures that critical devices can still obtain minimum memory resources in extreme situations (such as memory shortage, system abnormality), which is usually set to read-only or protected access to prevent low-priority requests from encroaching; the dynamic pool is a memory area that can dynamically adjust the size according to system load and device requirements, mainly serving high-priority but non-critical devices, and can be expanded when system resources are sufficient; the cache pool is used to meet temporary memory requests of low-priority devices, and can support cache recovery mechanisms (such as the aforementioned LRU and FIFO, etc.), and give priority to release when system resources are tight.
[0080]
[0081] Table 1 Three-level cache mechanism
[0082] In some embodiments, the emergency pool can be key devices such as GPU, NVME, etc. Key devices refer to core peripherals on which the normal operation of the system depends. If the key devices cannot obtain sufficient memory resources, it may cause the system to crash; the dynamic pool can be devices such as network devices, and the cache pool can be devices with lower priority such as USB.
[0083] In some embodiments, a linked list or reference counting mechanism may be used to track memory usage status.
[0084] In some embodiments, by dividing the system runtime memory into an emergency pool, a dynamic pool, and a cache pool, which are used to process memory requests from critical devices, high-priority devices, and low-priority devices respectively, refined management and efficient utilization of memory resources are achieved.
[0085] In some embodiments, as Figure 2 As shown, Figure 2 A flowchart of a memory allocation method provided in an embodiment of the present application is provided. Based on the priority of the device in the device priority database, after the system runtime memory is divided into multiple sub-memory pools, the external device memory management method includes:
[0086] Step 201: Obtain pending memory requests of each sub-memory pool in a plurality of sub-memory pools;
[0087] In some embodiments, a pending memory request refers to a memory allocation request that has not yet been satisfied. The memory allocation request typically includes the required memory size, a device identifier of the request source, and the like.
[0088] Step 202 , sorting the pending memory requests according to the device priorities in the device priority database to obtain a target request queue;
[0089] In some embodiments, the target request queue is a memory request queue sorted by device priority, with requests from high-priority devices at the front and requests from low-priority devices at the back, which can be used for subsequent memory scheduling decisions.
[0090] Step 203, in response to receiving a new memory request, updating the target request queue;
[0091] In some embodiments, each sub-memory pool maintains a request queue, which can be a linked list structure for recording all currently unprocessed requests, periodically polling each memory pool, or obtaining new memory requests in real time through an event notification mechanism. In the UEFI environment, new memory requests can be captured by registering an event listener.
[0092] Step 204 : Allocate memory to the memory requests in the target task queue in descending order of priority.
[0093] In some embodiments, all pending requests are extracted from each sub-memory pool, and for each device corresponding to the request, its current priority is searched in the device priority database, and sorted from high to low priority using a sorting algorithm such as quick sort. After the sorting is completed, a target request queue is generated. If a new memory request is received, the new memory request and the memory requests in the target request queue are sorted to obtain the latest target request queue, that is, the new memory request is inserted into the appropriate position in the existing queue, and finally memory is allocated to the memory request according to priority from high to low.
[0094] In some embodiments, a memory allocation algorithm built on a priority database uses a priority queue to manage memory requests in an orderly manner. When a memory request arrives, the system prioritizes memory allocation for high-priority tasks based on the order of the priority queue. High-priority tasks are often related to critical system functions or real-time response requirements. Prioritizing their memory supply can avoid system freezes or response delays. Low-priority tasks, on the other hand, receive memory allocation in sequence according to the queue order if system resources permit, thereby achieving rational resource utilization and orderly task execution.
[0095] In some embodiments, by obtaining pending requests from multiple sub-memory pools, sorting the requests in combination with the device priority database, generating a target request queue, and dynamically updating the queue when new requests arrive, resources are finally allocated to memory requests in order of priority, thereby achieving efficient memory management and task scheduling.
[0096] In some embodiments, after allocating memory to the memory requests in the target task queue in descending order of priority, the external device memory management method includes:
[0097] Obtain the resource usage of external devices, including the device's CPU usage and device memory usage;
[0098] In some embodiments, external device resource utilization refers to the proportion of computing and storage resources consumed by an external device during system operation, and is used to measure device activity. Device CPU utilization indicates the percentage of time the device driver or related tasks are executed on the CPU, reflecting the device's demand for CPU resources. Device memory utilization indicates the proportion of memory currently used by the device relative to its allocatable memory.
[0099] Update preset management rules based on external device resource occupancy and target request queue.
[0100] In some embodiments, updating the preset management rules refers to dynamically adjusting the above-mentioned memory allocation strategy according to the device resource usage and the status of the request queue, which can achieve more refined resource scheduling and exception prevention.
[0101] In some embodiments, by continuously monitoring key indicators such as CPU usage, memory occupancy, and task queue length, the system can accurately perceive load changes. Once the load situation changes, the dynamic adjustment mechanism is immediately activated and the memory allocation strategy is flexibly adjusted according to preset rules.
[0102] In some embodiments, by collecting the CPU usage and memory occupancy of the device and combining it with the status of the current pending task queue, the preset memory management rules are dynamically adjusted to achieve intelligent scheduling and optimal utilization of system resources.
[0103] In some embodiments, updating the preset management rules based on the external device resource occupancy and the target request queue includes:
[0104] Obtaining a first load of the external device, where the first load is an original load of the external device;
[0105] Determine a second load of the device based on the resource occupancy of the external device and the target request queue, where the second load is the current load of the external device;
[0106] Based on the second load and the first load, the preset management rule is updated.
[0107] In some embodiments, the original load of the external device refers to the load recorded in the device priority database, and the current load of the external device refers to the load determined by real-time monitoring.
[0108] In some embodiments, if the original load and the current load change, the memory allocation, access, and recycling strategies are determined based on the load change to update the preset management rules. Taking the memory allocation strategy as an example, the runtime memory is divided into multiple sub-memory pools (such as an emergency pool accounting for 60%, a cache pool accounting for 30%, and a dynamic pool accounting for 10%). According to the load changes, the space share of multiple sub-memory pools supports on-demand elastic expansion.
[0109] In some embodiments, after allocating memory to the memory requests in the target task queue in descending order of priority, the external device memory management method includes:
[0110] In response to a failure in allocating memory for a memory request in a target task queue, obtaining abnormal information of an external device, the abnormal information of the external device including at least one of a fatal error, a compatibility error, and a performance fluctuation;
[0111] In some embodiments, memory allocation failure typically occurs when some memory areas are unavailable due to insufficient memory resources, resource contention, or hardware failure.
[0112] In some embodiments, a real-time monitoring system can be used to collect data such as device status, network traffic, and program logs to obtain device status information, network traffic information, and program log information. Status information refers to whether the device is busy, disconnected, etc.; network traffic information is used to reflect data transmission rate and delay; program log information is used to record error logs, debugging information, etc. of device drivers or applications, and determine abnormal information of external devices based on device status information, network traffic information, and program log information.
[0113] Determining a priority adjustment instruction corresponding to abnormal information of the external device;
[0114] In some embodiments, the priority adjustment instruction corresponding to the abnormal information of the external device includes a fallback priority. If the abnormal information of the external device is manifested as a fatal error, such as a system crash, the fallback priority is 100, indicating that an emergency fallback needs to be performed immediately, and the fallback is based on the current priority of the external device; if the abnormal information of the external device is manifested as a compatibility issue, such as a driver abnormality, the version rollback is planned to be executed, and the fallback priority is 70; if the abnormal information of the external device is manifested as performance fluctuations, such as a memory leak, a progressive rollback is triggered, and the fallback priority is 50. The fallback priorities of 100, 70 and 50 in this application can be adjusted according to actual conditions.
[0115] In some embodiments, the priority adjustment instruction is an operation command used to modify its priority in the device priority database, which may include operations such as priority increase, decrease, and maintenance. For example, when the device frequently fails to allocate memory and the log shows insufficient memory, its priority can be lowered.
[0116] Based on the priority adjustment instruction, the priority field in the device priority database is updated.
[0117] In some embodiments, based on the priority adjustment instruction, updating the priority field in the device priority database includes:
[0118] Based on the priority adjustment instruction, determining an update rule corresponding to the priority adjustment instruction;
[0119] Update the priority field in the device priority database using the update rule.
[0120] In some embodiments, when the fallback priority in the priority adjustment instruction is 100, the update rule corresponding to the priority adjustment instruction is to immediately execute an emergency fallback; when the fallback priority in the priority adjustment instruction is 70, the update rule corresponding to the priority adjustment instruction is to plan to execute a version fallback; when the fallback priority in the priority adjustment instruction is 50, the update rule corresponding to the priority adjustment instruction is to trigger a gradual fallback. After determining the update rule, the priority field in the device priority database is updated according to the corresponding update rule.
[0121] In some embodiments, after updating the priority field in the device priority database using the update rule, the external device memory management method further includes:
[0122] Based on the updated priority field, the allocated memory is rolled back in preset stages, which include a hardware layer stage, a system layer stage, and an application layer stage.
[0123] In some embodiments, the updated priority field refers to the priority field in the device priority database after being updated using the update rule, and the allocated memory refers to the memory allocated to the memory request in the order of priority from high to low.
[0124] In some embodiments, the rollback processing of allocated memory during a preset phase specifically includes rolling back the allocated memory at the hardware layer, rolling back the allocated memory at the system layer, and rolling back the allocated memory at the application layer. Hardware-layer rollback processing is implemented through an FPGA dual-image architecture. When a configuration error or peripheral anomaly is detected, the system automatically triggers the IPROG instruction to reset the configuration memory and load the GoldenImage (basic function image) from the Flash base address to ensure rapid recovery of hardware functions. This mechanism specifies the rollback address through the WBSTAR register and, combined with a hardware reset pulse, clears the error state to avoid system crashes due to configuration failure. System-layer rollback processing adopts a phased strategy: first, a device reset (such as a PCIE device reset) is triggered through the UEFI firmware, followed by a rollback to a stable version using the system backup mechanism (such as the Windows.old folder in Windows). Application-layer fallback processing achieves refined control through framework-level event interception: the system uses OnBackPressedDispatcher to manage back key events and supports interactive logic such as double-click exit. Multi-fallback stack frameworks (such as the Navigation component) implement independent fallback paths for different functional modules by saving / restoring the fallback stack state. Application-layer fallback needs to be dynamically adjusted in conjunction with the priority database.
[0125] In some embodiments, the aforementioned three-layer fallback mechanism forms a closed loop through hardware-level rapid response, system-level version management and application-level interactive control, ensuring a complete fallback link from the physical layer to the application layer in abnormal scenarios.
[0126] In some embodiments, as Figure 3 As shown, Figure 3 A flow chart of a method for managing memory of an external device provided in an embodiment of the present application, wherein Figure 3 In the middle left triangle area, the external PCIE device layer refers to the PCIE devices extended by the server through the PCIE protocol, such as GPU cards, graphics cards, network cards, solid-state drives, etc.; the UEFI firmware layer refers to the key software layer between the hardware and the operating system when the server starts, which performs hardware initialization and detects the PCIE external devices configured for the server. In a certain server model product, depending on the server type, such as storage servers, computing servers, AI servers, etc., for the external PCIE devices of the server, the device type priority is determined according to the type attributes of the device. For example, for computing servers, the GPU priority is 0.5, the network card priority is 1, and the NVME hard disk priority is 2; for storage servers, the NVME hard disk priority is 0.5, the RAID card priority is 1, and the network card priority is 2. After loading and scanning the PCIE devices installed on the server, the UEFI firmware layer will organize this part of information into the database to establish a priority database for PCIE devices. For Figure 3 In the upper right corner of the rectangular matrix area, in the runtime memory, the memory priority area (PR) and the memory non-priority area (PR) are mainly used to optimize the performance of real-time computing tasks. The memory in the PR area has the characteristics of low-latency access and preemptive scheduling. For example, when a computing server performs graphics processing, because the GPU has a higher priority, this task will take priority in preempting the PR area memory. The non-PR area memory is characterized by high latency and fair scheduling principles. Figure 3Specifically, the three-level memory buffer pool mechanism refers to the division of PR and non-PR areas into three levels of memory pools for different tasks of different device types: emergency pool, dynamic pool, and cache pool. For example, GPU graphics rendering tasks and artificial intelligence training tasks are divided into the emergency pool, network interaction tasks of the network card are divided into the dynamic pool, and NVME hard disk read and write tasks are divided into the cache pool; elastic memory pool management refers to the flexible definition of task types and task quantities in the three cache pools, which can be flexibly defined in different product types; dynamic priority scheduling algorithm refers to the combination of the priority of each type of device in the PCIE device database and the task priority allocation of the three-level memory pool, and the algorithm scheduling of different assigned tasks to ensure that high-priority tasks can reasonably allocate memory space; the safe fallback mechanism refers to the tasks generated by the plug-in and unplugging of various PCIE devices and the access of business layer tasks. If the allocation of memory space fails or the resource preemption fails, the task needs to be rolled back and the corresponding alarm log is triggered. The dynamic monitoring system refers to a real-time monitoring system that can visualize the remaining memory space in the current PR area and non-PR area. Through the real-time monitoring system, you can view the current three-level memory pool allocation and task queue status. For any abnormal situations monitored, such as insufficient memory space and excessive task queues, the information will be printed through log information and fed back to the dynamic priority scheduling algorithm to promote further algorithm upgrades and optimizations of the dynamic priority scheduling algorithm.
[0127] In some embodiments, by collecting exception information of external devices when memory allocation fails, generating priority adjustment instructions, and updating the device priority database in a phased manner, a more stable and intelligent resource scheduling and exception handling mechanism is achieved.
[0128] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0129] The embodiment of the present application further provides a memory management system, which includes an external device module, a firmware module, a memory management module and a real-time monitoring module;
[0130] The external device module is used to obtain external devices on the bus;
[0131] The firmware module is used to obtain device information corresponding to external devices and build a device priority database based on the device information;
[0132] The memory management module is used to divide the system runtime memory into multiple sub-memory pools based on the device priority in the device priority database, and manage the sub-memory pools using preset management rules corresponding to the sub-memory pools to manage the memory of the external device;
[0133] The real-time monitoring module is used to obtain the operating status information of the system and update the device priority database based on the priority of the device in the device priority database and the operating status information of the system.
[0134] The embodiment of the present application further provides a memory management device 400, Figure 4 A schematic diagram of the structure of a memory management device provided by an embodiment of the present disclosure is shown in FIG. Figure 4 Shown, including:
[0135] An acquisition unit 401 is used to acquire device information of an external device;
[0136] A construction unit 402 is configured to construct a device priority database based on the device information, wherein the device priority database includes at least a device type field, a device hot plug status field, an external device resource occupancy field, and a priority field;
[0137] A partitioning unit 403 is configured to partition the system runtime memory into a plurality of sub-memory pools based on the device priorities in the device priority database, the sub-memory pools being used to process memory requests from devices with preset importance levels;
[0138] The memory management unit 404 is configured to manage the sub-memory pool using a preset management rule corresponding to the sub-memory pool, so as to manage the memory of the external device.
[0139] Furthermore, in a possible implementation of the embodiment of the present disclosure, the acquiring unit 401 is configured to:
[0140] Get the system's operating status information;
[0141] The device priority database is updated based on the priority of the device in the device priority database and the operating status information of the system.
[0142] In some embodiments, the sub-memory pool includes an emergency pool, a dynamic pool, and a cache pool. The emergency pool is used to process memory requests from critical devices, the dynamic pool is used to process memory requests from high-priority devices, and the cache pool is used to process memory requests from low-priority devices.
[0143] Furthermore, in a possible implementation of the embodiment of the present disclosure, the memory management device 400 further includes a memory allocation unit, which is configured to:
[0144] Get the pending memory requests of each sub-memory pool in multiple sub-memory pools;
[0145] Sort the pending memory requests according to the priorities of the devices in the device priority database to obtain a target request queue;
[0146] In response to receiving a new memory request, updating a target request queue;
[0147] Allocate memory to the memory requests in the target task queue in descending order of priority.
[0148] Furthermore, in a possible implementation of the embodiment of the present disclosure, the memory management device 400 further includes an updating unit, which is configured to:
[0149] Obtain the resource usage of external devices, including the device's CPU usage and device memory usage;
[0150] Update preset management rules based on external device resource occupancy and target request queue.
[0151] Furthermore, in a possible implementation of the embodiment of the present disclosure, the updating unit is further configured to:
[0152] Acquire a first load of the external device, where the first load is an original load of the external device;
[0153] determining a second load of the device based on the resource occupancy of the external device and the target request queue, where the second load is a current load of the external device;
[0154] The preset management rule is updated based on the second load and the first load.
[0155] Furthermore, in a possible implementation of the embodiment of the present disclosure, the updating unit is further configured to:
[0156] In response to a failure in allocating memory for a memory request in a target task queue, obtaining abnormal information of an external device, the abnormal information of the external device including at least one of a fatal error, a compatibility error, and a performance fluctuation;
[0157] Determining a priority adjustment instruction corresponding to abnormal information of the external device;
[0158] Based on the priority adjustment instruction, the priority field in the device priority database is updated.
[0159] Furthermore, in a possible implementation of the embodiment of the present disclosure, the updating unit is further configured to:
[0160] Based on the priority adjustment instruction, determining an update rule corresponding to the priority adjustment instruction;
[0161] The priority field in the device priority database is updated using the update rule.
[0162] Furthermore, in a possible implementation of the embodiment of the present disclosure, the memory management device 400 further includes a memory fallback unit, which is configured to:
[0163] Based on the updated priority field, the allocated memory is rolled back in preset stages, where the preset stages include a hardware layer stage, a system layer stage, and an application layer stage.
[0164] Through this application, device information of external devices is obtained; based on the device information, a device priority database is constructed, and the device priority database includes at least device type, device hot-plug status, external device resource occupancy and priority; based on the priority of the device in the device priority database, the system runtime memory is divided into multiple sub-memory pools, and the sub-memory pools are used to process memory requests of devices with preset importance; the sub-memory pools are managed using preset management rules corresponding to the sub-memory pools to manage the memory of external devices, thereby solving the technical problem of low memory management efficiency due to the inability to perform dynamic adjustments when memory demand fluctuates in high-density device scenarios, and achieving the technical effect of dynamically adjusting memory resources and improving memory management efficiency.
[0165] For the description of the features in the embodiment corresponding to the memory management apparatus, reference can be made to the relevant description of the embodiment corresponding to the external device memory management method, which will not be repeated here.
[0166] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps of any of the above-mentioned embodiments of the external device memory management method.
[0167] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned embodiments of the external device memory management method when running.
[0168] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0169] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned embodiments of the external device memory management method are implemented.
[0170] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned external device memory management method embodiments.
[0171] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0172] The above is a detailed introduction to the external device memory management method and system provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A method for managing memory of an external device, characterized in that: include: Get device information of external devices; Based on the device information, a device priority database is constructed, wherein the device priority database includes at least device type, device hot plug status, external device resource occupancy and priority; Based on the priority of the device in the device priority database, the system runtime memory is divided into multiple sub-memory pools, the sub-memory pools are used to process memory requests of devices with preset importance, the sub-memory pools include an emergency pool, a dynamic pool and a cache pool, the emergency pool is used to process memory requests of key devices, the dynamic pool is used to process memory requests of high-priority devices, and the cache pool is used to process memory requests of low-priority devices; Managing the sub-memory pool using a preset management rule corresponding to the sub-memory pool to manage the memory of the external device; After dividing the system runtime memory into a plurality of sub-memory pools based on the priorities of the devices in the device priority database, the method includes: Obtaining pending memory requests for each sub-memory pool in the plurality of sub-memory pools; sorting the pending memory requests according to the priorities of the devices in the device priority database to obtain a target request queue; In response to receiving a new memory request, updating the target request queue; Memory is allocated to the memory requests in the target task queue in descending order of priority.
2. The external device memory management method according to claim 1, characterized in that: After constructing the device priority database based on the device information, the method includes: Get the system's operating status information; The device priority database is updated based on the priority of the device in the device priority database and the operating status information of the system.
3. The external device memory management method according to claim 1, characterized in that: After allocating memory to the memory requests in the target task queue in descending order of priority, the method includes: Obtaining external device resource occupancy, wherein the external device resource occupancy includes device central processing unit usage and device memory usage; The preset management rule is updated based on the external device resource occupancy and the target request queue.
4. The external device memory management method according to claim 3, characterized in that: The updating of the preset management rule based on the external device resource occupancy and the target request queue includes: Acquire a first load of the external device, where the first load is an original load of the external device; determining a second load of the device based on the resource occupancy of the external device and the target request queue, where the second load is a current load of the external device; The preset management rule is updated based on the second load and the first load.
5. The external device memory management method according to claim 1, characterized in that: After allocating memory to the memory requests in the target task queue in descending order of priority, the method includes: In response to the failure to allocate memory for the memory request in the target task queue, obtaining abnormal information of the external device, wherein the abnormal information of the external device includes at least one of a fatal error, a compatibility error, and a performance fluctuation; determining a priority adjustment instruction corresponding to the abnormal information of the external device; Based on the priority adjustment instruction, the priority field in the device priority database is updated.
6. The external device memory management method according to claim 5, characterized in that: The updating of the priority field in the device priority database based on the priority adjustment instruction includes: Based on the priority adjustment instruction, determining an update rule corresponding to the priority adjustment instruction; The priority field in the device priority database is updated using the update rule.
7. The external device memory management method according to claim 6, characterized in that: After updating the priority field in the device priority database using the update rule, the method further includes: Based on the updated priority field, the allocated memory is rolled back in preset stages, where the preset stages include a hardware layer stage, a system layer stage, and an application layer stage.
8. A memory management system, characterized in that: The memory management system includes an external device module, a firmware module, a memory management module and a real-time monitoring module; The external device module is used to obtain the external device on the bus; The firmware module is used to obtain device information corresponding to the external device and build a device priority database based on the device information; The memory management module is used to divide the system runtime memory into multiple sub-memory pools based on the priority of the device in the device priority database, and manage the sub-memory pools using preset management rules corresponding to the sub-memory pools to manage the memory of the external device; wherein the sub-memory pools include an emergency pool, a dynamic pool and a cache pool, the emergency pool is used to process memory requests of key devices, the dynamic pool is used to process memory requests of high-priority devices, and the cache pool is used to process memory requests of low-priority devices; The real-time monitoring module is used to obtain the operating status information of the system and update the device priority database based on the priority of the device in the device priority database and the operating status information of the system; After dividing the system runtime memory into a plurality of sub-memory pools based on the priority of the device in the device priority database, the method further includes: Obtaining pending memory requests for each sub-memory pool in the plurality of sub-memory pools; sorting the pending memory requests according to the priorities of the devices in the device priority database to obtain a target request queue; In response to receiving a new memory request, updating the target request queue; Memory is allocated to the memory requests in the target task queue in descending order of priority.
Citation Information
Patent Citations
Memory pool management method and device, storage medium and electronic device
CN119336513A
Memory management function detection method and system, electronic equipment and storage medium
CN120066831A