Computer video memory sharing method, device, equipment and storage medium
By dividing and managing the video memory physical pages, the sharing of video memory resources and the unification of memory are achieved, the waste of idle video memory resources is solved, and the storage space utilization rate of computer systems and the overall efficiency of hardware resources are improved.
Patent Information
- Application Number
- CN202510771694.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2045-06-11
AI Technical Summary
The prior art is difficult to efficiently utilize the storage space of computer systems, especially the large amount of video memory resources is idle in non-graphic rendering scenarios, affecting the utilization rate of hardware resources and the cost of the whole machine.
By obtaining the usage status of video memory in real time, dividing idle resources into physical pages, and attaching them to the kernel partner system, sharing in response to memory requests, monitoring video memory/cache data synchronization, realizing unified management and resource sharing between video memory and memory.
It improves the efficient utilization of computer system storage space, reduces external fragmentation of video memory, optimizes hardware resource utilization and reduces dependence on physical memory.
Smart Images

Figure CN120276874B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a computer video memory sharing method, apparatus, device, and storage medium. Background Art
[0002] In personal computer systems, main memory (RAM) and video memory (GPU memory) are two key data storage components. As the core data storage area for computer system operation, main memory is primarily responsible for temporarily storing program code and data required by the CPU (central processing unit). It offers high-speed read and write speeds and strong versatility, making it essential for ensuring smooth computer system operation. Video memory is a high-speed storage device designed specifically for graphics processing units (GPUs). It is used to store data such as textures and frame buffers required for graphics rendering. Its unique architecture meets the GPU's demanding requirements for high-bandwidth, low-latency data access, providing strong support for high-quality graphics rendering and complex computing tasks. Main memory and video memory typically operate in relatively independent environments due to differences in hardware architecture and data management.
[0003] In current PC hardware configurations, graphics cards typically have a memory capacity between 2GB and 32GB. However, in non-graphics rendering scenarios (such as daily office work and web browsing), memory utilization is often low, leaving a significant amount of memory resources idle. Furthermore, host manufacturers spend up to 10%-20% of their system's total cost on system memory, making it a significant factor influencing overall pricing. If idle video memory could be dynamically shared with the host system through technical means, allowing it to be used as general-purpose memory, this would not only improve hardware resource utilization but also reduce the system's reliance on physical memory modules, thereby optimizing the cost structure.
[0004] Under current technological conditions, data exchange between the two requires collaboration through specific hardware interfaces (such as the PCIe bus) and software protocols (such as DMA). However, this collaborative approach makes it difficult to ensure data consistency and still struggles to efficiently utilize the computer system's storage space. Summary of the Invention
[0005] The embodiments of the present application solve the problem that the existing technology makes it difficult to efficiently utilize the storage space of a computer system by providing a computer video memory sharing method, apparatus, device and storage medium.
[0006] In a first aspect, an embodiment of the present application provides a computer video memory sharing method, comprising: acquiring the usage status of the video memory in real time to determine the idle resources therein; dividing the idle resources in the video memory into physical pages, and attaching the divided multiple shared physical pages to a kernel partner system; requesting the shared physical pages from the kernel partner system in response to a memory request; sending a video memory request to release the divided shared physical pages based on the usage status of the video memory; monitoring the video memory / cache, and when the video memory / cache data changes, sending corresponding data to the cache / video memory to achieve data synchronization between the cache and the video memory.
[0007] In combination with the first aspect, in a possible implementation, the idle resources in the video memory are divided into physical pages, and the divided multiple shared physical pages are attached to the kernel partner system, including: dividing the idle resources in the video memory into physical pages according to the size of the physical pages defined by the computer system to obtain multiple shared physical pages; and attaching the shared physical pages to the physical page linked list of the kernel partner system based on the rules of the kernel partner system.
[0008] In combination with the first aspect, in a possible implementation, the requesting the shared physical page from the kernel partner system in response to the memory request includes: when the available resources of the video memory are lower than a set threshold, rejecting the memory request; when the available resources of the video memory reach the set threshold, allocating the required shared physical page according to the memory request.
[0009] In combination with the first aspect, in a possible implementation, sending a video memory application request to release the divided shared physical page based on the usage status of the video memory includes: when the available resources in the usage status of the video memory obtained in real time are sufficient, rejecting the video memory application request; when the available resources in the usage status of the video memory obtained in real time are insufficient, releasing the divided shared physical page from the kernel partner system based on the video memory application request to meet the video memory demand.
[0010] In combination with the first aspect, in a possible implementation, the video memory / cache is monitored, and when the video memory / cache data changes, corresponding data is sent to the cache / video memory to achieve data synchronization between the cache and the video memory, including: monitoring data changes in the cache, and when data is written to the cache, the corresponding data is sent to the video memory; after the video memory receives the corresponding data from the cache, the corresponding data is written to the video memory within a timeout period; monitoring data changes in the video memory, and when the video memory data changes, the corresponding change data is sent to the cache; the cache performs data synchronization processing based on the corresponding change data received from the video memory.
[0011] In a second aspect, an embodiment of the present application provides a computer video memory sharing device, comprising: a page table initialization module, configured to divide idle resources in the video memory into physical pages, and to attach the divided multiple shared physical pages to a kernel partner system; a video memory management module, configured to obtain the usage status of the video memory in real time to determine the idle resources therein; to apply for the shared physical pages from the kernel partner system in response to a memory application request; and to release the applied shared physical pages according to the usage status of the video memory; and a consistency management module, configured to monitor the video memory / cache, and when the video memory / cache data changes, to send corresponding data to the cache / video memory to achieve data synchronization between the cache and the video memory.
[0012] In combination with the second aspect, in one possible implementation, the video memory management module includes a GMU-A unit and a GMU-F unit; the GMU-F unit is used to obtain the usage status of the video memory in real time, and when the available resources in the usage status of the video memory are insufficient, release the converted shared physical pages from the kernel partner system to meet the video memory demand; the GMU-A unit is used to determine whether the available resources of the video memory reach a set threshold based on a memory application request, and reject the memory application request based on the determination result, or allocate the required shared physical pages based on the memory application request.
[0013] In combination with the second aspect, in a possible implementation, the consistency management module includes a service agent unit and a client agent unit; the service agent unit is used to monitor data changes in the cache, and when data is written to the cache, the corresponding data is sent to the video memory; the client agent unit is used to monitor data changes in the video memory, and when the video memory data changes, the corresponding change data is sent to the cache.
[0014] In a third aspect, an embodiment of the present application provides a device for executing a computer video memory sharing method, the device comprising: a processor; a memory for storing processor-executable instructions; when the processor executes the executable instructions, it implements the method described in the first aspect or any possible implementation method of the first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides a non-volatile computer-readable storage medium, which includes a device for storing a computer program or instruction, and when the computer program or instruction is executed, the method described in the first aspect or any possible implementation method of the first aspect is implemented.
[0016] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:
[0017] By partitioning video memory into physical pages and attaching them to a kernel buddy system, the embodiments of this application can unify and abstract the physical pages of video memory and internal memory, reducing external fragmentation of video memory. By releasing partitioned shared physical pages, the normal operation of video memory can be guaranteed. By monitoring video memory / cache and notifying each other, data synchronization between video memory and cache can be achieved. This effectively solves the problem of inefficient use of computer system storage space, enabling real-time acquisition of video memory usage status, attaching idle resources to the kernel buddy system and using them as memory, further improving the efficient use of computer system storage space. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments of the present application or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 A flowchart of a computer video memory sharing method provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of the structure of a computer video memory sharing device provided in an embodiment of the present application;
[0021] Figure 3 A flowchart of the GMU-A unit provided in an embodiment of the present application;
[0022] Figure 4 A flowchart of the GMU-F unit provided in an embodiment of the present application;
[0023] Figure 5 A schematic structural diagram of a device for executing a computer video memory sharing method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0025] The following description of some of the technologies involved in the embodiments of this application is provided to facilitate understanding and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for the sake of clarity and conciseness, some descriptions of well-known functions and structures are omitted from the following description.
[0026] Figure 1 This is a flowchart of a computer video memory sharing method provided by an embodiment of the present application, including steps 101 to 105. Figure 1 This is only an execution order shown in the embodiment of the present application, and does not represent the only execution order of a computer video memory sharing method. If the final result can be achieved, Figure 1 The steps shown may be performed in parallel or reversed.
[0027] Step 101: Obtain the usage status of the video memory in real time to determine the idle resources therein. In an embodiment of the present application, during the operation of the computer, the idle resource management of the video memory is the key to the efficient operation of the task. Video memory management is usually completed by the GPU (graphics processing unit) driver and the hardware memory manager. Its core components include: a video memory allocator, which is responsible for allocating and releasing video memory blocks and maintaining metadata of idle video memory (idle resources). Page table / address mapping, which is used to map virtual video memory addresses to physical video memory addresses to achieve memory isolation and permission control. A defragmentation mechanism, which is used to reduce video memory fragmentation by compressing or migrating data. A hardware status register provides a register interface for the GPU hardware, and the driver can query the usage status of the video memory. When tracking the usage status of the video memory, the present application can adopt the following method.
[0028] The usage status of the video memory can be obtained through the video memory allocator. Specifically, by using the linked list or tree structure in the kernel buddy system, the idle video memory blocks, that is, the idle resources, can be obtained.
[0029] You can also obtain the video memory usage status through the hardware status register. The GPU hardware provides a register interface, and the driver can use the global status register to obtain the total video memory usage and free amount (i.e., free resources). You can also query video memory usage status through the API (data interface) provided by the video memory manufacturer. For example, NVIDIA (the world's leading graphics processor and artificial intelligence computing technology company) uses the cudaMemGetInfo() function (used to query the global video memory size available on the device and the amount of allocated video memory) to query free video memory (i.e., free resources) and total video memory.
[0030] Step 102: Physical pages are divided into idle resources in the video memory, and multiple shared physical pages are attached to the kernel buddy system. In this embodiment of the present application, the idle resources in the video memory are divided into physical pages according to the physical page size defined by the computer system to obtain multiple shared physical pages. Based on the rules of the kernel buddy system, the shared physical pages are attached to the kernel buddy system's memory physical page linked list.
[0031] Specifically, physical pages are fixed-size blocks that the operating system divides physical memory into. Each physical page is assigned a unique page frame number, which the kernel uses to track its status and determine whether the physical page is free or allocated. The size of a physical page varies depending on the operating system architecture, and can be, for example, 4KB (kilobytes), 2MB (megabytes), or 1GB (gigabyte).
[0032] Furthermore, the present application divides the idle resources of the video memory into multiple 4KB shared physical pages and assigns a page frame number to each shared physical page. Those skilled in the art should appreciate that the physical pages referred to in the present application are the physical pages divided by the memory, and the shared physical pages are the physical pages divided by the idle resources of the video memory.
[0033] In an embodiment of the present application, memory physical pages are managed by the kernel buddy system. The kernel buddy system maintains multiple free linked lists, each of which stores contiguous physical pages of varying sizes (different orders), with each physical page organized according to powers of 2 (e.g., 1 page, 2 pages, 4 pages, etc.). After the idle resources of the video memory are divided into shared physical pages, the shared physical pages are attached to the kernel buddy system's memory physical page linked list according to the kernel buddy system's rules.
[0034] Specifically, all partitioned shared physical pages are marked as free. Then, consecutive shared physical pages are merged into larger blocks until further merging is impossible. For example, two consecutive 4KB shared physical pages are merged into an 8KB shared physical page. The merged shared physical pages are then inserted into the kernel buddy system's corresponding free list based on their size, attaching the shared physical pages to the kernel buddy system's physical page list.
[0035] In this application, the idle resources of the video memory are divided into multiple shared physical pages and attached to the kernel partner system, so that the video memory can be directly managed by the kernel partner system of the operating system, realizing the unified abstraction of the physical pages of the video memory and the internal memory, and reducing the external fragmentation of the video memory.
[0036] Step 103: In response to the memory request, apply for a shared physical page from the kernel partner system. In this embodiment of the application, when the available resources of the video memory are lower than the set threshold, the memory request is rejected. When the available resources of the video memory reach the set threshold, the required shared physical page is allocated according to the memory request, such as Figure 2 shown.
[0037] Specifically, the threshold is exemplarily set to 20% of the video memory. Under normal memory resource allocation, when the available video memory resources obtained in real time are less than 20%, when a process / thread requests memory from the operating system, the operating system, upon receiving the memory request from the process / thread, will reject the request if the current available video memory resources are less than 20%. If the current available video memory resources are greater than or equal to 20%, the current idle video memory resources are divided into shared physical pages and attached to the kernel buddy system. Then, based on the memory request, the required memory (shared physical pages) is allocated to the process / thread.
[0038] Those skilled in the art should realize that steps 101 to 102 are performed in real time. After a process / thread requests memory and executes the current process / thread, the corresponding memory will be released. Therefore, the idle resources of the memory or video memory are changing during the execution of the task. And when the idle resources of the video memory are shared as memory, the needs of the video memory itself should be met first. Without affecting the video memory, the idle resources are attached to the kernel partner system as memory for sharing. Step 101 always determines the idle resources in the video memory when the available resources of the video memory are sufficient. Then step 102 divides the idle resources in the video memory into physical pages and attaches them to the kernel partner system.
[0039] Step 104: Based on the video memory usage status, a video memory request is sent to release the allocated shared physical pages. In this embodiment of the present application, if the available resources in the real-time acquired video memory usage status are sufficient, the video memory request is rejected. If the available resources in the real-time acquired video memory usage status are insufficient, the allocated shared physical pages are released from the kernel partner system based on the video memory request to meet the video memory demand.
[0040] Specifically, when the method of the present application uses the idle resources in the video memory as memory for sharing, it is necessary to first meet the needs of the video memory itself, and then hang the idle resources to the kernel partner system for use as memory.
[0041] Furthermore, the amount of available video memory resources required varies when a computer performs different tasks. Therefore, the "sufficient available resources" here refers to a quantity that changes in real time based on the task type and progress. For example, consider daily office work, such as word processing. Basic office tasks like web browsing and simple spreadsheet creation place relatively low demands on the graphics processor, primarily utilizing system memory. Only approximately 15% of available video memory is required, and available resources are sufficient. When playing local or online videos, video memory is primarily used for image rendering and display, relying on the video decoder chip and system memory. This does not require significant video memory resources, and in this case, approximately 20% of available video memory resources is sufficient. For games with less demanding graphics performance (such as low-quality, pixelated graphics, and static backgrounds), these games have relatively simple graphics, low texture resolution, and low scene complexity. Therefore, they do not require a large amount of video memory to store graphics data. Depending on the number of characters, special effects, and other elements in the game, approximately 40%-60% of available resources is sufficient. When playing games that demand high graphics performance (such as realistic 3D rendering, ultra-high-definition materials, large-scale dynamic scenes, and real-time computational special effects), these games feature high-resolution textures, complex lighting and shadow effects, large polygonal models, and intricate scene details. These games require a large amount of video memory to store and process graphics data. When video memory is insufficient, the game may experience lag, frame drops, or screen tearing. In these scenarios, the available resources required for video memory can reach 80%-95%, and in some extreme cases, even close to 100%.
[0042] Those skilled in the art will appreciate that in actual applications, available video memory resources (resources required for a task) are also affected by various factors, including hardware configuration (such as graphics card performance, video memory capacity, CPU performance), software optimization, and background programs running on the system. Therefore, the above-mentioned data for determining whether available resources are sufficient is only a rough guideline. In actual applications, the influence of hardware configuration and other factors must be comprehensively considered. Typically, the estimated available video memory resources will be slightly higher than the actual demand.
[0043] like Figure 3 As shown, based on the type and progress of the task currently being executed by the computer, it is determined whether the available video memory resources are sufficient. If the available video memory resources are sufficient, the free resources of the video memory that have been divided into shared physical pages are refused to be released, and the video memory request fails. If the available video memory resources are insufficient, the free resources of the video memory that have been divided into shared physical pages in the kernel partner system are released to meet the video memory demand, and the video memory request succeeds.
[0044] Step 105: Monitor the video memory / cache. When the video memory / cache data changes, send corresponding data to the cache / video memory to synchronize data between the cache and the video memory. In this embodiment of the present application, the cache data changes are monitored. When data is written to the cache, the corresponding data is sent to the video memory. After receiving the corresponding data from the cache, the video memory writes the corresponding data to the video memory within a timeout period. Monitor the video memory data changes. When the video memory data changes, send the corresponding change data to the cache. The cache performs data synchronization based on the corresponding change data received from the video memory.
[0045] Specifically, write operations and data modifications to the video memory or cache are detected through the CPU's cache consistency protocol (such as MESI, a cache consistency protocol used to maintain cache consistency in multi-processor systems) or the GPU's memory management unit (MMU, memory management unit, a hardware module). For example, when the CPU modifies a cache line, the hardware will mark the line as "dirty". Once the cache data on the CPU side is monitored to be written or modified, the corresponding data is sent from the source (cache) to the target (video memory). Once the data in the video memory is monitored to be written or modified, the corresponding changed data is sent from the source (video memory) to the target (cache) to ensure that the video memory and cache have the same copy of the data, thus achieving data synchronization.
[0046] Although this application provides method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on routine or non-creative work. The order of steps listed in this embodiment is only one way of executing the steps among many, and does not represent the only execution order. When an actual device or client product executes, the method shown in this embodiment or the accompanying drawings may be executed sequentially or in parallel (for example, in a parallel processor or multi-threaded processing environment).
[0047] like Figure 4 As shown, the present embodiment also provides a computer video memory sharing device 400. The device includes: a page table initialization module 410, a video memory management module 420, and a consistency management module 430. The video memory management module 420 includes a GMU-A unit 421 and a GMU-F unit 422, and the consistency management module 430 includes a service agent unit 431 and a guest agent unit 432. The details are as follows.
[0048] The page table initialization module 410 is configured to divide the idle resources in the video memory into physical pages, and to attach the divided multiple shared physical pages to the kernel partner system.
[0049] The video memory management module 420 is configured to obtain the usage status of the video memory in real time to determine the idle resources therein, request shared physical pages from the kernel partner system in response to a memory request, and release the requested shared physical pages based on the usage status of the video memory.
[0050] The consistency management module 430 is configured to monitor the video memory / cache, and when the video memory / cache data changes, send corresponding data to the cache / video memory to achieve data synchronization between the cache and the video memory.
[0051] The GMU-F unit 422 is used to obtain the usage status of the video memory in real time. When the available resources in the usage status of the video memory are insufficient, the converted shared physical pages are released from the kernel partner system to meet the video memory demand.
[0052] The GMU-A unit 421 is used to determine whether the available resources of the video memory have reached a set threshold according to the memory application request, and reject the memory application request according to the determination result, or allocate the required shared physical pages according to the memory application request.
[0053] The service agent unit 431 is used to monitor the data changes in the cache, and when data is written to the cache, it sends the corresponding data to the video memory.
[0054] The client agent unit 432 is used to monitor the data changes in the video memory, and when the data in the video memory changes, the corresponding changed data is sent to the cache.
[0055] like Figure 2 Specifically, under normal memory resource allocation, when the available video memory resources obtained in real time are less than 20%, when a process / thread requests memory from the operating system, the operating system receives the memory request from the process / thread and the GMU-A unit processes the request. The GMU-A unit first determines whether the available video memory resources are less than 20%. If the available video memory resources are less than 20%, the request is rejected, resulting in a failed memory request. If the available video memory resources are greater than or equal to 20%, the idle video memory resources are divided into shared physical pages and attached to the kernel buddy system. Then, based on the memory request, the required memory (shared physical pages) is allocated to the process / thread, resulting in a successful memory request.
[0056] like Figure 3As shown, based on the type and progress of the task currently being executed by the computer, the operating system is requested for video memory. The operating system then sends the video memory request to the GMU-F unit. The GMU-F unit first determines whether the available video memory resources are sufficient. If the available video memory resources are sufficient, the free resources of the video memory that have been allocated as shared physical pages are refused to be released, and the video memory request fails. If the available video memory resources are insufficient, the free resources of the video memory that have been allocated as shared physical pages in the kernel partner system are released to meet the video memory demand, and the video memory request succeeds.
[0057] Some modules in the apparatus described herein may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0058] The devices or modules described in the above application embodiments can be implemented by computer chips or physical devices, or by products with certain functions. For ease of description, the above devices are described separately by function in various modules. When implementing the embodiments of this application, the functions of each module can be implemented in the same or multiple software and / or hardware. Of course, a module that implements a certain function can also be implemented by combining multiple sub-modules or sub-units.
[0059] The methods, devices, or modules described herein can be implemented in the form of computer-readable program code. The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the memory control logic. Those skilled in the art will also appreciate that, in addition to implementing the controller in pure computer-readable program code, the controller can also be implemented in the form of logic gates, switches, an application-specific integrated circuit, a programmable logic controller, an embedded microcontroller, etc. by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions may be considered to be both a software module for implementing the method and a structure within a hardware component.
[0060] An embodiment of the present application also provides a device 500 for executing a computer video memory sharing method, the device comprising: a processor 502; a memory 501 for storing executable instructions of the processor 502; when the processor 502 executes the executable instructions, the method described in the embodiment of the present application is implemented.
[0061] The embodiments of the present application also provide a non-volatile computer-readable storage medium having a computer program or instruction stored thereon. When the computer program or instruction is executed, the method described in the embodiments of the present application is implemented.
[0062] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist independently, or two or more modules may be integrated into one module.
[0063] The above-mentioned storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), cache, hard disk drive (HDD), or memory card. Such memory can be used to store computer program instructions.
[0064] Through the description of the above implementation methods, it can be seen that those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary hardware. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, or can be embodied through the implementation process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application or certain parts of the embodiments.
[0065] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referenced to each other. Each embodiment focuses on the differences from other embodiments. All or part of this application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, mobile communication terminals, multi-processor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.
[0066] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit the present application. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present application.
Claims
1. A computer video memory sharing method, characterized in that: include: Obtain the usage status of video memory in real time to determine the idle resources; Dividing the idle resources in the video memory into physical pages, and attaching the divided multiple shared physical pages to the kernel partner system; In response to the memory application request, applying for the shared physical page from the kernel partner system; Sending a video memory application request to release the divided shared physical page according to the usage status of the video memory, including: rejecting the video memory application request when available resources in the usage status of the video memory obtained in real time are sufficient; and releasing the divided shared physical page from the kernel partner system according to the video memory application request to meet video memory demand when available resources in the usage status of the video memory obtained in real time are insufficient; Monitor the video memory / cache, and when the video memory / cache data changes, send the corresponding data to the cache / video memory to achieve data synchronization between the cache and video memory.
2. The method according to claim 1, characterized in that The step of dividing the idle resources in the video memory into physical pages and attaching the divided multiple shared physical pages to the kernel partner system includes: Dividing the idle resources in the video memory into physical pages according to the size of the physical pages defined by the computer system to obtain a plurality of shared physical pages; Based on the rules of the kernel buddy system, the shared physical page is attached to the physical page linked list of the kernel buddy system.
3. The method according to claim 1, characterized in that The step of applying for the shared physical page from the kernel partner system in response to the memory application request includes: When the available resources of the video memory are lower than the set threshold, the memory application request is rejected; When the available resources of the video memory reach a set threshold, the required shared physical pages are allocated according to the memory application request.
4. The method according to claim 1, wherein The monitoring video memory / cache, when the video memory / cache data changes, sends corresponding data to the cache / video memory to achieve data synchronization between the cache and the video memory, including: Monitor cache data changes, and when data is written to the cache, send the corresponding data to the video memory; After receiving the corresponding data in the cache, the video memory writes the corresponding data into the video memory within the timeout period; Monitor the data changes in the video memory, and when the video memory data changes, send the corresponding changed data to the cache; The cache performs data synchronization processing based on the corresponding change data received from the video memory.
5. A computer video memory sharing device, characterized in that: include: A page table initialization module is configured to divide the idle resources in the video memory into physical pages and attach the divided multiple shared physical pages to the kernel partner system; A video memory management module is configured to obtain the usage status of the video memory in real time to determine the idle resources therein; In response to the memory application request, applying for the shared physical page from the kernel partner system; Releasing the applied shared physical page according to the usage status of the video memory includes: rejecting the video memory application request when available resources in the usage status of the video memory obtained in real time are sufficient; and releasing the divided shared physical page from the kernel partner system according to the video memory application request to meet the video memory demand when available resources in the usage status of the video memory obtained in real time are insufficient; The consistency management module is configured to monitor the video memory / cache, and when the video memory / cache data changes, send corresponding data to the cache / video memory to achieve data synchronization between the cache and the video memory.
6. The device according to claim 5, characterized in that The video memory management module includes a GMU-A unit and a GMU-F unit; The GMU-F unit is used to obtain the usage status of the video memory in real time, and when the available resources in the usage status of the video memory are insufficient, release the converted shared physical pages from the kernel partner system to meet the video memory demand; The GMU-A unit is used to determine whether the available resources of the video memory have reached a set threshold according to the memory application request, and reject the memory application request according to the determination result, or allocate the required shared physical pages according to the memory application request.
7. The device according to claim 5, characterized in that The consistency management module includes a service agent unit and a client agent unit; The service agent unit is used to monitor the data changes in the cache, and when data is written to the cache, the corresponding data is sent to the video memory; The client agent unit is used to monitor the data changes in the video memory, and when the data in the video memory changes, the corresponding changed data is sent to the cache.
8. A device for executing a computer video memory sharing method, characterized in that: include: processor; a memory for storing processor-executable instructions; When the processor executes the executable instructions, the method according to any one of claims 1 to 4 is implemented.
9. A non-volatile computer-readable storage medium, characterized in that: The device comprises a computer program or an instruction for storing the computer program or the instruction, which, when executed, enables the method according to any one of claims 1 to 4 to be implemented.
Citation Information
Patent Citations
Server non-perception resource processing method and device and electronic equipment
CN116401062A
GPU video memory application and release method and device and storage medium
CN117194055A