Caching memory descriptors for multiple input / output requests

By cache memory descriptors and using reference count management, the performance problem of long-term locking of physical memory pages is solved, the system stability and memory manager efficiency are improved, and normal access and troubleshooting of GPU memory is ensured.

CN118891614APending Publication Date: 2024-11-01MICROSOFT TECHNOLOGY LICENSING LLC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202380026882.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-04-04
Filing Date
2023-03-23
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

When the prior art deals with a large number of I/O operations, the long-term detection and locking of physical memory pages leads to a degradation of system performance, affecting the success rate of OS core building large memory pages, the ability of hardware cyclic erasing and software to scan faulty pages, and the GPU Memory access is restricted.

Method used

Using cache memory descriptors, track I/O requests through reference counts, timely release memory descriptors and unlock physical memory pages, ensuring that the memory manager can quickly allocate and scan pages and avoid fatal errors.

Benefits of technology

Improves the success rate of the OS kernel in building large memory pages, improves the performance of the memory manager, prevents system errors, and supports GPU memory window mapping and power outage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118891614A_ABST
    Figure CN118891614A_ABST
Patent Text Reader

Abstract

Memory descriptors are cached across input / output (I / O) requests. Based at least on a request received from a buffer consumer to register a buffer, a memory descriptor is created that describes a layout of a set of physical memory pages allocated to the buffer. Creating the memory descriptor includes allocating and locking the set of physical memory pages to the memory descriptor. For each I / O request of the plurality of I / O requests on the buffer, at least a subset of the memory descriptors for use by the I / O request is returned, and the I / O requests suspended on the memory descriptors are tracked using a reference count. Subsequently, the memory descriptor is corrupted, including unlocking the set of physical memory pages based at least on the reference count indicating that there is no suspended I / O request on the memory descriptor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to systems, methods, and devices for managing memory page mapping of input / output (I / O) buffers. Background Art

[0002] When a user mode process needs to perform an I / O operation (e.g., read from or write to a file or some other memory buffer), the user mode process sends an I / O request to the operating system (OS) kernel. The I / O request includes a memory offset and a length, which together define a virtual memory area corresponding to the requested I / O. The OS kernel verifies that this virtual memory area is within a valid memory buffer, and then probes and locks one or more physical memory pages to the virtual memory area. When probing and locking, the OS kernel generates a mapping between virtual memory pages and physical memory pages, and locks these physical memory pages, ensuring that subsequent accesses to the virtual memory area do not cause page errors, and enabling the device to directly update the physical pages, and having the updates reflected in the virtual memory area. In some operating systems, such as WINDOWS from Microsoft, this mapping between virtual memory pages and physical memory pages can be represented by a memory descriptor list (MDL). Once the requested I / O operation is completed, the OS kernel releases the lock on the physical memory page and discards the MDL. Thus, for each valid I / O request, the OS performs a probe and lock on one or more physical memory pages and holds the lock for the duration of the I / O request.

[0003] Some scenarios (e.g., graphics rendering) generate a large number of I / O operations (e.g., loading a texture bitmap into a graphics processing unit (GPU) memory). To avoid having a call from user mode to kernel mode for each of these I / O operations, some OS kernels have implemented an I / O mechanism known as "IORing" (e.g., io_uring in LINUX or IORING in WINDOWS). Using IORing, a user-mode process pre-allocates multiple buffers to the OS kernel (e.g., gives the OS kernel an array of buffers, each of which can be identified by a user-mode process based on an offset within the array), uses a submission queue to queue multiple I / O requests on these buffers, and then submits these I / O requests. After submitting these I / O requests, the OS kernel processes them by issuing parallel and asynchronous I / O operations, and places the results of these I / O operations in a completion queue. Summary of the invention

[0004] In some aspects, the technology described herein relates to a method implemented at a computer system including a processor for caching memory descriptors across multiple I / O requests, the method comprising: creating a memory descriptor describing a layout of a set of physical memory pages allocated to the buffer based at least on receiving a request to register a buffer from a buffer consumer, the memory descriptor creating the memory descriptor comprising allocating and locking the set of physical memory pages to the memory descriptor; for each of the multiple I / O requests on the buffer: returning at least a subset of the memory descriptor for use by the I / O request, and using a reference count to track I / O requests pending on the memory descriptor; and releasing the memory descriptor based at least on the reference count indicating that there are no pending I / O requests on the memory descriptor, comprising unlocking the set of physical memory pages.

[0005] In some aspects, the technology described herein relates to a computer system for caching memory descriptors across multiple I / O requests, comprising: a processor; and a computer storage medium storing computer-executable instructions that can be executed by the processor to cause the computer system to at least: create a memory descriptor based at least on receiving a request to register a buffer from a buffer consumer, the memory descriptor describing the layout of a set of physical memory pages allocated to the buffer, creating the memory descriptor including allocating and locking the set of physical memory pages to the memory descriptor; for each of multiple I / O requests on the buffer: return at least a subset of the memory descriptor for use by the I / O request, and use a reference count to track pending I / O requests on the memory descriptor; and release the memory descriptor based at least on the reference count indicating that there are no pending I / O requests on the memory descriptor, including unlocking the set of physical memory pages.

[0006] In some aspects, the technology described herein relates to a computer program product that includes a computer storage medium storing computer-executable instructions that are executable by a processor to cause a computer system to at least: based at least on receiving a request to register a buffer from a buffer consumer, create a memory descriptor that describes a layout of a set of physical memory pages allocated to the buffer, creating the memory descriptor includes allocating and locking the set of physical memory pages to the memory descriptor; for each of a plurality of I / O requests on the buffer: return at least a subset of the memory descriptor for use by the I / O request, and use a reference count to track pending I / O requests on the memory descriptor; and release the memory descriptor based at least on the reference count indicating that there are no pending I / O requests on the memory descriptor, including unlocking the set of physical memory pages.

[0007] This Summary is provided to introduce some concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] In order to describe the manner in which the advantages and features of the systems and methods described herein can be obtained, a more particular description of the systems and methods briefly described above will be presented by reference to specific embodiments illustrated in the accompanying drawings. Understanding that these drawings depict only typical embodiments of the systems and methods and are therefore not to be considered limiting of their scope, the systems and methods will be described and explained with additional specificity and detail through the use of the accompanying drawings, in which:

[0009] Figure 1 An example computer architecture that facilitates caching of memory descriptors for multiple I / O requests is shown;

[0010] Figure 2 An example of an MDL cache data structure is shown in FIG.

[0011] Figure 3 shows an example of an MDL cache buffer entry;

[0012] Figure 4 An example of MDL cache logic is shown in FIG; and

[0013] Figure 5 A flow chart of an example method for caching memory descriptors across multiple I / O requests is shown. DETAILED DESCRIPTION

[0014] At least some embodiments herein provide a cache that caches memory descriptor data structures (e.g., MDLs) for buffers across multiple I / O operations on a buffer, resulting in detection and locking of underlying physical memory pages being maintained on multiple I / O operations. For example, in the context of IORing, at least some embodiments herein cache memory descriptors for pre-allocated buffers used by multiple I / O operations on a buffer. By caching memory descriptors for multiple I / O operations on a buffer, the performance of each I / O operation is improved. For example, in experiments, this results in a reduction in processor utilization of approximately 10%. Therefore, the extended time period for locking memory pages improves system behavior.

[0015] However, while improving system behavior, having long-standing probes and locks on physical memory pages may result in some negative effects. For example, having physical memory pages probed and locked over extended periods of time may adversely affect the OS kernel's success rate in quickly building large (64K, 2M, 1G) memory pages, because the OS kernel's memory manager may not be able to locate a sufficiently large contiguous physical memory region. In addition, probing and locking physical memory pages over extended periods of time means that the memory manager may need to check physical memory addresses (e.g., page frame numbers) at the page level rather than at the level of larger page clusters (e.g., 64K / 2M / 1G), resulting in longer scans (regardless of success rate) when requesting allocations of large memory pages or memory with physical address restrictions. In addition, having physical memory pages probed and locked over extended periods of time means that if hardware patrol scrubs find errors in those pages, the memory manager will not be able to remove the error pages, and the software will not be able to scan those pages - both of which may result in fatal system errors. Finally, GPU memory access is often windowed, requiring GPU physical memory to be remapped to expose different windows (e.g., 256M) into the GPU memory. The GPU driver may not be able to perform those remappings when probing and locking GPU physical memory pages for extended periods of time; in addition, the GPU cannot be powered off when GPU memory pages are locked by the OS kernel.

[0016] At least some embodiments herein address each of these negative effects of having long-lived probes and locks on physical memory pages, while still retaining the I / O performance improvements achieved by long-lived probes and locks on physical memory pages. Specifically, at least some embodiments herein provide a cache that caches memory descriptors across I / O requests that maintain probed and locked memory pages across those I / O requests. However, in addition to caching memory descriptors across I / O requests, the memory descriptor cache described herein implements a reference counted system that enables cached memory descriptors to be released (and any corresponding probed and locked memory pages to be unlocked) based on requests by a memory manager (e.g., based on a physical page address) and / or a memory buffer consumer (e.g., IORing).

[0017] By enabling cached memory descriptors to be released upon request, embodiments of the present invention enable the memory manager to release physical memory pages when needed. This improves the OS kernel's success rate in quickly building large memory pages (64K, 2M, 1G), and improves the performance of the memory manager in doing so. This also enables hardware and software to scan and remove faulty pages, preventing fatal system errors, and enabling the GPU to perform GPU memory window mappings and unlock GPU memory pages for power off in a timely manner.

[0018] Figure 1 An example computer architecture 100 is shown that facilitates caching of memory descriptors for multiple I / O requests. As shown, computer architecture 100 includes a computer system (hardware 101) that includes a processor 102 (or multiple processors), memory 103, and one or more computer storage media (storage media 104). In an embodiment, hardware 101 also includes a GPU 105 (or multiple GPUs), or various other hardware (as indicated by ellipses within hardware 101).

[0019] In various embodiments, storage medium 104 stores computer executable instructions that implement one or more software components executed at processor 102, such as an OS that provides a user mode 107 context and a kernel mode 108 context. As shown within user mode 107, processor 102 executes a user mode process 109 (or multiple user mode processes). As shown in kernel mode 108, processor 102 executes (among other things) a buffer consumer 110, a memory manager 112, and an I / O manager 113.

[0020] According to embodiments herein, buffer consumer 110 interfaces with I / O manager 113 to probe and lock physical memory pages of one or more buffers (e.g., buffers 111a through 111n) through multiple I / O operations (e.g., as requested by user mode process 109). In one example, buffer consumer 110 is an IORING component (e.g., io_uring in LINUX or IORING in WINDOWS) that pre-allocates one or more buffers (e.g., buffers 111a through 111n) based on request(s) from user mode process 109, and that performs multiple I / O operations on these buffers, possibly as parallel asynchronous operations.

[0021] As used herein, a "memory descriptor" is a data structure that describes the physical page layout of a virtual memory buffer (e.g., a mapping between physical memory pages and virtual memory pages). Although a memory descriptor can take a variety of forms, one example of a memory descriptor is the memory descriptor list (MDL) used by the WINDOWS operating system from Microsoft Corporation. For clarity and brevity, the description herein describes an example of an MDL cache that caches an MDL. However, it should be understood that the term "memory descriptor" can be applied to data structures other than MDLs.

[0022] I / O manager 113 is shown as including an MDL cache 114. In various embodiments, MDL cache 114 retains (e.g., caches) one or more MDLs (e.g., MDL 116a through MDL 116n) across I / O requests from buffer consumers 110. Retaining MDLs across I / O requests maintains probed and locked memory pages across those I / O requests. Additionally, in an embodiment, MDL cache 114 utilizes reference counting to enable any cached MDL to be released (and any corresponding probed and locked memory pages to be unlocked) based on a request by memory manager 112 and / or buffer consumers 110.

[0023] To achieve the foregoing, in an embodiment, MDL cache 114 provides (e.g., as part of MDL cache logic 118) one or more application programming interfaces (APIs) that allow calls from memory manager 112 and / or from buffer consumer 110, and some specific exemplary APIs are described herein. However, it should be understood that the example APIs are illustrative only. In other embodiments, MDL cache logic 401 may provide APIs of different numbers and functions.

[0024] Figure 4 The MDL cache logic 401 (eg Figure 11. In the example 400, the MDL cache logic 401 includes a buffer entry creation component 402, a buffer getter component 403, an MDL release component 405, a page release component 406, and a buffer entry clear component 407. The ellipsis indicates that in other examples the MDL cache logic 401 may include one or more additional (or alternative) components. Figure 4 Each component of the MDL cache logic 401 depicted in the 401 represents various functionalities that the MDL cache logic 401 may implement according to the various embodiments described herein. However, it should be understood that the depicted components (including their identification and arrangement) are presented only as an aid to describing the various embodiments of the MDL cache logic 401.

[0025] In various embodiments, a first API (hereinafter referred to as CreateBufferEntry(...)) enables the buffer consumer 110 to call the MDL cache 114 to register a buffer (e.g., buffer 111a) with the MDL cache 114 based on providing at least an address range (e.g., a starting address and a length) to the MDL cache 114. In various embodiments, based on the buffer consumer 110 calling the CreateBufferEntry(...) API, the buffer entry creation component 402 creates a "BufferEntry" object for the specified buffer and inserts the newly created BufferEntry into a set (e.g., an array, a list, etc.) of BufferEntry objects. Thus, the MDL cache 114 is shown to include buffer entries 115, which include buffer entries 115a (e.g., corresponding to buffer 111a) to buffer entries 115n (e.g., corresponding to buffer 111n).

[0026] Figure 3 Buffer entries 301 for an MDL cache are shown (eg Figure 1 15a). In example 300, buffer entry 301 includes (or is associated with) one or more flags 302, address range 303, MDL 304 (e.g., MDL 116a), reference count 305, and page to buffer entry (PtoB) node (PtoB node 306). The ellipsis indicates that buffer entry 301 may include one or more additional (or alternative) elements.

[0027] In some embodiments, flags 302 include a first flag (e.g., UNLOCK) that, when set, indicates that the MDL corresponding to the BufferEntry object cannot be used for new I / O operations. In various embodiments, buffer entry creation component 402 initializes the first flag to an unset state (e.g., binary 0). In an embodiment, this first flag is changed to a set state (e.g., binary 1) when (i) there is a call from memory manager 112 (e.g., TryReleasePage(...) API, discussed below) to unlock the physical page associated with the MDL for this BufferEntry object, and when (ii) the MDL is being actively used for I / O operations (e.g., when reference count 305 is non-zero). In an embodiment, including the first flag has the technical benefit of enabling a BufferEntry object to indicate whether it can accept new I / O operations.

[0028] In some embodiments, the flags 302 include a second flag (e.g., SIGNAL_RUNDOWN) that, when in a set state (e.g., binary 1), indicates that a thread that is setting references to the MDL associated with the BufferEntry object to zero should signal a shutdown event. In various embodiments, the shutdown event is used to wait for outstanding references to the MDL to be discarded before cleaning up the BufferEntry object (e.g., waiting for completion of a pending I / O operation). In various embodiments, the buffer entry creation component 402 initializes the second flag to an unset state (e.g., binary 0). In various embodiments, including the second flag has the technical benefit of enabling the BufferEntry object to indicate that the I / O operation associated with the BufferEntry object is being exhausted.

[0029] In some embodiments, flags 302 include a third flag (e.g., CLEANED_UP) that, when in a set state (e.g., binary 1), persistently indicates that the BufferEntry object is cleaned and cannot be used for new I / O operations. In various embodiments, buffer entry creation component 402 initializes the third flag to an unset state (e.g., binary 0). In various embodiments, including the third flag has the technical benefit of enabling a BufferEntry object to indicate whether it was ever available for a new I / O operation.

[0030] In an embodiment, address range 303 is the range of memory addresses managed by the BufferEntry object. In various embodiments, buffer entry creation component 402 initializes address range 303 based on the buffer start address and buffer length provided by buffer consumer 110 as part of a call to CreateBufferEntry(...) API. In an embodiment, including address range 303 has the technical benefit of enabling a BufferEntry object to indicate the virtual memory buffer it manages.

[0031] In an embodiment, MDL 304 is an MDL object for the BufferEntry object. The MDL object can be part of the BufferEntry object itself, or can be stored separately from the BufferEntry object. In some embodiments, the buffer entry creation component 402 uses the MDL creator component 404a to create and detect and lock the MDL object when creating the BufferEntry object. However, in other embodiments, the buffer entry creation component 402 calculates and allocates the amount of space required to store the MDL object, but the MDL cache 114 postpones the creation of the MDL object until the initial I / O operation (e.g., the initial call to the GetBuffer(...) API discussed below) with reference to this BufferEntry object.

[0032] In an embodiment, the reference count 305 is a reference count on the MDL 304 associated with the BufferEntry object. In an embodiment, the buffer entry creation component 402 sets the reference count 305 to 1 when creating the BufferEntry object. In an embodiment, the reference count 305 is increased for each I / O operation that references the BufferEntry object and is decreased when each I / O operation is completed. In an embodiment, the BufferEntry object is released when the reference count 305 reaches zero.

[0033] In an embodiment, for each BufferEntry object, the MDL cache 114 populates a PtoB map 117, which has entries each mapping a physical page address (e.g., a page frame number) to a reference (e.g., a memory address) to a BufferEntry object that includes an MDL covering this physical page address. In an embodiment, each entry is a node in an Adelson-Velsky and Landis (AVL) tree. In other embodiments, the PtoB map 117 is a hash table, a rotating jump list, or any other data structure used as an effective mapping. In an embodiment, if the buffer entry creation component 402 creates and detects and locks the MDL object when creating the buffer entry object, the buffer entry creation component 402 also creates a PtoB node 306 for the BufferEntry and inserts the node(s) into the PtoB map 117. In an embodiment, if the MDL cache 114 postpones the creation of the MDL object until the initial I / O operation, the buffer entry creation component 402 calculates the allocation of the amount of space required to store the PtoB node 306.

[0034] In an embodiment, the buffer entry creation component 402 returns a reference (e.g., a memory address) corresponding to the newly created BufferEntry object to a caller such as the buffer consumer 110. Therefore, the caller (e.g., the buffer consumer 110) can use the reference to reference the newly created BufferEntry object later. In an embodiment, the buffer consumer 110 stores these references in one or more arrays so that the buffer consumer 110 can locate the reference to the BufferEntry object based on the offset within the array. In an embodiment, if the buffer consumer 110 is an IORing component, the buffer consumer 110 can maintain different IORing objects for each buffer array registered by a user mode process (e.g., the user mode process 109). In this embodiment, the buffer consumer 110 can maintain a corresponding array of BufferEntry object references for each IORing object, wherein this array can be used to identify a specific BufferEntry object based on the offset used by the user mode process to reference the corresponding buffer.

[0035] Figure 2An example 200 of an MDL cache data structure is shown. In example 200, an MDL cache 204 (e.g., MDL cache 114) includes a buffer entry 205 (e.g., buffer entry 115). As shown, buffer entry 205 includes a plurality of BufferEntry objects (e.g., as an array, as a list), including BufferEntry objects for buffers (e.g., buffers 111a through 111n) defined by IORing object 206 and IORing object 207 within buffer consumer 110. For example, IORing object 206 is shown as an array storing references to BufferEntry objects, including a reference to BufferEntry-1 208a at offset 0 within the array (in this case, address 0xFFFF0BE00001000), and a reference to BufferEntry-2 208b at offset 1 within the array. In addition, IORing object 207 is shown as storing a reference to BufferEntry object-A 208c (in this case, address 0xFFFF0BE0000A000). In example 200, MDL cache 204 also includes PtoB map 201 (e.g., PtoB map 117). As shown, PtoB map 201 stores a mapping between physical memory pages (e.g., key 202) and references to BufferEntry objects (e.g., value 203). Thus, for example, physical memory page 0x000FFFFE00000001 maps to BufferEntry-1 208a (address 0xFFFF0BE00001000), physical memory page 0x000FFFFE00000002 maps to BufferEntry-A 208c (address 0xFFFF0BE0000A000), and physical memory page 0x000FFFFE0000000A maps to both BufferEntry-1 208a and BufferEntry-A 208c.

[0036] In an embodiment, a second API (hereinafter referred to as Getbuffer(...)) enables the buffer consumer 110 to call the MDL cache 114 to obtain an MDL for at least a portion of a buffer previously registered by a call to CreateBufferEntry(...). In an embodiment, based on the buffer consumer 110 utilizing a reference to a BufferEntry object and a call to GetBuffer(...), the buffer getter component 403 initially determines whether a first flag (e.g., UNLOCK) or a third flag (e.g., CLEANED_UP) is set for the requested BufferEntry object, and if so, the buffer getter component 403 does not use the created MDL within the BufferEntry object. This means that the I / O system will create and detect and lock a new uncached MDL using conventional techniques (e.g., so that a new uncached MDL is used for a single I / O operation).

[0037] In an embodiment, if the first flag and the third flag are not set for the requested BufferEntry object, the buffer getter component 403 determines whether an MDL for the BufferEntry object has been created. If so, the buffer getter component 403 increases the reference count of the BufferEntry object and returns the MDL of the BufferEntry object. In some embodiments, the GetBuffer(...)) API also receives an offset and a length, and the buffer getter component 403 returns a partial MDL that covers only a subset of the buffer. If an MDL for the BufferEntry object has not been created, the buffer getter component 403 creates and detects and locks a "complete" MDL for the BufferEntry object (e.g., using an MDL creator component 404b), increases the reference count of the BufferEntry object, fills the PtoB map 117 with the physical page address covered by the MDL that references the BufferEntry object, and returns the entire MDL or a portion of the MDL (based on the offset and length received).

[0038] In an embodiment, after calling GetBuffer(...), the buffer getter component 403 may be unable to build / return an MDL (e.g., in whole or in part). In an embodiment, this is not considered a fatal error, and an I / O request making the call may still be issued (e.g., by the I / O manager 113). In an embodiment, in these cases, the I / O operation is performed using conventional techniques (e.g., creating and probing and locking an MDL dedicated to the I / O operation and not cached by the MDL cache 114).

[0039] In an embodiment, a third API (hereinafter referred to as ReleaseMDL(...)) releases part (or all) of the MDL. In an embodiment, based on the buffer consumer 110 calling ReleaseMDL(...) with a reference to the MDL, the MDL release component 405 reduces the reference count of the corresponding BufferEntry object. Then, if the reference count is zero and the first flag (e.g., UNLOCK) is set, the MDL release component 405 releases / removes the MDL of the BufferEntry object. In addition, if the reference count is zero and the second flag (e.g., SIGNAL_RUNDOWN) is set, the MDL release component 405 signals a BufferEntry close event because this is the last I / O of the MDL using the BufferEntry object.

[0040] In an embodiment, a fourth API (hereinafter referred to as TryReleasePage(...)) enables the memory manager 112 to unlock a memory page that is locked by a cached MDL in a timely manner (e.g., unlocking a page in memory 106 on behalf of a GPU driver, on behalf of a component that requires contiguous memory, on behalf of a component that has identified a page that has gone bad). In an embodiment, based on the memory manager 112 calling TryReleasePage(...) with the address of the requested physical memory page (e.g., the page frame number), the page release component 406 uses the PtoB map 117 to determine whether there is a BufferEntry object corresponding to the requested physical memory page. If the page release component 406 identifies a BufferEntry object with an associated MDL that is not currently active (e.g., the reference count of the BufferEntry object is zero), the page release component 406 unlocks and releases the MDL and returns success, indicating that the memory manager 112 should retry its attempt to take the physical memory page. If the page release component 406 identifies a BufferEntry object with an associated MDL that is being actively used by an I / O operation (e.g., the reference count of the BufferEntry object is non-zero), the page release component 406 sets a first flag (e.g., UNLOCK) (preventing future I / O operations from utilizing the MDL) and returns a locked state. In this case, the memory manager 112 treats the MDL of the BufferEntry object as temporarily active and may retry later (e.g., waiting for active I / O operations on the MDL to be exhausted). If the memory manager 112 calls TryReleasePage(...) in response to a request from another component (e.g., a graphics driver requesting to release a page in memory 106), and the page release component 406 returns a locked state, the memory manager 112 may return a fault to the component (which may retry again later). In some embodiments, a call to TryReleasePage(...) (or a similar API) results in exhaustion of I / O operations from all cached MDLs (e.g., all buffer entries 115), not just the MDL corresponding to the requested memory page.

[0041] It is noteworthy that in some embodiments, a call to TryReleasePage(...) results in a partial teardown of the MDL. For example, an embodiment may track reference counts on a page-by-page basis, rather than the entire MDL. Then, while the MDL is being actively used by an I / O operation, if the reference count on a requested page within the MDL is zero, the page release component 406 may create a temporary MDL with all pages in the original MDL that have zero reference counts, unlock those pages, and replace the corresponding pages in the original MDL with virtual page addresses. In an embodiment, doing so will enable the memory manager 112 to immediately unlock pages of interest, rather than having to wait for pending I / O operations to complete on the entire MDL.

[0042] In an embodiment, the buffer consumer 110 uses a reference to the BufferEntry object to call a fifth API (hereinafter referred to as WaitAndCleanupBufferEntry(...)) to remove the BufferEntry object. In an embodiment, based on the call to WaitAndCleanupBufferEntry(...) by the buffer consumer 110, the buffer entry cleanup component 407 sets a flag (e.g., a second flag, SIGNAL_RUNDOWN) to signal a close event for the requested BufferEntry object. Then, if the reference count of the BufferEntry object is non-zero, the buffer entry cleanup component 407 waits for the close event to complete. In an embodiment, once the reference count of the BufferEntry object is zero, the thread that drops the reference count to zero signals a close event and calls the buffer entry cleanup component 407, which unlocks the MDL of the BufferEntry object, removes the BufferEntry object from the buffer entry 115, and deletes the BufferEntry object.

[0043] Now combine Figure 5 Describe the operation of the MDL cache 114, Figure 5 A flow chart of an example method 500 for caching memory descriptors across multiple I / O requests is illustrated. In an embodiment, instructions for implementing the method 500 are encoded as computer executable instructions (e.g., MDL cache logic 118, 401) stored on a computer storage medium (e.g., storage medium 104), which can be executed by a processor (e.g., processor 102) to cause a computer system (e.g., hardware 101) to perform the method 500.

[0044] The following discussion now involves a number of methods and method actions. Although method actions may be discussed in a particular order or may be shown in a flowchart as occurring in a particular order, no particular order is required unless specifically stated or because an action depends on another action being completed before the action is performed.

[0045] refer to Figure 5 In an embodiment, method 500 includes an act 501 of detecting and locking an MDL describing a buffer. In some embodiments, act 501 includes creating a memory descriptor describing a layout of a set of physical memory pages allocated to the buffer based at least on receiving a request to register the buffer from a buffer consumer, and creating the memory descriptor includes allocating and locking a set of physical memory pages to the memory descriptor. In an example, based at least on (e.g., in response to) registering buffer 111a on behalf of buffer consumer 110, MDL creator component 404 (e.g., MDL creator component 404a or MDL creator component 404b) creates MDL 116a corresponding to buffer 111a. The technical effect of act 501 includes creating a memory descriptor (e.g., MDL) that enables the buffer consumer to perform one or more I / O operations on the buffer. Although buffer consumer 110 can be a variety of components, in some embodiments of act 501, the buffer consumer is an IORing component and the buffer is an IORing user registered buffer.

[0046] like Figure 1 As shown, in an embodiment, the MDL is associated with a BufferEntry object. Therefore, in some embodiments, based on at least receiving a request to register a buffer from a buffer consumer, method 500 includes creating a buffer entry data structure including a starting address and a buffer length for the buffer, and inserting the buffer entry data structure into a list of buffer entries. For example, based on a call to CreateBufferEntry(...) by the buffer consumer 110 using the starting address and length of buffer 111a, the buffer entry creation component 402 creates a buffer entry 115a and inserts the buffer entry 115a into the buffer entry 115. In an embodiment, the buffer entry creation component 402 also returns a reference to the buffer entry 115a to the buffer consumer 110. Therefore, in some embodiments, method 500 includes returning the address of the buffer entry data structure to the buffer consumer.

[0047] As discussed, in some embodiments, buffer entry creation component 402 uses MDL creator component 404a to create and detect and lock MDL objects when creating BufferEntry objects. Therefore, in some embodiments of action 501, the allocation and locking of a set of physical memory pages to the memory descriptor is triggered by a request to register a buffer. For example, based on a call to CreateBufferEntry(...) by buffer consumer 110, MDL creator component 404a creates MDL 116a. In other embodiments, MDL cache 114 postpones the creation of MDL objects until the initial I / O operation of the BufferEntry object is referenced. Therefore, in some embodiments, the allocation and locking of a set of physical memory pages to the memory descriptor is triggered by receiving an initial I / O request in a plurality of I / O requests. For example, based on a call to GetBuffer(...) by buffer consumer 110, MDL creator component 404b creates MDL 116a.

[0048] Regardless of whether the MDL 116a is created by the MDL creator component 404a when the buffer is registered (e.g., creating a BufferEntry object) or by the MDL creator component 404b when the buffer is requested for an I / O operation, the BufferEntry object is referenced to add the underlying physical memory pages to the PtoB map 117. Therefore, in some embodiments, the method 500 also includes adding a mapping between the set of physical memory pages and a reference to a buffer entry data structure to the P2B map based at least on allocating and locking the set of physical memory pages to the memory descriptor.

[0049] Method 500 also includes an action 502 of using an MDL for multiple I / O requests. In some embodiments, action 502 includes: for each of the multiple I / O requests on the buffer, returning at least a subset of the memory descriptors used by the I / O request, and using reference counts to track the I / O requests pending on the memory descriptors. In the example, when the buffer consumer 110 needs an MDL for an I / O operation, the buffer consumer 110 calls GetBuffer(...) for the BufferEntry object, resulting in an increase in the reference count of the BufferEntry object by the buffer getter component 403. In addition, when the buffer consumer 110 completes the MDL (e.g., because the I / O operation is completed), the buffer consumer 110 calls ReleaseMDL(...), resulting in a decrease in the reference count of the BufferEntry object. Thus, in some embodiments, using a reference count to track each I / O request pending on a memory descriptor includes: increasing the reference count based on receiving a request from a buffer consumer for at least a subset of the memory descriptors used by the I / O request, and decreasing the reference count based on a received request from the buffer consumer to release at least a subset of the memory descriptors based on at least allocating and locking a set of physical memory pages used by the I / O request. The technical effects of action 502 include enabling memory descriptors (e.g., MDLs) to be saved (e.g., cached) by a BufferEntry across multiple I / O operations, reducing the CPU overhead of these I / O operations (experimentally, by approximately 10%).

[0050] As discussed, in some embodiments, the GetBuffer(...) API receives an offset and a length, and the buffer getter component 403 returns a partial MDL covering only a subset of the buffer. Thus, in some embodiments of action 502, at least one I / O request includes an offset and a length identifying a subset of the buffer, and returning at least a subset of the MDL for use by the at least one I / O request includes returning a partial memory descriptor corresponding to the offset and length. Alternatively, the buffer getter component 403 may return a full memory descriptor. Thus, in some embodiments of action 502, at least one I / O request includes an offset and a length identifying the entire buffer, and returning at least a subset of the memory descriptors for use by the I / O request includes returning the entire memory descriptor.

[0051] As shown, in an embodiment, method 500 also includes action 503, which exhausts any pending I / O operations for the MDL based on a request from the memory manager. In some embodiments, action 503 includes: based on a request from the memory manager to release a physical memory page identified in a set of physical memory pages, and at least based on a reference count indicating that there is at least one pending I / O request on the memory descriptor, setting a flag in the buffer entry data structure to prohibit future I / O requests from using the memory descriptor. In the example, based on a call to TryReleasePage(...) by the memory manager 112, the page release component 406 determines that there is at least one pending I / O operation on the MDL 116a based on the reference count for the buffer entry 115a, and sets a first flag (e.g., UNLOCK) in the buffer entry 115a, thereby preventing future I / O operations from utilizing the MDL 116a. The technical effect of action 503 includes enabling the memory manager to request the release of physical memory pages locked by cached memory descriptors (e.g., MDLs).

[0052] As discussed, the call to TryReleasePage(...) may include the address of the requested physical memory page, and the page release component 406 uses the PtoB map 117 to determine whether there is a BufferEntry object corresponding to the requested physical memory page. Thus, in an embodiment, action 503 includes using the identified physical memory page to identify a reference to a buffer entry data structure from the P2B map. Additionally, in an embodiment, action 503 includes identifying a reference count within a buffer entry data structure (e.g., buffer entry 115a).

[0053] Method 500 also includes an action 504 of releasing the MDL when no pending I / O operations remain. In some embodiments, action 504 includes releasing the memory descriptor, including unlocking a set of physical memory pages based at least on a reference count indicating that there are no pending I / O requests on the memory descriptor. In an example, when the reference count for buffer entry 115a is zero and a first flag (e.g., UNLOCK) is set within buffer entry 115a, MDL release component 405 releases / tears down MDL 116a. A technical effect of action 504 includes releasing physical memory pages based on the use of reference counts.

[0054] In an embodiment, the release of the MDL 116a in act 504 is based on the memory manager 112 having initiated the setting of the first flag (e.g., UNLOCK) within the buffer entry 115a in act 503. Thus, in some embodiments, releasing the memory descriptor is further based on receiving a request from the memory manager to release at least one physical memory page in a set of physical memory pages. Alternatively, in an embodiment, the release of the MDL 116a in act 504 is based on the buffer consumer 110 having requested the release of the MDL in act 502. Thus, in some embodiments, releasing the memory descriptor is further based on receiving a request from the buffer consumer to unregister the buffer.

[0055] Therefore, the embodiments herein provide a memory descriptor cache, which caches memory descriptors (e.g., MDL) for buffers on multiple I / O operations on buffers, thereby causing detection and locking of underlying physical memory pages to be maintained on multiple I / O operations. The extended time period of locking memory pages improves system behavior, and has been shown to cause processor utilization to be reduced by about 10%. In addition, the embodiments herein implement a reference counting system, which enables the cached memory descriptors (and unlocks any corresponding detected and locked memory pages) to be released based on the request of a memory manager (e.g., based on a physical page address) and / or a memory buffer consumer. By enabling the cached memory descriptors to be released upon request, the embodiments herein enable the memory manager to release physical memory pages when needed. This improves the success rate of the OS kernel when quickly building large memory pages (64K, 2M, 1G), and improves the performance of the memory manager when doing so. This also enables hardware and software to scan and remove faulty pages, prevent fatal system errors, and enable the GPU to promptly execute GPU memory window mapping and unlock GPU memory pages to power off.

[0056] Embodiments of the present disclosure may include or utilize a special-purpose or general-purpose computer system (e.g., computer architecture 100) that includes computer hardware (hardware 101), such as one or more processors (e.g., processor 102) and system memory (e.g., memory 103), as discussed in more detail below. Embodiments within the scope of the present disclosure also include physical and other computer-readable media for carrying or storing computer-executable instructions and / or data structures. Such computer-readable media can be any available media that can be accessed by a general-purpose or special-purpose computer system. Computer-readable media that store computer-executable instructions and / or data structures are computer storage media (e.g., storage media 104). Computer-readable media that carry computer-executable instructions and / or data structures are transmission media. Therefore, as an example, embodiments of the present disclosure may include at least two distinct computer-readable media: computer storage media and transmission media.

[0057] Computer storage media are physical storage media that store computer-executable instructions and / or data structures. Physical storage media include computer hardware, such as random access memory (RAM), read-only memory (ROM), electrically erasable programmable ROM (EEPROM), solid-state drive ("SSD"), flash memory, phase-change memory ("PCM"), optical disk storage, magnetic disk storage or other magnetic storage devices, or any other hardware storage device that can be used to store program code in the form of computer-executable instructions or data structures, which can be accessed and executed by a general-purpose or special-purpose computer system to implement the disclosed functions.

[0058] Transmission media may include networks and / or data links, which may be used to carry program codes in the form of computer executable instructions or data structures, and which may be accessed by general or special computer systems. "Network" is defined as one or more data links capable of transmitting electronic data between computer systems and / or modules and / or other electronic devices. When information is transmitted or provided to a computer system via a network or another communication connection (hardwired, wireless, or a combination of hardwired or wireless), the computer system may view the connection as a transmission medium. The above combination should also be included within the scope of computer-readable media.

[0059] In addition, program code in the form of computer executable instructions or data structures can be automatically transferred from transmission media to computer storage media (or vice versa) upon reaching various computer system components. For example, computer executable instructions or data structures received over a network or data link can be buffered in RAM within a network interface module and then ultimately transferred to computer system RAM and / or less volatile computer storage media at the computer system. Thus, it should be understood that computer storage media can be included in computer system components that also (or even primarily) utilize transmission media.

[0060] Computer executable instructions include, for example, instructions and data that cause a general purpose computer system, a special purpose computer system, or a special purpose processing device to perform a specific function or group of functions when executed on one or more processors. Computer executable instructions may be, for example, a binary file, intermediate format instructions such as assembly language, or even source code.

[0061] It should be understood that the disclosed system and method can be practiced in a network computing environment with many types of computer system configurations, including personal computers, desktop computers, laptop computers, message processors, handheld devices, multiprocessor systems, microprocessor-based or programmable consumer electronics, network PCs, minicomputers, mainframe computers, mobile phones, PDAs, graphic input tablets, pagers, routers, switches, etc. The embodiments of the present disclosure can also be practiced in a distributed system environment, where local and remote computer systems linked by a network (via a hardwired data link, a wireless data link, or a combination of a hardwired and wireless data link) all perform tasks. In this way, in a distributed system environment, a computer system can include multiple component computer systems. In a distributed system environment, program modules can be located in local and remote memory storage devices.

[0062] Those skilled in the art will also appreciate that embodiments of the present disclosure may be practiced in a cloud computing environment. A cloud computing environment may be distributed, although this is not required. When distributed, a cloud computing environment may be distributed internationally within an organization and / or have components owned across multiple organizations. In this specification and the appended claims, "cloud computing" is defined as a model for implementing on-demand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage, applications, and services).

[0063] Cloud computing models can consist of various characteristics, such as on-demand self-service, broad network access, resource pooling, rapid elasticity, measured services, etc. Cloud computing models can also appear in the form of various service models, such as software as a service ("SaaS"), platform as a service ("PaaS"), and infrastructure as a service ("IaaS"). Cloud computing models can also be deployed using different deployment models such as private cloud, community cloud, public cloud, hybrid cloud, etc.

[0064] Some embodiments (such as a cloud computing environment) may include a system that includes one or more hosts that are each capable of running one or more virtual machines. During operation, the virtual machine emulates an operational computing system, supports an operating system and may also support one or more other applications. In some embodiments, each host includes a hypervisor that emulates the virtual resources of the virtual machine using physical resources extracted from the virtual machine's view. The hypervisor also provides appropriate isolation between virtual machines. Therefore, from the perspective of any given virtual machine, the hypervisor provides the illusion that the virtual machine is engaged with physical resources, even if the virtual machine is only engaged with the appearance of physical resources (e.g., virtual resources). Examples of physical resources include processing power, memory, disk space, network bandwidth, media drives, etc.

[0065] Although the subject matter has been described in language specific to structural features and / or method actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the features or actions described above, or the order of the actions described above. Instead, the described features and actions are disclosed as example forms of implementing the claims.

[0066] The present disclosure may be implemented in other specific forms without departing from its essential features. Such embodiments may include a data processing device including means for performing one or more methods described herein; a computer program including instructions that, when executed by a computer, cause the computer to perform one or more methods described herein; and / or a computer-readable medium including instructions that, when executed by a computer, cause the computer to perform one or more methods described herein. The described embodiments are to be considered in all respects only as illustrative and not restrictive. All changes within the meaning and range of equivalents of the claims are included within their scope. When an element is introduced in the appended claims, the articles "a" and "an", "the" and "said" are intended to indicate the presence of one or more elements. The terms "comprising", "including" and "having" are intended to be inclusive and mean that there may be additional elements in addition to the listed elements. Unless otherwise indicated, the terms "group", "superset" and "subset" are intended to exclude empty groups, and thus "group" is defined as a non-empty group, "superset" is defined as a non-empty superset, and "subset" is defined as a non-empty subset. Unless otherwise specified, the term "subset" excludes its entire superset (ie, the superset contains at least one item not included in the subset). Unless otherwise specified, a "superset" may include at least one additional element, while a "subset" may exclude at least one element.

Claims

1. A method implemented at a computer system including a processor for caching memory descriptors across multiple input / output (I / O) requests, the method include: creating (404) a memory descriptor (304) describing a layout of a set of physical memory pages allocated to a buffer (111a), creating the memory descriptor includes allocating and locking the set of physical memory pages to the memory descriptor; Receiving a plurality of I / O requests on the buffer, for each of the plurality of I / O requests on the buffer: returning (403) at least a subset of the memory descriptors for use by the I / O request, and Using reference counting (305) to track the I / O requests pending on the memory descriptor; as well as Based at least on the reference count indicating that there are no pending I / O requests on the memory descriptor, releasing (405) the memory descriptor, including unlocking the set of physical memory pages, in: An I / O request of the plurality of I / O requests comprises an offset and a length identifying a subset of the buffer, and wherein returning at least the subset of the memory descriptors for use by the I / O request comprises returning a partial memory descriptor corresponding to the offset and the length; or An I / O request of the plurality of I / O requests includes an offset and a length identifying the entire buffer, and wherein returning at least the subset of the memory descriptors for use by the I / O request includes returning all of the memory descriptors.

2. The method of claim 1, wherein allocating and locking the set of physical memory pages to the memory descriptor is triggered by receiving (403) an initial I / O request from among the plurality of I / O requests. 3 . The method of claim 1 , wherein allocating and locking the set of physical memory pages to the memory descriptor is triggered by a request to register the buffer.

4. The method of any one of claims 1 to 3, wherein releasing the memory descriptor is further based on receiving (406) a request from a memory manager (112) to release a physical memory page in the set of physical memory pages.

5. The method according to any one of claims 1 to 4, wherein releasing the memory descriptor is further based on receiving (407) a request from a buffer consumer to deregister the buffer.

6. The method of any one of claims 1 to 4, wherein the reference count is used to track each I / O request pending on the memory descriptor. include: incrementing the reference count based on receiving (403) a request from a buffer consumer for at least the subset of the memory descriptors used by the I / O request; as well as The reference count is decremented based on receiving (405) a request from the buffer consumer to release at least the subset of the memory descriptors for use by the I / O request.

7. The method according to any one of claims 1 to 6, further comprising, based at least on receiving a request to register the buffer from a buffer consumer: creating (402) a buffer entry data structure (301) comprising a starting address for the buffer and a buffer length (303); and The buffer entry data structure is inserted (402) into the buffer entry list (115).

8. A method implemented at a computer system including a processor for caching memory descriptors across multiple input / output (I / O) requests, the method include: creating (404) a memory descriptor (304) describing a layout of a set of physical memory pages allocated to a buffer (111a), creating the memory descriptor includes allocating and locking the set of physical memory pages to the memory descriptor; Receiving a plurality of I / O requests on the buffer, for each of the plurality of I / O requests on the buffer: returning (403) at least a subset of the memory descriptors for use by the I / O request, and Using reference counting (305) to track the I / O requests pending on the memory descriptor; Based at least on the reference count indicating that there are no pending I / O requests on the memory descriptor, releasing (405) the memory descriptor, including unlocking the set of physical memory pages; as well as Based at least on receiving a request from a buffer consumer to register the buffer: creating (402) a buffer entry data structure (301) comprising a starting address for the buffer and a buffer length (303); and The buffer entry data structure is inserted (402) into the buffer entry list (115).

9. The method of claim 7 or 8, further comprising returning (402) the address of the buffer entry data structure to the buffer consumer.

10. The method of any one of claims 7 to 9, further comprising allocating and locking the set of physical memory pages to the memory descriptor based at least on: A mapping between the set of physical memory pages and references to the buffer entry data structure is added (402) to a page-to-buffer entry map (117).

11. The method of claim 10, further comprising based on a request from a memory manager (112) to release the identified physical memory page in the set of physical memory pages: Using the identified physical memory page, the reference to the buffer entry data structure is identified (406) from the page to buffer entry mapping.

12. The method according to claim 11, further comprising: include: identifying (406) the reference count within the buffer entry data structure; as well as Based at least on the reference count indicating that there is at least one pending I / O request on the memory descriptor, a flag (302) is set (406) within the buffer entry data structure to prohibit future I / O requests from using the memory descriptor.

13. The method according to any one of claims 1 to 12, wherein the buffer consumer is an IORing component and the buffer is a buffer registered by an IORing user.

14. A computer system for caching memory descriptors across multiple input / output (I / O) requests, include: processor; as well as A computer storage medium storing computer executable instructions executable by the processor to cause the computer system to at least: receiving a request to register a buffer from a buffer consumer; creating a memory descriptor that describes a layout of a set of physical memory pages allocated to the buffer, the creating the memory descriptor comprising allocating and locking the set of physical memory pages to the memory descriptor; Receiving a plurality of I / O requests on the buffer, for each of the plurality of I / O requests on the buffer: returning at least a subset of the memory descriptors for use by the I / O request, and Using a reference count to track pending I / O requests on the memory descriptor; as well as releasing the memory descriptor, including unlocking the set of physical memory pages, based at least on the reference count indicating that there are no pending I / O requests on the memory descriptor, in: An I / O request of the plurality of I / O requests comprises an offset and a length identifying a subset of the buffer, and wherein returning at least the subset of the memory descriptors for use by the I / O request comprises returning a partial memory descriptor corresponding to the offset and the length; or An I / O request of the plurality of I / O requests includes an offset and a length identifying the entire buffer, and wherein returning at least the subset of the memory descriptors for use by the I / O request includes returning all of the memory descriptors.