Method and device for processing virtual IO request, electronic equipment and storage medium
By using register groups to achieve multi-channel bidirectional parallel transmission in a virtualized environment, the real-time and reliability issues in VirtIO request processing are solved, and the response speed and efficiency of virtual IO requests are improved, especially suitable for small data requests and big data. Quick processing of requests.
Patent Information
- Application Number
- CN202410781516.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-06-18
AI Technical Summary
In a virtualized environment, VirtIO's IO request processing has real-time and reliability issues. Especially when the system is busy or multiple devices make frequent requests, timeouts or delayed scheduling may occur, and fast IO requests are inefficient, especially due to data Small requests need to pass a large number of context configuration items and sg_table structures, resulting in inefficiency.
By using the first register group and the second register group to generate interrupts respectively between the front-end driver and the back-end driver, multi-channel bidirectional parallel transmission is realized without joining the waiting queue for serial execution. The front-end driver writes the request to the first register group to trigger Interrupt, the back-end driver reads from it and forwards it to the target device. The processing result is written into the second register group to trigger an upstream interrupt. The front-end driver returns the result according to the interrupt.
It improves the real-time and reliability of virtual IO requests, reduces the waiting queue scheduling delay, improves the response speed of fast IO requests and the processing efficiency of big data requests, and realizes zero copy of memory.
Smart Images

Figure CN118779062A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of virtualization technology, and in particular to a method and device for processing virtual IO requests, an electronic device and a storage medium. Background Art
[0002] In the current virtualization environment, software-implemented VirtIO (an abstraction layer above the device in a paravirtualized hypervisor) is used as a virtual device interface. Hypervisor is a virtualization technology that allows multiple virtual machines to run on a physical computer and isolate them in different virtualization environments. Each virtual device driver of a virtual machine is divided into a front-end driver and a back-end driver. The front-end driver runs on the client virtual machine, receives service requests from the upper standard framework, converts them into hardware logic requests, sends these requests to the virtual queue, and then is uniformly scheduled by the VritIO management process and handed over to the back-end driver for processing. The back-end driver runs on the management host, receives requests from the front-end driver, forwards them to the physical device for processing, and returns the processing results to the front-end driver. When the device configuration information changes, the hypervisor generates an interrupt, and VirtIO uses this soft interrupt method to notify the front-end and back-end drivers to synchronize data. All virtual queues share this interrupt. This type of VritIO communication has the following disadvantages.
[0003] First, when the system is busy or multiple devices frequently send requests, the VritIO management process scheduling will be busy, and timeouts or delayed scheduling may occur, and the real-time and reliability of IO cannot be guaranteed. Second, in order to be compatible with all types of VirtIO requests, VirtIO has many context configuration items. In addition, the data buffer (memory that temporarily stores input and output data) requested by VirtIO is generally a virtual address with discontinuous physical addresses. In order to achieve zero copy of memory, the data structure of sg_table (hash table of physical memory) is required to save the starting address and length of multiple discontinuous physical addresses corresponding to this virtual address. Each request must pass the context configuration and sg_table structure. However, in actual scenarios, there are often requests with small data volumes and requiring fast transmission, such as fence synchronization, status query, etc. For such scenarios with small data volumes such as fast IO requests and event notifications, the VirtIO mechanism is very inefficient. Summary of the invention
[0004] The present invention provides a method and device for processing virtual IO requests, an electronic device and a storage medium, which can optimize the processing process of virtual IO requests, improve the real-time performance and reliability of virtual IO requests, and realize the response of fast IO requests.
[0005] In one aspect of the present invention, a method for processing a virtual IO request is provided. The method comprises: a front-end driver receives a first request from an upper layer, and writes the first request into a first register group to trigger a first interrupt; a back-end driver reads the first request from the first register group according to the first interrupt, and forwards the first request to a target device to obtain a request processing result of the first request; the back-end driver writes the request processing result into a second register group to trigger a second interrupt; and the front-end driver returns the request processing result to the upper layer according to the second interrupt.
[0006] In another aspect of the present invention, a device for processing a virtual IO request is provided. The device includes: a first register group configured to trigger a first interrupt; a second register group configured to trigger a second interrupt; a front-end driver configured to receive a first request from an upper layer, write the first request to the first register group to trigger the first interrupt, and return the request processing result of the first request to the upper layer according to the second interrupt; and a back-end driver configured to read the first request from the first register group according to the first interrupt, forward the first request to a target device to obtain the request processing result of the first request, and write the request processing result to the second register group to trigger the second interrupt.
[0007] In another aspect of the present invention, an electronic device is provided, comprising a memory configured to store a computer program and a processor configured to execute the computer program to perform the above method for processing a virtual IO request.
[0008] In another aspect of the present invention, a computer-readable medium is provided, wherein a computer program is stored on the medium, and the computer program is executed by a processor to implement the above-mentioned method for processing a virtual IO request.
[0009] According to the technical solution of the present invention, the front-end driver writes the first request from the upper layer into the first register group to trigger the first interrupt, and the back-end driver forwards the first request to the target device process for processing according to the first interrupt to obtain the request processing result, and at the same time, the back-end driver writes the request processing result into the second register group to trigger the uplink interrupt, and the front-end driver returns the request processing result to the upper layer according to the second interrupt. The front-end driver and the back-end driver generate the first interrupt and the second interrupt respectively through the first register group and the second register group, realizing multi-channel bidirectional parallel transmission, without joining the waiting queue for serial execution, thereby improving the real-time performance and reliability of the virtual IO request. At the same time, the request from the upper layer only needs to be read, written and stored in the first register group and the second register group, thereby improving the response speed of the virtual IO request. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 A flowchart of a method for processing a virtual IO request according to an embodiment of the present invention;
[0011] Figure 2 An architectural diagram of a method for processing a virtual IO request according to an embodiment of the present invention;
[0012] Figure 3 Another flow chart of a method for processing a virtual IO request according to an embodiment of the present invention;
[0013] Figure 4 Another flow chart of a method for processing a virtual IO request according to an embodiment of the present invention;
[0014] Figure 5 A schematic diagram of the structure of a device for processing a virtual IO request according to an embodiment of the present invention;
[0015] Figure 6 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0016] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0017] In the prior art, each virtual device driver of a virtual machine is divided into a front-end driver and a back-end driver. The front-end driver runs on the client virtual machine, receives service requests from the upper standard framework, converts them into hardware logic requests, sends these requests to the virtual queue, and then is uniformly scheduled by the VritIO management process and handed over to the back-end driver for processing. The back-end driver runs on the management host, receives requests from the front-end driver, forwards them to the physical device for processing, and returns the processing results to the front-end driver. VirtIO uses a soft interrupt method (when the device configuration information changes, the hypervisor will generate an interrupt) to notify the front-end and back-end drivers to synchronize data. All virtual queues share this interrupt. This type of VritIO communication has the following disadvantages.
[0018] First, when the system is busy or multiple devices frequently send requests, the VritIO management process scheduling will be busy, and timeouts or delayed scheduling may occur, and the real-time and reliability of IO cannot be guaranteed. Second, in order to be compatible with all types of VirtIO requests, VirtIO has many context configuration items. In addition, the data buffer of VirtIO requests is generally a virtual address with discontinuous physical addresses. In order to achieve zero copy of memory, the sg_table data structure is required to save the starting address and length of multiple discontinuous physical addresses corresponding to this virtual address. Each request must pass the context configuration and sg_table structure. However, in actual scenarios, there are often requests with small data volumes and requiring fast transmission, such as fence synchronization, status query, etc. For such scenarios with small data volumes such as fast IO requests and event notifications, the VirtIO mechanism is very inefficient.
[0019] In order to solve at least the above technical problems, the present disclosure provides a method for processing virtual IO requests. According to the present disclosure, the front-end driver writes the first request from the upper layer into the first register group to trigger the first interrupt, and the back-end driver forwards the first request to the target device process for processing according to the first interrupt to obtain the request processing result, and at the same time, the back-end driver writes the request processing result into the second register group to trigger the uplink interrupt, and the front-end driver returns the request processing result to the upper layer according to the second interrupt. In this way, according to the embodiment of the present disclosure, the first interrupt and the second interrupt can be generated respectively between the front-end driver and the back-end driver through the first register group and the second register group, realizing multi-channel bidirectional parallel transmission, without joining the waiting queue for serial execution, thereby improving the real-time and reliability of the virtual IO request. At the same time, the request from the upper layer only needs to be read, written and stored in the first register group and the second register group, thereby improving the response speed of the virtual IO request.
[0020] Hereinafter, the technical solution according to the present disclosure will be described with reference to specific embodiments and in conjunction with the accompanying drawings.
[0021] Figure 1 1 is a flow chart showing a method 100 for processing a virtual IO request according to an embodiment of the present disclosure. Figure 1 The method 100 includes the following steps 102 to 108.
[0022] In step 102, the front-end driver receives a first request from an upper layer, and writes the first request into a first register group to trigger a first interrupt.
[0023] In some embodiments, writing the first request into the first register group includes: if the front-end driver determines that the size of the request data corresponding to the first request is not greater than a threshold, the front-end driver writes the request data into a shared data register of the first register group. In this way, for upper-layer requests with smaller request data, an interrupt can be directly generated based on the first register group to achieve rapid response processing to the upper-layer request, avoiding the problem of waiting delay, and effectively improving the processing efficiency of small data requests.
[0024] In some embodiments, writing the first request to the first register group includes: if the front-end driver determines that the size of the request data corresponding to the first request is greater than a threshold, the front-end driver writes the handle of the request data to the shared data register of the first register group, and the method also includes: writing the request data to the first memory in the continuous memory pool, and sharing the first memory to the target device through the back-end driver for the target device to process the first request. In this way, for upper-level requests with larger request data, the first memory can be shared to the target device through the back-end driver, realizing zero copy of memory between the front-end driver and the back-end driver, thereby improving the processing efficiency of large data requests, and further improving the real-time and reliability of virtual IO requests.
[0025] In some embodiments, writing the first request into the first register group to trigger the first interrupt includes: the front-end driver writes the request type corresponding to the first request into the request register of the first register group; and in response to the request type being written into the request register, triggering the first interrupt. In this way, after the request type is written into the first register group, the interrupt is directly triggered, and then the upper layer request is waited for completion, without joining the waiting queue to wait for scheduling, thereby avoiding timeout and non-response or delayed scheduling when the management process scheduling is busy.
[0026] In some embodiments, the first request includes a request type and request data, the first register group includes a first request register and a first shared data register, wherein the front-end driver receives the first request from the upper layer, and writes the first request into the first register group to trigger the first interrupt, including: the front-end driver of the client receives the first request associated with the upper-layer framework service; the front-end driver writes the request type into the first request register to trigger the first interrupt, and writes the request data into the second memory; and the front-end driver writes the memory handle of the second memory into the first shared data register. In this way, while the request type is written into the first request register to directly trigger the interrupt, the request data is written into the first shared data register for temporary storage to wait for the completion of the upper-layer request, so as to realize the parallel processing of the upper-layer request, avoid the situation of timeout and non-response or delayed scheduling when the management process scheduling is busy, and improve the real-time performance and reliability of the virtual IO request.
[0027] In step 104, the backend driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device to obtain a request processing result of the first request.
[0028] In some embodiments, the backend driver reads the first request from the first register group according to the first interrupt and forwards the first request to the target device, including: the backend driver receives the first interrupt and calls the interrupt callback function; reads the request type and the request data from the first register group according to the interrupt callback function; and forwards the request type and the request data to the target device. In this way, the backend driver directly reads the request type and the request data from the first register group according to the first interrupt and forwards them, so that the upper-layer request does not need to be scheduled through the waiting queue in the management service process, but is directly responded to and processed by the first interrupt, thereby improving the request response speed.
[0029] In some embodiments, the backend driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device, including: the backend driver receives the first interrupt and calls the interrupt callback function; reads the request type and the handle of the request data from the first register group according to the interrupt callback function; the backend driver converts the handle of the request data into a physical address; and forwards the request type and the physical address to the target device. In this way, the backend driver directly reads the request type and the request data from the first register group according to the first interrupt, without waiting for queue scheduling, thereby improving the request response speed. At the same time, the backend driver converts the handle of the request data into a physical address, so that the target device can directly access the first memory after obtaining the physical address, realizing zero-copy memory processing, and there is no need to pass the relevant data structure of the request, thereby improving the request processing efficiency.
[0030] In some embodiments, the backend driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device, including: the backend driver of the host calls the first interrupt callback function according to the first interrupt; the backend driver reads the request type in the first request register and the memory handle in the first shared data register according to the first interrupt callback function, and adds the request type and the memory handle to the request queue; the backend driver forwards the request type and the memory handle to the target device through the request queue. In this way, after the backend driver receives the first interrupt, it reads the request type and request data of the upper layer request from the corresponding register, adds them to the request queue, and forwards them one by one to the target device for processing, thereby avoiding the problem of excessive load on the target device.
[0031] In some embodiments, the backend driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device, including: the backend driver reads the request type from the first request register and reads the memory handle from the first shared data register; the backend driver converts the memory handle into a physical address; and the backend driver forwards the request type and the physical address to the target device. In this way, the request type is read from the first request register, and the memory handle is read from the first shared data register, so that the request data is isolated, which facilitates the subsequent direct reading of the corresponding data from the register and improves the data reading efficiency.
[0032] In step 106, the backend driver writes the request processing result into a second register group to trigger a second interrupt.
[0033] In some embodiments, the backend driver writes the request processing result into the second register group to trigger the second interrupt, including: the backend driver writes the completion type corresponding to the processing of the target device into the request register of the second register group to trigger the second interrupt. In this way, the completion type corresponding to the processing of the target device is written into the second register group to trigger the second interrupt, thereby quickly responding to the upper layer request without queue scheduling, thereby improving the request processing efficiency.
[0034] In some embodiments, the first register group includes a first interrupt status register, the second register group includes a second request register, the request processing result includes a completion type, wherein the backend driver writes the request processing result to the second register group to trigger the second interrupt includes: the backend driver of the host writes the completion type to the second request register to trigger the second interrupt, and the second interrupt is used to read and clear the interrupt status in the first interrupt status register. In this way, the second interrupt triggered by the backend driver reads and clears the interrupt status in the first interrupt status register to respond to the completion of the current request processing, avoiding repeated execution of the same request.
[0035] In step 108, the front-end driver returns the request processing result to the upper layer according to the second interrupt.
[0036] In some embodiments, the front-end driver returns the request processing result to the upper layer according to the second interruption, including: the front-end driver receives the second interruption and calls an interruption reply function; and wakes up the waiting thread according to the interruption reply function to return the request processing result to the upper layer. In this way, since it takes a certain amount of time for the back-end driver and the target device to process the request, the front-end driver creates a waiting thread to monitor the request processing result subsequently returned by the back-end driver, thereby returning the request processing result to the upper layer in a timely manner.
[0037] In some embodiments, triggering a first interrupt includes: writing a first interrupt status into an interrupt status register of the second register group, and after triggering the first interrupt, the method further includes: reading and clearing the first interrupt status from the interrupt status register of the second register group, and triggering a second interrupt includes: writing a second interrupt status into an interrupt status register of the first register group, and after triggering the second interrupt, the method further includes: reading and clearing the second interrupt status from the interrupt status register of the first register group. In this way, the first interrupt triggered by the front-end driver and the second interrupt triggered by the back-end driver are respectively stored through the interrupt status registers in different register groups, so as to realize the bidirectional transmission of the request data and the request result.
[0038] In some embodiments, the method may further include: after writing the first request to the first register group to trigger the first interrupt and before the back-end driver writes the request processing result to the second register group to trigger the second interrupt, the front-end driver receives a second request from the upper layer and writes the second request to the first register group to trigger a third interrupt; the back-end driver reads the second request from the first register group according to the third interrupt and forwards the second request to the target device to obtain the request processing result of the second request; after the back-end driver writes the request processing result to the second register group to trigger the second interrupt, the back-end driver writes the request processing result of the second request to the second register group to trigger the fourth interrupt; and the front-end driver returns the request processing result of the second request to the upper layer according to the fourth interrupt. In this way, multiple front-end drivers in the client can send requests to the back-end driver in parallel. Compared with the method of joining the waiting queue for serial execution, the present invention can avoid the situation of timeout and non-response or delayed scheduling when the management process scheduling is busy.
[0039] In some embodiments, the method may further include: after the back-end driver writes the request processing result into the second register group to trigger the second interrupt and before the front-end driver returns the request processing result to the upper layer, the front-end driver receives a third request from the upper layer and writes the third request into the first register group to trigger the fifth interrupt; the back-end driver reads the third request from the first register group according to the fifth interrupt and forwards the third request to the target device to obtain the request processing result of the third request; the back-end driver writes the request processing result of the third request into the second register group to trigger the sixth interrupt; and the front-end driver returns the request processing result of the third request to the upper layer according to the sixth interrupt. In this way, multi-channel bidirectional parallel transmission of requests and request processing results can be achieved, thereby improving the request processing efficiency.
[0040] Figure 2 is an architectural diagram showing a method for processing a virtual IO request according to an embodiment of the present disclosure. Figure 2 In some embodiments, the front-end driver runs in a guest virtual machine (hereinafter referred to as GUEST), and the back-end driver runs in a management host (hereinafter referred to as HOST). A first register group (hereinafter referred to as A register group) and a second register group (hereinafter referred to as B register group) are also provided. The front-end driver implements request response with the back-end driver based on the uplink and downlink interrupts of the register and the shared memory mechanism RKVMEM.
[0041] In some embodiments, the GUEST and the HOST have different read and write permissions for register group A and register group B. Specifically, the GUEST can read and write register group A, and can only read register group B. The HOST can only read register group A, and can read and write register group B.
[0042] In some embodiments, an uplink interrupt route and a downlink interrupt route are set to achieve bidirectional data transmission. The uplink interrupt route is set to the guest, and the guest's processor can receive the downlink interrupt. The downlink interrupt route is set to the host, and the host's processor can receive the uplink interrupt.
[0043] In some embodiments, the relevant data in the register is read and written through the uplink interrupt and the downlink interrupt. Writing the request type in the request register of group A will trigger the downlink interrupt. After the downlink interrupt is triggered, the request status can be read and cleared in the interrupt register of group B. Writing the completion type in the request register of group B will trigger the uplink interrupt. After the uplink interrupt is triggered, the request status can be read and cleared in the interrupt register of group A.
[0044] Figure 3 2 is a flow chart showing a method 200 for processing a virtual IO request according to an embodiment of the present disclosure. Figure 3 The method 200 implements request processing for small data requests, including the following steps 202 to 212.
[0045] In step 202, the GUEST front-end driver receives a first request from an upper layer.
[0046] In step 204, the GUEST front-end driver writes the request type of the first request into the request register of group A, triggering the first interrupt, namely the A2B interrupt; at the same time, the GUEST front-end driver writes the memory handle of the request data of the first request into the shared data register of group A, and creates a waiting thread to wait for the completion of the first request.
[0047] In step 206, the HOST backend driver receives the A2B interrupt and calls the interrupt callback function.
[0048] In step 208, the HOST backend driver reads the GUEST request type and memory handle from the group A request register and the group A shared data register through the interrupt callback function, adds it to the request queue, and forwards it to the driver of the target device for processing through the request queue.
[0049] In step 210, the driver processing of the target device is completed, the processing result of the first request is obtained, the completion type of the first request is written into the request register of group B, and the second interrupt, namely, the B2A interrupt, is triggered; wherein the completion type of the first request includes success or error.
[0050] In step 212, when the GUEST front-end driver receives the B2A interrupt, it calls the interrupt callback function, wakes up the waiting thread, and returns the processing result of the first request to the upper layer through the waiting thread.
[0051] Figure 4 3 is a flow chart showing a method 300 for processing a virtual IO request according to an embodiment of the present disclosure. Figure 4 The method 300 implements request processing for big data requests, including steps 302 to 318.
[0052] In step 302, the GUEST front-end driver receives a second request from an upper layer.
[0053] In step 304, the GUEST front-end driver writes the request type of the second request into the request register of group A, triggering the third interrupt, namely, the A2B interrupt; the GUEST front-end driver allocates a piece of memory from the continuous memory pool, and obtains the memory handle handle corresponding to the memory.
[0054] In step 306, the GUEST front-end driver writes the memory handle handle into the shared data register.
[0055] In step 308, the HOST backend driver receives the A2B interrupt and calls the interrupt callback function.
[0056] In step 310, the HOST backend driver reads the GUEST request type from the request register of group A through the interrupt callback function; the HOST backend driver reads the memory handle handle from the shared data register of group A through the interrupt callback function, and converts the memory handle handle into a physical address.
[0057] In step 312, the HOST backend driver sends the request type and physical address to the driver of the target device.
[0058] In step 314, the driver of the target device maps the physical address to the virtual machine address to access the memory, or directly sets the physical address to the register of the hardware processing unit for processing by the hardware processing unit, for example, the memory physical address of the error-reporting encoded video is handed over to the device's video codec unit VPU for processing.
[0059] In step 316, the driver processing of the target device is completed, the processing result of the second request is obtained, the completion type of the second request is written into the request register of group B, and the fourth interrupt, ie, B2A interrupt, is triggered.
[0060] In step 318, when the GUEST front-end driver receives the B2A interrupt, it calls the interrupt callback function, wakes up the waiting thread, and returns the processing result of the second request to the upper layer through the waiting thread.
[0061] In the prior art, in order to improve the efficiency of data memory access, the multimedia hardware processing units on the device (such as graphics processing unit GPU, video codec unit VPU, display processing and synthesis unit VOP, 2D graphics processor RGA, etc.) can directly access DDR memory without the participation of CPU. In the standard virtual machine architecture, for data security, the guest is generally not allowed to directly access the DDR memory, and memory mapping and access control need to be done in the hypervisor. Under this architecture, the continuous memory accessed by the guest is actually the memory mapped by the hypervisor. These memories are continuous memories for the guest, but they are not necessarily real physical continuous memories. Therefore, the multimedia hardware processing unit cannot directly access these memories. It is necessary to convert these memories into multiple blocks of physically continuous memories, and enable the memory management unit MMU under the CPU or copy the data to the specified physical continuous memory. The multimedia hardware processing unit can access these memories, resulting in very low access efficiency.
[0062] The present invention is aimed at the characteristic that the multimedia hardware processing unit can directly access the physical memory, and in combination with the memory access characteristic of the virtual machine, a shared memory mechanism RKMEM, i.e., the above method 300, is established. A piece of physically continuous memory is allocated in hypervisor and handed over to the shared memory mechanism RKMEM for management, and the shared memory mechanism RKMEM is responsible for the access control of this piece of physically continuous memory, and provides an interface to realize memory allocation and the conversion between the memory handle and the physical address. When the GUEST needs memory, the memory allocation interface can be called to return the memory handle and the virtual machine address that the GUEST maps and can directly access. The GUEST front-end driver accesses this piece of memory through this virtual machine address, and the HOST back-end driver converts the memory handle of this piece of memory into a physical address through the interface of the shared memory mechanism RKMEM, and writes into the register of the multimedia hardware processing unit, and the multimedia hardware processing unit can access this piece of physical memory. Through this shared memory mechanism RKMEM mechanism, the multimedia hardware processing unit and the GUEST front-end driver can access the same piece of memory, and zero copy of memory can be realized under the condition of ensuring mutual exclusion of access, so as to effectively improve the access efficiency.
[0063] According to another aspect of the present invention, Figure 5 4 is a block diagram showing an apparatus 400 for processing a virtual IO request according to an embodiment of the present invention. Figure 5, the device 400 includes a first register group 402, a second register group 404, a front-end driver 406, and a back-end driver 408. The first register group 402 is configured to trigger a first interrupt. The second register group 404 is configured to trigger a second interrupt. The front-end driver 406 is configured to receive a first request from an upper layer, and write the first request to the first register group 402 to trigger the first interrupt, and is configured to return a request processing result of the first request to the upper layer according to the second interrupt. The back-end driver 408 is configured to read the first request from the first register group 402 according to the first interrupt, and forward the first request to a target device to obtain a request processing result of the first request, and is configured to write the request processing result to the second register group 404 to trigger the second interrupt.
[0064] In some embodiments, the device 400 includes multiple data transmission channels, each of which includes a first register group 402 and a second register group 404. The first register group 402 and the second register group 404 each include a request register, an interrupt register and a 64-bit shared data register. The request register is used to save the request type, the interrupt register is used to save the interrupt status, and the shared data register is used to save the memory handle or physical address of the data memory. In this way, the mailbox delivery function is simulated to achieve multi-channel bidirectional data transmission, thereby improving the real-time performance and reliability of IO requests.
[0065] According to yet another aspect of the present invention, Figure 6 Schematic diagram of an electronic device 500 according to an embodiment of the present invention. Figure 6 The electronic device 500 includes a memory 502, a processor 504, and a computer program stored in the memory 502 and executable on the processor 504. When the processor 504 executes the computer program, each step of the method for processing a virtual IO request as described above is implemented.
[0066] According to another aspect of the present invention, a computer readable medium is provided, wherein a computer program is stored on the computer readable medium, and the computer program is executed by a processor to implement the method for processing a virtual IO request as described above.
[0067] In summary, the present invention provides a method and device for processing virtual IO requests, an electronic device and a storage medium. The front-end driver realizes bidirectional parallel transmission in the first register group and the second register group. Compared with the method in the prior art that sends the upper layer request to the request queue and then schedules the transmission by VritIO according to the priority and first-in-first-out principle, the multiple front-end drivers of the present invention send IO requests to the back-end driver in parallel without joining the request queue for serial scheduling and execution, which effectively improves the real-time performance and reliability of the virtual IO request. For small data requests, the front-end driver only needs to directly trigger the interrupt through the register to respond quickly, ensuring that the line response time is controlled at the nanosecond level, which effectively improves the response speed of small data requests. At the same time, for large data requests, the front-end driver and the target device realize zero copy of the memory of the front-end driver and the back-end driver through shared memory, effectively improving data access efficiency. The present invention comprehensively improves the response efficiency of virtual IO requests by optimizing the processing process of different IO requests.
[0068] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for processing a virtual IO request, characterized in that: include: The front-end driver receives a first request from an upper layer, and writes the first request into a first register group to trigger a first interrupt; The back-end driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device to obtain a request processing result of the first request; The back-end driver writes the request processing result into a second register group to trigger a second interrupt; as well as The front-end driver returns the request processing result to the upper layer according to the second interrupt.
2. The method according to claim 1, characterized in that Writing the first request into the first register group comprises: If the front-end driver determines that the size of the request data corresponding to the first request is not greater than a threshold, the front-end driver writes the request data into the shared data register of the first register group.
3. The method according to claim 2, characterized in that Writing the first request into the first register group comprises: If the front-end driver determines that the size of the request data corresponding to the first request is greater than a threshold, the front-end driver writes the handle of the request data into the shared data register of the first register group, and The method further includes: writing the request data into a first memory in a continuous memory pool, and sharing the first memory with the target device through the back-end driver, so that the target device processes the first request.
4. The method according to claim 2 or 3, characterized in that: Writing the first request into a first register group to trigger a first interrupt comprises: The front-end driver writes a request type corresponding to the first request into a request register of the first register group; and In response to the request type having been written to the request register, the first interrupt is triggered.
5. The method according to claim 4, characterized in that The back-end driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device, including: The back-end driver receives the first interrupt and calls an interrupt callback function; reading the request type and the request data from the first register group according to the interrupt callback function; and The request type and the request data are forwarded to the target device.
6. The method according to claim 4, characterized in that The back-end driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device, including: The back-end driver receives the first interrupt and calls an interrupt callback function; Reading the request type and the handle of the request data from the first register group according to the interrupt callback function; The backend driver converts the handle of the request data into a physical address; and The request type and the physical address are forwarded to the target device.
7. The method according to claim 1, characterized in that Writing the request processing result into the second register group by the back-end driver to trigger the second interrupt includes: The back-end driver writes a completion type corresponding to the process of the target device into a request register of the second register group to trigger the second interrupt.
8. The method according to claim 1, characterized in that The front-end driver returns the request processing result to the upper layer according to the second interruption, including: The front-end driver receives the second interrupt and calls an interrupt reply function; and The waiting thread is woken up according to the interrupt reply function to return the request processing result to the upper layer.
9. The method according to claim 1, characterized in that: The first request includes a request type and request data, the first register group includes a first request register and a first shared data register, The front-end driver receives a first request from an upper layer, and writes the first request into a first register group to trigger a first interrupt, comprising: Receiving, by a front-end driver of a client, a first request associated with an upper-layer framework service; The front-end driver writes the request type into the first request register to trigger the first interrupt, and writes the request data into a second memory; and The front-end driver writes the memory handle of the second memory into the first shared data register.
10. The method according to claim 9, characterized in that The back-end driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device, including: The back-end driver of the host calls a first interrupt callback function according to the first interrupt; The backend driver reads the request type in the first request register and the memory handle in the first shared data register according to the first interrupt callback function, and adds the request type and the memory handle to a request queue; The backend driver forwards the request type and the memory handle to the target device through the request queue.
11. The method according to claim 1, characterized in that: The first register group includes a first interrupt status register, the second register group includes a second request register, the request processing result includes a completion type, The back-end driver writes the request processing result into the second register group to trigger the second interrupt, which includes: the back-end driver of the host writes the completion type into the second request register to trigger the second interrupt, and the second interrupt is used to read and clear the interrupt status in the first interrupt status register.
12. The method according to claim 9, characterized in that The back-end driver reads the first request from the first register group according to the first interrupt, and forwards the first request to the target device, including: The back-end driver reads the request type from the first request register and reads the memory handle from the first shared data register; The backend driver converts the memory handle into a physical address; and The backend driver forwards the request type and the physical address to the target device.
13. The method according to claim 1, characterized in that Triggering the first interrupt includes: writing the first interrupt status into the interrupt status register of the second register group, and after triggering the first interrupt, the method further includes: reading and clearing the first interrupt status from the interrupt status register of the second register group, Triggering the second interrupt includes: writing a second interrupt status into an interrupt status register of the first register group, and after triggering the second interrupt, the method further includes: reading and clearing the second interrupt status from the interrupt status register of the first register group.
14. The method according to claim 1, characterized in that Also includes: After writing the first request into the first register group to trigger the first interrupt and before the back-end driver writes the request processing result into the second register group to trigger the second interrupt, the front-end driver receives a second request from an upper layer and writes the second request into the first register group to trigger the third interrupt; The back-end driver reads the second request from the first register group according to the third interrupt, and forwards the second request to the target device to obtain a request processing result of the second request; After the backend driver writes the request processing result into the second register group to trigger the second interrupt, the backend driver writes the request processing result of the second request into the second register group to trigger the fourth interrupt; as well as The front-end driver returns the request processing result of the second request to the upper layer according to the fourth interrupt.
15. The method according to claim 1, characterized in that Also includes: After the back-end driver writes the request processing result into the second register group to trigger a second interrupt and before the front-end driver returns the request processing result to the upper layer, the front-end driver receives a third request from the upper layer and writes the third request into the first register group to trigger a fifth interrupt; The back-end driver reads the third request from the first register group according to the fifth interrupt, and forwards the third request to the target device to obtain a request processing result of the third request; The back-end driver writes the request processing result of the third request into the second register group to trigger a sixth interrupt; as well as The front-end driver returns the request processing result of the third request to the upper layer according to the sixth interrupt.
16. A device for processing a virtual IO request, characterized in that: include: A first register group configured to trigger a first interrupt; a second register set configured to trigger a second interrupt; a front-end driver configured to receive a first request from an upper layer, write the first request into the first register group to trigger the first interrupt, and return a request processing result of the first request to the upper layer according to the second interrupt; as well as A back-end driver is configured to read the first request from the first register group according to the first interrupt, and forward the first request to the target device to obtain a request processing result of the first request, and is configured to write the request processing result into the second register group to trigger the second interrupt.
17. An electronic device, characterized in that: include: a memory configured to store an executable program; as well as A processor configured to execute the program to perform the method according to any one of claims 1 to 15.
18. A computer readable medium having a computer program stored thereon, characterized in that: The computer program is executed to implement the method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Virtual memory driving method and driver
CN105389133A
Virtualization method and device
CN111381926A
Data transmission method, device and equipment and readable storage medium
CN112463307A
DMA (direct memory access) interrupt configuration method and device for virtual machine direct PCIe (peripheral component interface express) device, product and medium
CN117555832A
Xen para-virtualization agent-free real-time backup method, system and recovery method
CN117851133A
Cited By
Acceleration processing method, management node, storage medium and computer program product
CN121541978A
