Display memory address space processing method and device, electronic equipment, medium and product
Patent Information
- Application Number
- CN202610920423.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-24
- Publication Date
- 2026-10-09
AI Technical Summary
[0003]然而,在实际运行中,上述机制常出现显存资源持续被无效占用的情形
[0007]一种可能的实现中,第一方面所述的方法还包括:在所述目标显存地址空间在所述第一时间段中被访问的情况下,或者,若所述目标显存地址空间不满足所述预设条件,确定不对所述目标显存地址空间执行物理回收操作。目标显存地址空间在第一时间段中被访问或目标显存地址空间满足预设条件可以表示目标显存地址空间处于正常状态。如此,能避免因回收目标显存地址空间导致后续访问该目标显存地址空间时,触发非法内存访问错误、进程崩溃、访问失效或系统异常等问题。此外,在目标显存地址空间在第一时间段被访问时,可以记录目标显存地址空间被访问的时间戳,以便于后续确定目标显存地址空间是否为持续被无效占用的显存地址空间。
Smart Images

Figure CN122884869A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of video memory management technology, specifically relating to a video memory address space processing method, apparatus, electronic device, medium, and product. Background Technology
[0002] In scenarios such as artificial intelligence (AI) inference, cloud-native computing, and massively parallel computing, video memory management typically involves memory pools and handle mechanisms. Memory pools reduce driver call overhead by pre-allocating and reusing video memory blocks, while handle mechanisms are responsible for tracking the lifecycle of video memory resources, ensuring that physical memory can be reclaimed for subsequent use after logical release.
[0003] However, in actual operation, the above mechanism often results in situations where video memory resources are continuously and unused. Such unused video memory cannot be reused by subsequent video memory requests within the same process, nor can it be reclaimed by other processes or container instances, resulting in a serious waste of video memory resources. Summary of the Invention
[0004] Therefore, the purpose of this application is to provide a method, apparatus, electronic device, medium and product for processing video memory address space, so as to improve the utilization rate of video memory resources.
[0005] The embodiments of this application are implemented as follows: In a first aspect, embodiments of this application provide a method for processing video memory address space. The method includes: acquiring a target video memory address space, wherein the idle time of the target video memory address space is greater than a first threshold, and the idle time is used to indicate the duration during which the target video memory address space has not been accessed; if the target video memory address space is not accessed during a first time period, and if the target video memory address space meets a preset condition, then performing a physical reclamation operation on the target video memory address space, wherein the start time of the first time period is the time point at which the idle time of the target video memory address space is determined to be greater than the first threshold, and the target video memory address space meeting the preset condition indicates that the target video memory address space is currently not occupied.
[0006] The continuous invalidation of video memory resources can be understood as follows: the video memory handle of the video memory address space has been released, but the physical video memory page corresponding to the video memory address space has not been returned to the GPU driver or the free list of the memory pool; or, the video memory address space has been occupied for a long time without any valid instructions for reading or writing. To address the problem of continuously invalidated video memory resources, this application proposes to acquire video memory address spaces that may be continuously invalidated (i.e., target video memory address spaces with an idle time greater than a first threshold), and determine whether the video memory address space has been accessed within a first time period. If the video memory address space has not been accessed within the first time period, and no application is currently occupying the target video memory address space, a physical reclamation operation is performed on the target video memory address space. In this way, continuously invalidated video memory address spaces can be accurately and effectively identified, and the video memory address space can be reclaimed in a timely manner by setting a first time period without interrupting application operation, thereby improving the utilization rate of video memory resources.
[0007] In one possible implementation, the method in the first aspect further includes: determining not to perform a physical reclamation operation on the target memory address space if the target memory address space is accessed during the first time period, or if the target memory address space does not meet the preset conditions. Access to the target memory address space during the first time period or the target memory address space meeting the preset conditions indicates that the target memory address space is in a normal state. This avoids problems such as illegal memory access errors, process crashes, access failures, or system anomalies triggered when accessing the target memory address space subsequently due to reclamation. Furthermore, when the target memory address space is accessed during the first time period, the timestamp of the access can be recorded to facilitate subsequent determination of whether the target memory address space is a continuously invalidally occupied memory address space.
[0008] In one possible implementation, when the idle duration of the target video memory address space is determined to be greater than the first threshold, the method of the first aspect further includes: setting the target video memory address space to a protected state; if a page fault occurs during the first time period, and if the page fault is caused by the protected state, then it is determined that the target video memory address space was accessed during the first time period. Thus, it is unnecessary to continuously poll or passively check the application's call logs, call stack information, or memory access records to determine whether access to the target video memory address space has occurred, thereby reducing detection overhead and accurately pinpointing the trigger time of each access that occurs while the target video memory address space is in a protected state.
[0009] In one possible implementation, the acquisition of the target video memory address space includes: acquiring the target video memory address space from a dataset whose free duration is greater than the first threshold, wherein the dataset includes at least one allocated video memory address space that has not been fully released; the method in the first aspect further includes: if a page fault occurs during the first time period, and if the page fault is not caused by the protection state of the target video memory address space, then deleting the relevant information of the video memory address space corresponding to the page fault from the dataset. Thus, when determining whether each video memory address space in the dataset is a continuously invalidally occupied video memory address space, the determination of the video memory address space corresponding to the page fault does not need to be performed, thereby reducing device power consumption.
[0010] In one possible implementation, the acquisition of the target memory address space includes: acquiring the target memory address space from a dataset whose free duration is greater than a first threshold, wherein the dataset includes at least one allocated memory address space that has not been fully released; the method in the first aspect further includes: if the page fault that occurs during the first time period is caused by the protected state, updating the rollback count to obtain the latest rollback count, wherein the latest rollback count is the sum of the most recent rollback count and 1, and the most recent rollback count is the total number of rollback events that have occurred in the memory address space of the dataset before the page fault occurred during the first time period; when the latest rollback count is greater than a preset number, extending the first threshold. A latest rollback count greater than a preset number indicates a high actual access activity of the memory address space in the dataset. Extending the first threshold in this case avoids frequent observation of the memory address space in the dataset, such as setting the memory address space to a protected state to determine whether there are page faults caused by the protected state, thereby reducing device power consumption.
[0011] In one possible implementation, the preset conditions include: the video memory address space has completed read and write operations, there is no corresponding asynchronous task flow in the video memory address space, no logical entity needs to use the video memory address space, and no other physical device operates the video memory address space through the hardware bus. This avoids access failures or system anomalies after performing physical reclamation on the target video memory address space, such as kernel crashes due to the GPU not being able to find the target video memory address space, memory out-of-bounds errors, system-level segmentation faults, or service interruptions caused by streams / events accessing the target video memory address space, thereby improving the security and reliability of physical reclamation of the video memory address space.
[0012] In one possible implementation, the value of the first threshold is negatively correlated with the amount of video memory used in the system where the target video memory address space is located. This allows for the prompt identification and release of continuously invalidally occupied video memory address space when system video memory usage is high, thereby quickly providing usable video memory address space to the system and ensuring the supply of video memory resources. This effectively avoids service anomalies caused by insufficient video memory resources, such as application crashes, failed inference requests, or forced process termination. Furthermore, when system video memory usage is low, the frequency of identifying and releasing continuously invalidally occupied video memory address space is reduced, thus lowering device power consumption.
[0013] Secondly, embodiments of this application provide a video memory address space processing device, comprising: an acquisition module, configured to acquire a target video memory address space, wherein the idle time of the target video memory address space is greater than a first threshold, and the idle time is used to indicate the duration during which the target video memory address space has not been accessed; and a processing module, configured to perform a physical reclamation operation on the target video memory address space if the target video memory address space meets a preset condition when the target video memory address space has not been accessed during a first time period, wherein the start time of the first time period is the time point at which the idle time of the target video memory address space is determined to be greater than the first threshold, and the target video memory address space meeting the preset condition indicates that the target video memory address space is currently unoccupied.
[0014] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory, the processor and the memory being connected; wherein the memory is used to store a program, and the processor is used to call the program stored in the memory to execute the method provided by the embodiments of the first aspect described above and / or some possible implementations of the embodiments of the first aspect described above.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when run by a processor, performs the method provided by the embodiments of the first aspect described above and / or some possible implementations of the embodiments of the first aspect described above.
[0016] Fifthly, embodiments of this application provide a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the method provided by the first aspect embodiment and / or some possible implementations of the first aspect embodiment. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application; Figure 2 A schematic diagram of the software architecture of the electronic device provided in the embodiments of this application; Figure 3 A flowchart illustrating the video memory address space processing method provided in an embodiment of this application; Figure 4 A timing diagram of the video memory address space processing method provided in the embodiments of this application; Figure 5 A schematic diagram illustrating the state transition of memory address space #1 provided in an embodiment of this application; Figure 6 A flowchart illustrating the first stage of an embodiment of this application; Figure 7 A schematic diagram of the second stage provided for an embodiment of this application; Figure 8 A flowchart illustrating the third stage provided for an embodiment of this application; Figure 9 This is a schematic diagram of a memory address space processing device provided in an embodiment of this application. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. The following embodiments are provided as examples to more clearly illustrate the technical solutions of this application, and should not be used to limit the scope of protection of this application. Those skilled in the art will understand that, without conflict, the following embodiments and features can be combined with each other.
[0020] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, relational terms such as "first," "second," etc., in the description of this application are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus.
[0021] Furthermore, the term "and / or" in this application is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0022] To address the aforementioned problem of severe waste of video memory resources, this application proposes that for target video memory address spaces with an idle duration greater than a first threshold, if the target video memory address space is not accessed during a first time period and it is determined that the target video memory address space is currently unoccupied, a physical reclamation operation is performed on the target video memory address space. In this way, continuously invalidally occupied video memory address spaces can be accurately and effectively identified, and the video memory address space can be reclaimed in a timely manner, thereby improving the utilization rate of video memory resources.
[0023] To facilitate understanding of the embodiments of this application, an electronic device that performs the memory address space processing method disclosed in the embodiments of this application will first be introduced.
[0024] like Figure 1 As shown, the aforementioned electronic device 100 may include a memory 110 and a processor 120, which are connected, such as through one or more communication buses or signal lines. The memory 110 is used to store programs; the processor 120 is used to call programs in the memory to execute video memory address space processing methods (described below).
[0025] The aforementioned memory 110 may include video memory and target memory other than the video memory. The target memory may also be random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0026] The aforementioned processor 120 may include a graphics processing unit (GPU) and a target processor other than the GPU. The target processor may be a central processing unit (CPU), a network processor (NP), an accelerated processing unit (accelerated processing unit), a multimedia application processor (MAP), a microprocessor, etc.; or it may be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA); or it may be other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components; or it may be any conventional processor, etc.
[0027] The aforementioned electronic devices 100 include, but are not limited to, mobile phones, computers, servers, etc.
[0028] The software architecture of the electronic device involved in the embodiments of this application is described below.
[0029] The software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application uses a layered architecture software system as an example to illustrate the software structure of an electronic device.
[0030] Layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. For example... Figure 2As shown, in some embodiments, the software system is divided into four layers, from top to bottom: the application layer, the application framework layer, the runtime and system libraries, and the kernel layer.
[0031] The application layer can include a series of application packages. For example... Figure 2 As shown, the application package may include applications such as camera, gallery, calendar, call, map, theme application, wireless local area network (WLAN), and music.
[0032] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions. For example... Figure 2 As shown, the application framework layer may include a window manager, a default database, a view system, a resource manager, etc.
[0033] The system library can include multiple functional modules, such as a surface manager, media libraries, a 3D graphics processing library, and a 2D graphics engine.
[0034] The kernel layer can include kernel drivers, display drivers, camera drivers, audio drivers, etc. Furthermore, an extended Berkeley Packet Filter (eBPF) program can be set within the kernel layer. This eBPF program can perform video memory address space processing methods (described below) without modifying the kernel source code or loading additional kernel modules. The specific principles of setting up an eBPF program in the kernel layer can be understood by referring to existing technologies, and will not be elaborated upon here.
[0035] Understandable Figure 2 The layers in the illustrated structure and the components contained in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the structure may include more or fewer layers than illustrated, and each layer may include more or fewer components; this application does not impose limitations.
[0036] The technical solutions in the embodiments of this application are described below with reference to the accompanying drawings.
[0037] Figure 3 This is a flowchart illustrating a memory address space processing method provided in an embodiment of this application. This memory address space processing method can be applied to the aforementioned electronic device. The electronic device includes a hardware system (such as a memory, processor, etc.) and a software system running thereon (such as...). Figure 2 The software system shown is described in detail in the foregoing description and will not be repeated here. In this application, unless otherwise specified, "system" refers to the electronic device.
[0038] like Figure 3 As shown, this method for processing video memory address space includes: S301, obtain the target video memory address space.
[0039] The video memory address space can be understood as the logical address range addressed by the GPU through the memory management unit (MMU) or the driver. The video memory address space is typically presented as a continuous range from a start address to an end address, and can be represented by a start address and an end address, or by a start address and a length. The video memory address space may be called a video memory region, video memory space, or other possible names, which are not limited in this application. It is understood that the specific principles of the video memory address space can be found in existing technologies, and will not be elaborated upon here.
[0040] The target video memory address space is an allocated (i.e., marked as occupied) and not fully freed video memory address space, and the idle time of the target video memory address space is greater than a first threshold. The target video memory address space can be a video memory address space in a dataset, that is, the target video memory address space can be obtained from the dataset. The dataset can be set in the system, and the dataset includes at least one video memory address space. Each video memory address space in the at least one video memory address space is in an allocated and not fully freed state.
[0041] The idle duration indicates the length of time the target video memory address space has not been accessed. In this embodiment, an application can submit commands (such as kernel execution) through a driver, which reference logical addresses in the video memory address space, allowing the GPU to access the video memory address space at runtime based on those logical addresses. The aforementioned "target video memory address space not accessed" could mean that the target video memory address space has not been accessed by the application, or it could mean that the target video memory address space has not been accessed by the GPU.
[0042] The idle time is the time from the last time the target memory address space was accessed (referred to as the first time point) to the time when the target memory address space was acquired (referred to as the second time point). In other words, the idle time can be determined based on the first time point and the second time point.
[0043] The first time point can be determined using pre-configured tools. For example, the system can use profiling tools to capture GPU events, including memory transfers and kernel execution, and record the timestamp when the target video memory address space is accessed. Alternatively, the system can determine the first time point by monitoring the interface of the direct rendering manager (DRM) subsystem in the kernel space. The DRM is a core module in the kernel responsible for managing communication with the GPU. It receives requests from user space (such as memory allocation and command submission) and performs security checks and resource scheduling. The specific principles of the DRM can be found in existing technologies and will not be elaborated here.
[0044] For example, during the normal access phase of the system, when an application calls cudaMemcpy to initiate data transfer, this call is first processed by the user-space compute unified device architecture (CUDA) library, and then enters the kernel via an input / output control (ioctl) system call, entering the DRM subsystem. During this process, an eBPF probe can attach to relevant functions (such as ioctl entry points, DRM handling functions, or lower-level driver paths), thereby intercepting and observing information about events on the call chain (such as call stacks, timestamps, process context, etc.) without modifying the kernel code. This allows the probe to obtain the identification information (such as start and end addresses) and current timestamp corresponding to the target memory region. This timestamp can be considered the time point when that memory address space was last accessed (i.e., the first time point). Furthermore, during the normal access phase of the system, after intercepting each event, the eBPF probe can record or update the aforementioned dataset. Specifically, if the memory address space corresponding to the event already exists in the dataset, then the relevant information (such as timestamp) of the memory address space in the dataset is updated based on the event; if the memory address space corresponding to the event does not exist in the dataset, then the relevant information of the memory address space is added to the dataset based on the event.
[0045] The second time point can be the time point at which the system begins to determine whether the idle time of the target video memory address space is greater than the first threshold.
[0046] After obtaining the first and second time points mentioned above, the system can calculate the difference between the first and second time points to obtain the idle time of the target video memory address space.
[0047] The value of the first threshold can be set according to the actual situation. For example, the value of the first threshold is negatively correlated (inversely correlated) with the amount of video memory used in the system where the target video memory address space is located. For example, when the video memory usage in the system is greater than 85% (high-voltage environment), the first threshold can be set to 30 seconds; when the video memory usage in the system is less than or equal to 85% and greater than 60% (medium-voltage environment), the first threshold can be set to 60 seconds; when the video memory usage in the system is less than or equal to 60% (low-voltage environment), the first threshold can be set to 180 seconds. By making the value of the first threshold negatively correlated with the amount of video memory used in the system, when the video memory usage in the system is high, the continuously invalid video memory address space can be identified and released as soon as possible. This can provide the system with usable video memory address space as quickly as possible, ensuring the supply of video memory resources in the system. This can effectively avoid service anomalies caused by insufficient video memory resources, such as application crashes, inference request failures, or forced process termination. Furthermore, when the video memory usage in the system is low, the frequency of identifying and releasing continuously invalid video memory address space can be reduced, thereby reducing device power consumption.
[0048] In this embodiment, before acquiring the target memory address space, the system can first determine whether the memory address space to be processed is the target memory address space. The memory address space to be processed is an allocated (i.e., marked as occupied) memory address space that has not been fully released. For example, the system can acquire the idle time of the memory address space to be processed and determine whether the idle time is greater than a first threshold. If the idle time of the memory address space to be processed is greater than the first threshold, then the memory address space to be processed is taken as the target memory address space. At this time, the system can change the identifier of the memory address space to be processed from "normal" to "suspected". If the idle time of the memory address space to be processed is less than or equal to the first threshold, then the memory address space to be processed is determined to be in a normal state. At this time, the identifier of the memory address space to be processed can remain unchanged as "normal". It can be understood that the memory address space to be processed can be a memory address space in the aforementioned dataset, or in other words, the aforementioned dataset includes at least one memory address space to be processed.
[0049] S302, if the target memory address space is not accessed during the first time period, and if the target memory address space meets the preset conditions, then perform a physical reclamation operation on the target memory address space.
[0050] The first time period begins when the system determines that the idle time of the target video memory address space exceeds a first threshold. The duration of the first time period can be set according to actual conditions. For example, the duration of the first time period is negatively correlated with the video memory usage in the system where the target video memory address space is located. For instance, under high voltage conditions, the duration of the first time period can be set to 45 seconds; under medium voltage conditions, the duration of the first time period can be set to 75 seconds; and under low voltage conditions, the duration of the first time period can be set to 105 seconds. The descriptions of high voltage, medium voltage, and low voltage environments are provided above and will not be repeated here. In this way, when the video memory usage in the system is high, continuously invalidally occupied video memory address space can be identified and released as quickly as possible, thereby providing the system with usable video memory address space as soon as possible and ensuring the supply of video memory resources in the system.
[0051] The target memory address space meeting the preset conditions indicates that the target memory address space is currently unoccupied or unused. The target memory address space being unoccupied can be understood as follows: the target memory address space has been allocated and has carried valid computation or data transmission, but currently no instructions are accessing it for reading or writing; or, the target memory address space has been separately and actually used, but currently there are no access operations.
[0052] Performing a physical reclamation operation on the target video memory address space can be understood as releasing the physical video memory resources corresponding to the target video memory address space. After releasing the target video memory address space, it changes from an occupied state to a free state that can be reallocated. Furthermore, when the target video memory address space is obtained from a dataset, performing a physical reclamation operation on the target video memory address space can delete the relevant information about the target video memory address space from the dataset, thus preventing subsequent operations on whether the target video memory address space is continuously and invalidally occupied.
[0053] In this embodiment, when the system determines that the idle time of the target memory address space is greater than a first threshold, it can continue to observe whether any application or GPU accesses the target memory address space within a first time period. For example, the system can observe events on the call chain using an eBPF probe and determine whether the target memory address space has been accessed based on the events. Alternatively, the system can set the target memory address space to a protected state so that it receives a notification when an application or GPU accesses the target memory address space.
[0054] If no application or GPU accesses the target memory address space within the first time period, the system can determine whether the target memory address space meets preset conditions. If the target memory address space meets the preset conditions, a physical reclamation operation is performed on the target memory address space. Furthermore, when the system determines that the target memory address space meets the preset conditions, it can change the target memory address space's identifier to "dead," meaning the target memory address space is in a dead state. When the target memory address space is in a dead state, the system performs a physical reclamation operation on the target memory address space. After performing the physical reclamation operation on the target memory address space, the system can change the target memory address space's identifier from "dead" to "released," meaning the target memory address space is in a released state and can be reallocated.
[0055] In summary, in this embodiment, by acquiring a target memory address space with an idle duration greater than a first threshold and observing the target memory address space for a first time period, if no application or GPU accesses the target memory address space after the observation ends, and the target memory address space is currently unused, it is determined that the target memory address space is continuously and ineffectively occupied, and a physical reclamation operation is performed on the target memory address space. In this way, continuously ineffectively occupied memory address spaces can be accurately and effectively identified, and the memory address space can be reclaimed in a timely manner, thereby improving the utilization rate of memory resources.
[0056] Optionally, in conjunction with the above embodiments, the method may further include: determining not to perform a physical reclamation operation on the target memory address space when it is accessed during the first time period. The fact that the target memory address space is accessed by an application or GPU during the first time period indicates that the target memory address space is not continuously and invalidally occupied; that is, the target memory address space is being read and written by an application, meaning the target memory address space is in a normal state. By determining that the target memory address space is in a normal state and not performing a physical reclamation operation on it, problems such as illegal memory access errors or process crashes may be triggered when the target memory address space is subsequently accessed due to reclamation.
[0057] In addition, after the target video memory address space is accessed in the first time period, the time point when the target video memory address space is accessed can be recorded so as to determine whether the target video memory address space is a video memory address space that is continuously and invalidally occupied.
[0058] When the system determines that the idle time of the target video memory address space is greater than a first threshold, the above method may further include: setting the target video memory address space to a protected state; if a page fault occurs during the first time period, and the page fault is caused by the protected state, then it is determined that the target video memory address space was accessed during the first time period.
[0059] Setting the target memory address space to a protected state can be understood as: setting the access permissions of the target memory address space to inaccessible, or setting both read and write permissions of the target memory address space to prohibited. In the protected state, any operation (read or write) on the target memory address space from an application (or GPU) is not allowed. When the target memory address space is set to a protected state, a page fault will be triggered when an application or GPU accesses the target memory address, and this page fault can be caught by the kernel driver. In this embodiment, the system can call the driver protection interface to set the target memory address space to a protected state. Furthermore, when setting the target memory address space to a protected state, the identifier of the target memory address space can be changed from "suspected" to "soft_locked," at which point the target memory address space is in a soft_locked state. It can be understood that the specific principle of setting the memory address space to a protected state by calling the driver protection interface can refer to existing technologies.
[0060] When a page fault occurs within the first time period, the system can obtain relevant information about the page fault (such as the fault address and context) and, based on this information, determine whether the page fault was caused by the protection status of the target memory address space. If the page fault was caused by the protection status of the target memory address space, it indicates that an application or GPU is currently accessing the target memory address, thus confirming that the target memory address space was accessed within the first time period. In this case, the system can clear the protection flag of the target memory address space, making it no longer protected, and can wake up the target memory address space, making it await access operations. Furthermore, if the current flag of the target memory address space is "soft isolated," the flag is changed from "soft isolated" to "normal."
[0061] Furthermore, when the system obtains information related to the page fault (such as the fault address and context), it can first determine whether the fault address belongs to the target video memory address space. If the fault address belongs to the target video memory address space, it further determines whether the page fault is caused by the protection status of the target video memory address space. If the fault address does not belong to the target video memory address space, it determines that the page fault is not caused by the protection status of the target video memory address space.
[0062] In this embodiment, the target video memory address space is set to a protected state, and a page fault is used as the event triggering mechanism. This eliminates the need to continuously poll or passively check the application's call logs, call stack information, or memory access records to determine whether an access to the target video memory address space has occurred. This reduces detection overhead and allows for precise location of the triggering time of each access that occurs while the target video memory address space is in a protected state.
[0063] Furthermore, the above-mentioned acquisition of the target video memory address space may specifically include: acquiring the target video memory address space whose free duration is greater than a first threshold from the dataset; the above method may also include: if a page fault occurs within the first time period, and if the page fault is not caused by the protection status of the target video memory address space, then the relevant information of the video memory address space corresponding to the page fault is deleted from the dataset.
[0064] The dataset includes at least one allocated but not fully freed video memory address space. This dataset can be referred to in section S301, and will not be repeated here. The system can compare the idle time of the video memory address space in the dataset with a first threshold, and select the video memory address space whose idle time is greater than the first threshold as the target video memory address space.
[0065] A page fault not caused by the protected state of the target memory address space can be understood as being caused by other reasons (such as access errors, illegal addresses, or out-of-bounds addresses).
[0066] The memory address space corresponding to a page fault can be understood as the memory address space that the GPU attempts to access when a page fault occurs, i.e., the memory address space to which the aforementioned fault address belongs. Information related to the memory address space corresponding to a page fault can include: the address information corresponding to that memory address space (such as the start and end addresses), and the timestamp of the most recent access.
[0067] In this embodiment, if a page fault occurs within the first time period due to reasons other than the protected state of the target memory address space, it indicates that the memory address space corresponding to the page fault is abnormal. In this case, the relevant information of the memory address space is deleted from the dataset, so that there is no longer any information about the memory address space in the dataset. This allows the system to determine whether each memory address space in the dataset is a continuously invalidally occupied memory address space without judging the memory address space corresponding to the page fault (i.e., the abnormal memory address space), thereby reducing device power consumption. Furthermore, if the memory address space corresponding to the page fault is the target memory address space, the system can terminate operations on the target memory address space at this time.
[0068] Furthermore, the above-mentioned acquisition of the target video memory address space may specifically include: acquiring the target video memory address space whose free duration is greater than a first threshold from the dataset; the above method may also include: if the page fault exception that occurs within the first time period is caused by the protection state of the target video memory address space, updating the rollback count to obtain the latest rollback count; when the latest rollback count is greater than a preset count, extending the first threshold.
[0069] The updated rollback count can be understood as: adding 1 to the most recent rollback count to get the latest rollback count. In other words, the latest rollback count is the sum of the most recent rollback count and 1.
[0070] The most recent rollback count is the total number of rollback events that have occurred in the memory address space of the dataset before a page fault occurs in the target memory address space. This dataset includes at least one allocated but not fully freed memory address space; details can be found in the preceding descriptions, which will not be repeated here. A rollback event can be understood as: when it is determined that a page fault (or other equivalent exception) is caused by the protected state of the memory address space, determining not to perform a physical reclamation operation on that memory address space; or, when it is determined that a page fault (or other equivalent exception) is caused by the protected state of the memory address space, removing the protection state of that memory address space and changing its identifier from "soft isolated" to "normal".
[0071] In this embodiment, the system can determine whether the idle time of each video memory address space in the dataset exceeds a first threshold, set a protection state for target video memory address spaces with idle time exceeding the first threshold, and observe whether there are page faults caused by the protection state of the target video memory address space during a first time period. If such a page fault occurs, a rollback event is determined to have occurred, and the rollback count is updated based on the rollback event. When the latest rollback count is greater than a preset count, it indicates that a large number of target video memory address spaces have been accessed during the first time period, i.e., the actual access activity of the video memory address spaces is high. In this case, by extending the first threshold, frequent observation of the video memory address spaces in the dataset can be avoided, thereby reducing device power consumption; and frequent rollback operations on the video memory address spaces in the dataset can be avoided, thereby reducing interference with application operation.
[0072] Optionally, in conjunction with the above embodiments, the method may further include: if the target video memory address space does not meet the preset conditions, determining not to perform a physical reclamation operation on the target video memory address space.
[0073] The fact that the target video memory address space does not meet the preset conditions indicates that the target video memory address space is currently occupied or in use. The target video memory address space being currently occupied can be understood as: the target video memory address space is performing a read or write operation; or, the target video memory address space is about to be used, such as if there is a corresponding asynchronous task flow in the target video memory address space.
[0074] In this embodiment, when the target memory address space does not meet the preset conditions, no physical reclamation operation is performed on the target memory address space. This avoids problems such as access failure or system abnormalities when accessing the target memory address space subsequently due to reclamation of the target memory address space. When the target memory address space is accessed, the system can update or record the timestamp of the access to the target memory address space, even if the target memory address space does not meet the preset conditions.
[0075] Furthermore, the system can periodically determine whether there is continuously invalidally occupied video memory address space. For example, it can periodically check the video memory address space in the dataset and reclaim the video memory address space when it is determined to be continuously invalidally occupied. In this case, if the target video memory address space does not meet the preset conditions, the system can also determine in the next cycle whether the latest idle time of the target video memory address space is greater than a first threshold, and execute the above method if the idle time is greater than the first threshold.
[0076] Optionally, in conjunction with the above embodiments, the preset conditions include: the video memory address space has completed read and write operations, there is no corresponding asynchronous task flow in the video memory address space, no logical entity needs to use the video memory address space, and no other physical device operates the video memory address space through the hardware bus.
[0077] The completion of read / write operations in the video memory address space can be understood as follows: data transfer in the video memory address space has ended, meaning there are no outstanding operations in the video memory address space; or, in other words, all video memory synchronization instructions involved in the video memory address space have been executed. The system can determine whether read / write operations in the video memory address space have been completed through a synchronization queue verification operation. This synchronization queue verification operation can determine whether all pending read / write operations on a specified video memory address space (including GPU commands submitted in the queue previously) have been executed.
[0078] The absence of a corresponding asynchronous task flow in the video memory address space can be understood as follows: the video memory address space is not referenced / accessed by any currently executing or soon-to-be-executed asynchronous task; or, in other words, no suspended operation in the GPU's asynchronous task flow points to that video memory address space. The system can determine whether a corresponding asynchronous task flow exists in the video memory address space by performing a stream / event refresh operation on all streams / events in the system.
[0079] The statement "No logical entity needs to use the video memory address space" can be understood as: there is currently no logical entity that declares, holds, or intends to access the video memory address space in any form; or, in other words, no middleware or library file holds a handle to that video memory address space. The system can determine whether any logical entity needs to use the video memory address space through a reference counting check.
[0080] The statement "No other physical device is operating on the video memory address space via the hardware bus" can be understood as follows: On the hardware bus of the current electronic device, apart from the GPU itself that is currently managing the video memory, no other local or cross-device physical device (such as the CPU, other homogeneous or heterogeneous GPUs, etc.) is performing read / write operations on the video memory address space via the hardware bus. The system can monitor operations using Remote Direct Memory Access (RDMA) / Unified Virtual Addressing (UVM) to determine whether other physical devices are operating on the video memory address space via the hardware bus.
[0081] The specific principles of the above-mentioned synchronization queue verification operation, stream / event refresh operation, count check, and RDMA / UVM monitoring operation can be found in existing technologies and will not be elaborated here.
[0082] In this embodiment, the system can execute the above four operations in a preset order. If any one of the operations fails, the check on the target video memory address space is stopped, and it is determined that the target video memory address space does not meet the preset conditions. The preset order can be: synchronization queue verification operation, stream / event refresh operation, count check, and RDMA / UVM monitoring operation; or, the preset order can be RDMA / UVM monitoring operation, synchronization queue verification operation, stream / event refresh operation, and count check.
[0083] By setting the preset conditions to ensure that the video memory address space has completed read and write operations, there is no corresponding asynchronous task flow in the video memory address space, no logical entity needs to use the video memory address space, and no other physical devices operate the video memory address space through the hardware bus, access failures or system anomalies can be avoided after physical reclamation of the target video memory address space. For example, the GPU may not be able to find the target video memory address space, causing kernel crashes, or streams / events may cause memory out-of-bounds errors, system-level segmentation faults, or service interruptions when accessing the target video memory address space. This improves the security and reliability of physical reclamation of the video memory address space.
[0084] Optionally, in conjunction with the above embodiments, the electronic device includes a processor that executes the above method by running an eBPF program.
[0085] For example, the electronic device runs a Linux operating system whose kernel supports eBPF. The method in this embodiment is written as one or more eBPF program files (e.g., written in C language and compiled into eBPF bytecode). User-space tools (such as bpftool or a self-developed loader) load the eBPF bytecode into the kernel and attach it to specified hooks (such as memory access trace points, system call entry points, or device interrupt handlers). When the triggering condition is met, the kernel executes the eBPF bytecode, thereby completing the operations described in this embodiment. Based on this, although the execution subject of this embodiment is an electronic device, the specific logic is executed efficiently and securely in kernel mode through eBPF programs.
[0086] Implementing the above method using eBPF programs requires no modification to the kernel source code and no loading of additional kernel modules. The eBPF bytecode is dynamically mounted to predetermined hook points in the kernel layer to take effect. This avoids the system restart risks associated with kernel recompilation or module insertion, reduces the complexity of developing and debugging kernel-mode programs, and significantly improves the deployment efficiency and operational stability of the method.
[0087] It is understood that the various method steps described in the embodiments of this application can also be implemented by software, hardware or firmware, and can be flexibly set according to the actual situation.
[0088] The above content provides an overview of methods for handling video memory address space. For ease of understanding, the following section will combine... Figures 4 to 5 This paper will use a specific example to illustrate the method of processing video memory address space.
[0089] In the kernel mode of the electronic device, eBPF maps (corresponding to the aforementioned dataset) are set up. These eBPF maps serve as a shared storage area between kernel mode and user mode, used to store state data and collected information during the execution of the eBPF program. These eBPF maps store allocated (i.e., marked as occupied) but not fully released video memory address space; and the video memory address space in these eBPF maps is in a normal state, meaning it is marked as "normal". For example, such as... Figure 4As shown, during the normal access phase, when an application in the application layer (i.e., the aforementioned application layer) calls cudaMemcpy to initiate data transfer, the kernel driver can call ioctl. During this process, the eBPF probe can be attached to the relevant function, thereby intercepting and observing information about events on the call chain without modifying the kernel code. After capturing the relevant parameters of cudaMemcpy, the eBPF program can parse the target memory address and update or add the target memory address and its corresponding timestamp (i.e., update the eBPF mapping) in the eBPF mapping. This timestamp represents the time point when the target memory address was last accessed. The kernel driver submits a memory operation to the GPU hardware (including the target memory address space #1) so that the GPU hardware can execute the operation. Furthermore, after the memory address space in the dataset is released (physically reclaimed), all information in that memory address space in the dataset can be deleted; that is, the dataset will no longer include that memory address space.
[0090] The eBPF program periodically determines whether each video memory address space in the eBPF mapping is a continuously invalidated video memory address space, and physically reclaims the determined continuously invalidated video memory address spaces. For example, in any given period, the eBPF program first determines whether video memory address space #1 (any video memory address space in the eBPF mapping) is likely to be a continuously invalidated video memory address space (referred to as the first stage); if video memory address space #1 is likely to be a continuously invalidated video memory address space, it observes video memory address space #1 (referred to as the second stage); after the observation period for video memory address space #1 has passed, it determines whether to physically reclaim video memory address space #1 (referred to as the third stage). For ease of understanding, the following will combine... Figures 4 to 8 The three stages mentioned above will be introduced separately.
[0091] like Figure 6 As shown, the process for the first stage is as follows: S601, the eBPF program calculates the idle time of video memory address space #1.
[0092] S602, the eBPF program determines whether the idle time of video memory address space #1 is greater than the first threshold.
[0093] S603: When the idle time of video memory address space #1 is less than or equal to the first threshold, maintain the "normal" flag of video memory address space #1.
[0094] In other words, in this case, the eBPF program does not change the "normal" flag of video memory address space #1, and video memory address space #1 is in a normal state.
[0095] S604, when the idle time of video memory address space #1 is greater than the first threshold, the eBPF program marks video memory address space #1 as "suspected".
[0096] In other words, the eBPF program changes the identifier of video memory address space #1 from "normal" to "suspected". At this time, video memory address space #1 is in a suspected state.
[0097] When the eBPF program determines that the idle time of video memory address space #1 is greater than the first threshold, video memory address space #1 enters the second stage.
[0098] like Figure 7 As shown, the process for the second stage is as follows: S701, the eBPF program calls the driver protection interface to set the video memory address space #1 to a protected state.
[0099] In this embodiment, the eBPF program calls the protection interface to set soft isolation for memory address space #1 via the kernel driver. After setting soft isolation for memory address space #1, the eBPF program changes the identifier of memory address space #1 from "suspected" to "soft isolated," at which point memory address space #1 is in a soft isolated state. The second stage corresponds to the first time period mentioned above.
[0100] S702, when no application accesses video memory address space #1 in the second stage, prepare to perform physical reclamation operation on video memory address space #1.
[0101] That is, if no application accesses video memory address space #1 during the second stage, video memory address space #1 enters the third stage. The specific process of the third stage is described below.
[0102] S703, a page fault occurred in the second stage.
[0103] For example, in the second phase, an application accesses the protected video memory address space #1. At this point, the kernel driver can detect a page fault.
[0104] S704, the kernel driver determines whether the page fault is caused by the protection state of video memory address space #1.
[0105] S705 initiates a momentary rollback if the page fault is caused by the protection state of video memory address space #1.
[0106] If the page fault is caused by the protected state of video memory address space #1, a rollback event can also be recorded, as detailed in S708 to S711 below.
[0107] S706, the kernel driver clears the protection state of video memory address space #1 and wakes up video memory address space #1 to wait for access.
[0108] At this point, the eBPF program can change the identifier of video memory address space #1 from "soft isolated" to "normal," thus putting video memory address space #1 into a normal state, allowing the execution of the original access instruction (i.e., the instruction that triggered the page fault). This operation enables the application to seamlessly resume the use of video memory address space #1.
[0109] S707, if the page fault is not caused by the protected state of video memory address space #1, the eBPF program deletes the relevant information of the video memory address space corresponding to the page fault in the eBPF mapping.
[0110] In this situation, the system can handle the exception according to the handling method corresponding to page fault exceptions.
[0111] S708, eBPF program records rollback events.
[0112] In other words, the eBPF program updates the rollback count based on the rollback event of video memory address space #1.
[0113] S709, the eBPF program determines whether the number of rollbacks exceeds the preset number.
[0114] S710, when the number of rollbacks exceeds the preset number, the eBPF program extends the first threshold.
[0115] S711, when the number of rollbacks is less than or equal to the preset number, the eBPF program ends the relevant operations of the rollback event.
[0116] That is, the first threshold is not processed at this time.
[0117] like Figure 8 As shown, the process for the third stage is as follows: S801, the eBPF program performs a synchronization queue check operation on video memory address space #1.
[0118] S802, after the synchronization queue verification operation in video memory address space #1, the eBPF program performs a stream / event refresh operation on video memory address space #1.
[0119] S803, after the video memory address space #1 is refreshed by a stream / event, the eBPF program performs a count check on the video memory address space #1.
[0120] After the count check is completed in video memory address space #1, the eBPF program performs RDMA / UVM monitoring operation on video memory address space #1.
[0121] After the S805 performs an RDMA / UVM monitoring operation on memory address space #1, the kernel driver performs physical reclamation on memory address space #1.
[0122] After the RDMA / UVM monitoring operation is completed in memory address space #1, that is, when all four of the above checks are passed, the eBPF program can change the identifier of memory address space #1 from "soft isolation" to "invalid", so that memory address space #1 is in an invalid state. At this time, the kernel driver can perform physical reclamation on memory address space #1 based on the fact that memory address space #1 is in an invalid state.
[0123] After the kernel driver performs physical reclamation on video memory address space #1, the eBPF program can change the flag of video memory address space #1 from "invalid" to "free". At this time, video memory address space #1 is in a freed state, meaning that video memory address space #1 can be reallocated.
[0124] S806: If the video memory address space #1 fails to pass the synchronization queue check operation, stream / event refresh operation, count check, or RDMA / UVM monitoring operation, the eBPF program cancels the reclamation operation of the video memory address space #1.
[0125] In this case, when the eBPF program determines whether each video memory address space in the eBPF mapping is a video memory address space that is continuously occupied invalidally in the next cycle, it can re-determine the video memory address space #1 and execute the above method (each operation in the first to third stages).
[0126] It is understood that the specific implementation of the above embodiments can refer to the foregoing. Figure 3 The relevant descriptions in the illustrated embodiments are for reference only and will not be repeated here.
[0127] Based on the same inventive concept, embodiments of this application also provide a video memory address space processing device, which is applied to an electronic device. Please refer to... Figure 9 , Figure 9 This is a schematic diagram of a video memory address space processing device provided in an embodiment of this application. The video memory address space processing device 900 includes: an acquisition module 910 and a processing module 920.
[0128] The acquisition module 910 is used to acquire the target video memory address space. The idle time of the target video memory address space is greater than a first threshold. The idle time is used to indicate the duration during which the target video memory address space has not been accessed.
[0129] The processing module 920 is used to perform a physical reclamation operation on the target video memory address space if the target video memory address space is not accessed during the first time period and if the target video memory address space meets the preset conditions. The start time of the first time period is the time point at which the idle time of the target video memory address space is determined to be greater than a first threshold. The target video memory address space meeting the preset conditions indicates that the target video memory address space is currently not occupied.
[0130] In one possible implementation, the processing module 920 is also used to determine not to perform a physical reclamation operation on the target video memory address space if the target video memory address space is accessed in the first time period, or if the target video memory address space does not meet the preset conditions.
[0131] In one possible implementation, when the idle time of the target video memory address space is determined to be greater than a first threshold, the processing module 920 is further configured to set the target video memory address space to a protected state; if a page fault occurs during the first time period, and if the page fault is caused by the protected state, then it is determined that the target video memory address space was accessed during the first time period.
[0132] In one possible implementation, the acquisition module 910 is specifically used to acquire a target video memory address space whose free duration is greater than a first threshold from the dataset, the dataset including at least one allocated video memory address space that has not been fully released; the processing module 920 is also used to delete the relevant information of the video memory address space corresponding to the page fault from the dataset if the page fault is not caused by the protected state when a page fault occurs within the first time period.
[0133] In one possible implementation, the acquisition module 910 is specifically used to acquire target memory address spaces with a free duration greater than a first threshold from the dataset, the dataset including at least one allocated memory address space that has not been fully released; the processing module 920 is further used to update the rollback count when the page fault that occurs in the first time period is caused by the protected state, to obtain the latest rollback count, the latest rollback count being the sum of the most recent rollback count and 1, the most recent rollback count being the total number of rollback events that have occurred in the memory address space of the dataset before the page fault occurred in the first time period; when the latest rollback count is greater than a preset number, the first threshold is extended.
[0134] In one possible implementation, the preset conditions include: the video memory address space has been read and written, there is no corresponding asynchronous task flow in the video memory address space, no logical entity needs to use the video memory address space, and no other physical device operates the video memory address space through the hardware bus.
[0135] In one possible implementation, the value of the first threshold is negatively correlated with the amount of video memory used in the system where the target video memory address space is located.
[0136] In one possible implementation, the electronic device includes a processor that executes a video memory address space processing method by running an eBPF program.
[0137] This application also provides a computer-readable storage medium (hereinafter referred to as the storage medium) storing a computer program, which, when run by a processor, executes the above-described method.
[0138] This application also provides a computer program product, which includes a computer program that, when executed by a computer, implements the above-described method.
[0139] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0140] The above detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0141] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0142] In the description of this application, it should also be noted that, unless otherwise expressly specified and limited, the term "connection" should be interpreted broadly. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be a connection within two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0143] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part. If the function is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions to cause a computer device (which may be a personal computer, laptop, server, or electronic device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned computer-readable storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0144] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for processing video memory address space, characterized in that, The method includes: Obtain the target video memory address space, wherein the idle time of the target video memory address space is greater than a first threshold, and the idle time is used to indicate the duration during which the target video memory address space has not been accessed; If the target memory address space is not accessed during the first time period, and if the target memory address space meets a preset condition, then a physical reclamation operation is performed on the target memory address space. The start time of the first time period is the time point at which the idle time of the target memory address space is determined to be greater than the first threshold. The target memory address space meeting the preset condition indicates that the target memory address space is currently not occupied.
2. The method according to claim 1, characterized in that, The method further includes: If the target memory address space is accessed during the first time period, or if the target memory address space does not meet the preset conditions, it is determined that no physical reclamation operation will be performed on the target memory address space.
3. The method according to claim 2, characterized in that, When it is determined that the idle time of the target video memory address space is greater than the first threshold, the method further includes: Set the target video memory address space to a protected state; If a page fault occurs during the first time period, and the page fault is caused by the protection status, then it is determined that the target video memory address space was accessed during the first time period.
4. The method according to claim 3, characterized in that, The acquisition of the target video memory address space includes: The target video memory address space is obtained from the dataset where the free duration of the video memory address space is greater than the first threshold, and the dataset includes at least one allocated video memory address space that has not been fully released. The method further includes: If a page fault occurs during the first time period, and if the page fault is not caused by the protection state, then the relevant information of the video memory address space corresponding to the page fault is deleted from the dataset.
5. The method according to claim 3, characterized in that, The acquisition of the target video memory address space includes: The target video memory address space is obtained from the dataset where the free duration of the video memory address space is greater than the first threshold, and the dataset includes at least one allocated video memory address space that has not been fully released. The method further includes: If the page fault that occurs during the first time period is caused by the protection state, the rollback count is updated to obtain the latest rollback count. The latest rollback count is the sum of the most recent rollback count and 1. The most recent rollback count is the total number of rollback events that have occurred in the video memory address space of the dataset before the page fault occurs during the first time period. When the latest rollback count exceeds a preset count, the first threshold is extended.
6. The method according to any one of claims 1-5, characterized in that, The preset conditions include: the video memory address space has completed read and write operations, there is no corresponding asynchronous task flow in the video memory address space, no logical entity needs to use the video memory address space, and no other physical device operates the video memory address space through the hardware bus.
7. The method according to any one of claims 1-5, characterized in that, The value of the first threshold is negatively correlated with the amount of video memory used in the system where the target video memory address space is located.
8. A video memory address space processing device, characterized in that, The device includes: The acquisition module is used to acquire the target video memory address space, wherein the idle time of the target video memory address space is greater than a first threshold, and the idle time is used to indicate the duration during which the target video memory address space has not been accessed. The processing module is configured to perform a physical reclamation operation on the target video memory address space if the target video memory address space meets a preset condition when the target video memory address space is not accessed during a first time period. The start time of the first time period is the time point at which the idle time of the target video memory address space is determined to be greater than the first threshold. The target video memory address space meeting the preset condition indicates that the target video memory address space is currently not occupied.
9. An electronic device, characterized in that, include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs; The processor is configured to invoke a program stored in the memory to execute the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by a processor, performs the method as described in any one of claims 1-7.
11. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-7.