I / O request processing method and device
By issuing I/O requests to other threads on the host for processing, the blocking problem of virtual CPU threads when processing I/O requests is solved, and the processing efficiency and system performance of virtual CPU are improved.
Patent Information
- Application Number
- CN202210376965.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-11
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2042-04-11
AI Technical Summary
In a virtualized environment, virtual CPU threads need to transfer to the Host context when processing I/O requests, resulting in the virtual CPU being blocked and affecting processing efficiency.
By sending the I/O request to other threads running on the host for processing, instead of being directly processed by the virtual CPU thread, the virtual CPU thread directly returns to the Guest context after the issuance is completed.
It reduces the blocking time of the virtual CPU, improves the processing efficiency of the virtual CPU, and improves the overall performance of the system by processing I/O requests in parallel.
Smart Images

Figure CN114741194B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of computer virtualization technology, and more particularly, to a method and device for processing an I / O request. Background Art
[0002] In the prior art, when a virtual CPU (central processing unit) thread running in a host needs to access an external device, it is implemented in the form of an I / O (IN / OUT, write / read) request, and during the processing, the virtual CPU thread needs to switch from the Guest context to the Host context to perform virtualization processing on the I / O request, and then return to the Guest context. For the virtual CPU thread, during the process of virtualizing the I / O request, the virtual CPU thread is in a state of suspending the execution of the virtual machine code, that is, the virtual CPU is in a blocked state. Summary of the invention
[0003] In view of this, one or more embodiments of the present specification provide a method and device for processing an I / O request.
[0004] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0005] According to a first aspect of one or more embodiments of this specification, a method for processing an I / O request is proposed, which is applied to a virtual CPU thread running on a host CPU, and the virtual CPU thread is allocated to a virtual machine deployed on the host, and the method includes:
[0006] When an I / O request is received, the guest context is transferred to the host context;
[0007] The I / O request is sent to other threads running on the host for processing, and the Guest context is returned after the sending is completed.
[0008] According to a second aspect of one or more embodiments of the present specification, a device for processing an I / O request is provided, which is applied to a virtual CPU thread running on a host CPU, wherein the virtual CPU thread is allocated to a virtual machine deployed on the host, and the device comprises:
[0009] The receiving unit is used to transfer from the Guest context to the Host context when receiving an I / O request;
[0010] The sending unit is used to send the I / O request to other threads running on the host for processing, and return the Guest context after the sending is completed.
[0011] According to a third aspect of one or more embodiments of this specification, there is provided a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0012] According to a fourth aspect of one or more embodiments of the present specification, there is provided an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method described in the first aspect are implemented.
[0013] In the technical solution provided in this specification, the I / O request is sent to other threads running on the host for processing, and the received I / O request is virtualized by other threads running on the host instead of the virtual CPU thread that accesses the external device, and the virtual CPU thread directly returns to the Guest context. The above method reduces the blocking time of the virtual CPU and improves the processing efficiency of the virtual CPU. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 It is a schematic diagram of an I / O request processing device architecture provided by an exemplary embodiment of this specification;
[0015] Figure 2 is a schematic diagram of a virtual machine architecture provided by an exemplary embodiment of this specification;
[0016] Figure 3 It is a flowchart of a method for processing an I / O request provided by an exemplary embodiment of this specification;
[0017] Figure 4 It is a flowchart of a specific method for processing an I / O request provided by an exemplary embodiment of this specification;
[0018] Figure 5 is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of this specification;
[0019] Figure 6 It is a schematic diagram of a message forwarding device provided by an exemplary embodiment of this specification. DETAILED DESCRIPTION
[0020] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0021] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0022] In order to reduce the time spent on virtual CPU blocking, release the processing power of the virtual CPU to execute virtual machine programs, and thus improve the processing efficiency of the virtual CPU, this specification proposes a method for processing I / O requests, which is applied to a virtual CPU thread running on a host CPU. The virtual CPU thread is assigned to a virtual machine deployed on the host. Several virtual CPU threads may be running on the virtual machine. The virtual machine manages the physical processor, i.e., the host CPU, and is responsible for scheduling and switching the virtual CPU threads. The virtual CPU thread can effectively reduce the blocking time by sending the I / O request to other threads running on the host for processing, and return to the Guest context after the sending is completed. The virtual processing of the I / O request is completed through other threads, thereby improving the processing efficiency of the virtual CPU.
[0023] Figure 1 This is a schematic diagram of the architecture of an I / O request processing device shown in this specification. Figure 1 As shown, it may include a host 11 and a virtual machine 12 deployed on the host, a network 13, and electronic devices 14 and 15.
[0024] The host 11 is a virtual server hosted by an independent host or a host cluster, and the virtual machine 12 is deployed in the independent host or the host cluster, and is allocated with at least one virtual CPU thread. During operation, the host 11 may be configured with an I / O request processing device, which may be implemented in software and / or hardware to process the received I / O request.
[0025] Electronic device 14 or electronic device 15 refers to a type of electronic device that can be used by a user. In fact, the user can obviously also use electronic devices such as the following types: mobile phones, tablet devices, laptops, PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smart watches, etc.), etc., and one or more embodiments of this specification do not limit this. During operation, electronic device 14 can allow the user to issue I / O requests for external device resources.
[0026] The network 13 for interaction between the electronic device 14 or the electronic device 15 and the host 11 may include various types of wired or wireless networks. In one embodiment, the network 13 may include a public switched telephone network (PSTN) and the Internet.
[0027] Computer virtualization refers to the use of virtualization technology to virtualize a computer into multiple logical computers. Multiple logical computers can be run on a computer at the same time, each logical computer can run a different operating system, and applications can run in independent spaces without affecting each other, thereby significantly improving the computer's work efficiency. Virtualization technology allows one or more guest operating systems (Guest Operating System, Guest OS) to run under a host operating system (Host Operating System, Host OS). Current virtualization technologies are mainly divided into three types: full virtualization, which is virtualization for computers and operating systems; resource virtualization, which refers to the virtualization of specific computer system resources, such as memory, network resources, etc.; and application virtualization. In full virtualization technology, the host intercepts the client's access request to the I / O device, and then simulates the real hardware through software. This method is very transparent to the client, and there is no need to consider the underlying hardware and no need to modify the operating system. The operating system of the multiple logical computers running on a computer, namely the Guest OS, is equivalent to multiple virtual CPU threads running in the Host OS. For example Figure 2 1. The virtual machine 2111 is established in the host 21 by full virtualization technology in an exemplary embodiment of the present specification. The virtual CPU thread 1, the virtual CPU thread 2 and the virtual CPU thread 3 are allocated to the virtual machine 2111.
[0028] In an exemplary embodiment of the present specification, the above three virtual CPU threads can be formed by a virtual machine monitor (Hypervisor) by differentiating the host CPU through full virtualization technology, and the VMM (Virtual Machine Monitor, virtual machine management control software) performs scheduling and switching between the virtual CPU threads.
[0029] In an exemplary embodiment of the present specification, the above-mentioned VMM includes KVM (Kernel-based Virtual Machine) and / or Qemu. Among them, KVM is a loadable module of the Linux kernel. By calling the kernel function of Linux itself, it realizes the underlying virtualization of the CPU and the virtualization of the memory, making the Linux kernel a virtualization layer, requiring x86 architecture and hardware that supports virtualization functions, and is a full virtualization architecture. In essence, KVM is a driver for managing virtual hardware devices. The driver uses the character device / dev / kvm (created by KVM itself) as a management interface, and is mainly responsible for the creation of virtual CPUs, the allocation of virtual memory, the reading and writing of virtual CPU registers, and the operation of virtual CPUs. Qemu is a set of free software for simulating processors written by Fabrice Bellard. It is a complete software that can run independently and can independently simulate the entire computer, including CPU, memory, and I / O devices. QEMU has two working modes: system mode, which can simulate the entire computer system, and user mode, which can run programs on platforms other than the current hardware platform (for example, running programs running on the ARM platform on the x86 platform).
[0030] Based on the above characteristics of QEUM, a new architecture QEMU-KVM is generated. From the introduction of the KVM kernel module above, we can know that KVM is only responsible for the virtualization of CPU and memory. After loading KVM, users can further use the interface provided by KVM to create virtual machines by tools. However, KVM alone is not enough. Users cannot directly control the kernel to create virtual machines, allocate virtual CPUs, etc. KVM only provides the creation interface, and there must be tools running in user space to cooperate with it. QEMU is used as this tool to cooperate with KVM, and finally a new virtual machine architecture QEMU-KVM is formed. In QEMU-KVM, KVM runs in the kernel space and QEMU runs in the user space, cooperating with each other to complete the tasks of simulating, creating, and managing various virtual hardware.
[0031] Combine the following Figure 3 The processing method of the I / O request provided in this specification is specifically described. Figure 3It is a flowchart of a method for processing an I / O request provided by an exemplary embodiment.
[0032] like Figure 3 The method shown in the figure is mainly applied to a virtual CPU thread running on a host CPU, and the virtual CPU thread is assigned to a virtual machine deployed on the host. For example, in an exemplary embodiment of the present application, the method can be applied to Figure 2 In the virtual CPU thread 1 in the host shown. The method mainly includes the following steps:
[0033] S301, when an I / O request is received, the Guest context is transferred to the Host context.
[0034] Since the virtual CPU thread does not have the authority to directly access external devices, when accessing external devices, the virtual CPU thread needs to exit to the Host context, and the host will complete the access to the external device on its behalf. When receiving an I / O request for a predetermined target external device, the virtual CPU thread originally running in the Guest context needs to temporarily stop the execution of the Guest context to access the external device, and switch to the execution of the Host context, and the host will access the external device on its behalf, obtain the access result and feed it back to the virtual CPU thread. Only when the I / O request is processed, the virtual CPU thread will return to the Guest context to continue executing the task. When processing the I / O request, in fact, the virtual CPU thread suspends the execution of the task in the Guest OS, so the state of the Guest context suspension caused by the processing of the I / O request can be changed to a blocked state.
[0035] In an exemplary embodiment of the present specification, the above process can be described as: when an I / O request is received, the virtual CPU exits to the VMM.
[0036] S302: Send the I / O request to other threads running on the host for processing, and return to the Guest context after the sending is completed.
[0037] In order to successfully access external devices, the virtual CPU thread needs to process the received I / O request. Normally, after the virtual CPU thread enters the Host context, it completes the processing of the I / O request and then returns to the Guest context to continue execution. However, in order to save the I / O request processing time, reduce the time the virtual CPU thread is in a blocked state, and improve the processing efficiency of the virtual CPU, in an exemplary embodiment of the present specification, the virtual CPU thread sends the received I / O request to other threads for processing, and directly returns to the Guest context after the sending is completed, without waiting for the I / O request to be processed. The above method can effectively reduce the delay of the virtual CPU thread accessing external devices, thereby improving the execution efficiency of the virtual CPU thread, and further improving the processing performance of the virtual CPU.
[0038] In an exemplary embodiment of the present specification, the above-mentioned I / O request may include a PIO (Port IN / OUT, I / O port) request and / or an MMIO (Memory Mapping I / O, memory mapping I / O) request. The PIO request accesses the I / O port address space of the device through the IN / OUT instruction, wherein the IN instruction is a read request and the OUT instruction is a write request. The MMIO request occupies the physical address space of the host CPU, and accesses the I / O address space of the device in the same way as accessing the memory, and can be accessed using the host CPU's instructions for accessing the memory.
[0039] In an exemplary embodiment of the present specification, an I / O request is sent to other threads running on the host for processing, wherein the other threads may be virtual I / O threads in a virtual I / O thread pool on the host. A virtual I / O thread pool is pre-created on the host specifically for processing I / O requests of virtual CPU threads in virtual machines, and the virtual I / O thread pool may include at least one virtual I / O thread for assisting in processing I / O requests of virtual CPU threads. The virtual I / O thread pool may simultaneously process I / O requests sent by various virtual CPU threads in the virtual machine.
[0040] For example, in an exemplary embodiment of the present specification, it is assumed that there are three virtual I / O threads in a virtual I / O thread pool for assisting a virtual CPU thread in processing I / O requests, namely, virtual I / O thread 1, virtual I / O thread 2, and virtual I / O thread 3. Figure 2After receiving I / O request 1, the virtual CPU thread 1 shown in the figure enters the Host context, and sends the I / O request 1 to the virtual I / O thread 1 in the virtual I / O thread pool for processing, and the virtual CPU thread 1 directly returns to the Guest context. At the same time, the virtual CPU thread 2 on the host CPU also receives I / O request 2, then the virtual CPU thread 2 enters the Host context, and sends the I / O request 2 to the virtual I / O thread 2 in the virtual I / O thread pool, and the virtual I / O thread 2 in the virtual I / O thread pool processes it. In an exemplary embodiment of the present specification, when any virtual CPU thread sends an I / O request to the virtual I / O thread pool, and there is no unoccupied virtual I / O thread in the virtual I / O thread pool, it is necessary to wait until a virtual I / O thread in the virtual I / O thread pool completes processing, and then the idle virtual I / O thread processes the I / O request. The virtual CPU thread does not need to wait for the virtual I / O thread pool to allocate an idle virtual I / O thread to process the I / O request it sends, but directly returns to the Guest context to continue executing the task, which can minimize the blocking time of the virtual CPU thread.
[0041] In an exemplary embodiment of the present specification, since the I / O request includes both a read request and a write request, the processing method of the read request and the write request can be distinguished according to the difference between the read request and the write request. Since the write request only writes data to the corresponding I / O address, the write request does not need to care whether there are other unfinished requests at the corresponding address, and only needs to write the data, and the write request can be directly handed over to other threads for processing. As for the read request, since it involves data feedback, the read result needs to be fed back to the client, so when processing the read request, it is necessary to pay extra attention to the accuracy of the read data. In order to ensure that there are no errors and delays in the feedback result, when the received I / O request is a read request, if it is determined that there is no write request sent by the virtual machine and has not been processed on other threads running on the host, the I / O request is sent to other threads running on the host for processing, and the Guest context is returned after the sending is completed. That is, it is necessary to determine that all write requests are completed and the read data is the latest and written data.
[0042] Of course, since it may be difficult to determine whether there are write requests sent by the virtual machine and not yet processed on other threads running on the host, and there are also certain difficulties in feeding back the read results of read requests completed by other threads, therefore, in an exemplary embodiment of the present specification, the virtual CPU thread can also process the read request by itself, and return to the Guest context after the processing is completed. Specifically, the virtual CPU thread can complete the processing of the read request according to the following steps. First, the virtual CPU thread parses the address of the received read request; then, it is determined whether there is an uncompleted write request at the address, and if there is an uncompleted write request at the address, the read request is processed after waiting for the uncompleted write request to be completed. The above-mentioned method for processing the read request is also to ensure the accuracy of the read data, and it is simpler to determine whether there are uncompleted write requests sent by the virtual machine and not yet processed on other threads running on the host. By sending the write request to other threads and processing it, and completing the processing of the read request by the virtual CPU thread itself, the time for completing the write request is saved, and the blocking time of the virtual CPU thread can also be reduced, and the execution efficiency of the virtual CPU thread can be improved.
[0043] In order to more clearly describe a method for processing an I / O request provided in this specification, this specification provides the following specific embodiments.
[0044] like Figure 4 FIG. 1 is a flow chart of a specific method for processing an I / O request. The method can be applied to Figure 2 In the virtual CPU thread 1, virtual CPU thread 2 or virtual CPU thread 3. Each virtual CPU thread runs on the virtual machine 2111, and the virtual CPU thread 1, virtual CPU thread 2 and virtual CPU thread 3 are specifically implemented by KVM and perform scheduling and switching. And, Figure 2 The host shown in FIG. 1 is also provided with a virtual I / O thread pool, which is as shown in FIG. Figure 4 As shown in the virtual I / O thread pool 420 in FIG. 1 , the virtual I / O thread pool includes several virtual I / O threads pre-created on the host and used to assist in processing the virtual machine. It is assumed that the number of virtual I / O threads in the virtual I / O thread pool is three, namely, virtual I / O thread 1, virtual I / O thread 2, and virtual I / O thread 3. Of course, in the case of idle resources, the virtual I / O thread pool can create more virtual I / O threads to assist the virtual CPU thread in simulating I / O processing of write requests, which is not specifically limited in this specification.
[0045] Assume that Figure 2The virtual CPU thread 1 in the virtual machine 2111 shown receives the I / O request 1, and the virtual CPU thread can complete the following steps:
[0046] S401, when virtual CPU thread 1 receives I / O request 1, it switches from guest context to host context, that is, switches from executing the code of the virtual machine to starting to execute the code of the host. This process can also be described as the virtual CPU exiting the KVM and switching to step S402.
[0047] S402, determine whether the received I / O request is a read request or a write request. Since the nature of a read request is different from that of a write request, it is necessary to process the read request and the write request differently. Assume that the I / O request 1 is a write request. Then proceed to S403.
[0048] S403, the virtual CPU thread determines that the I / O request is a write request, and according to the characteristic that the write request does not need to return an access result, the process directly proceeds to step S404.
[0049] S404: Send the write request to the virtual I / O thread 1 in the virtual thread pool 420 for processing. After the write request, ie, the I / O request 1, is sent to the virtual I / O thread 1, the process proceeds to step S410.
[0050] S410, virtual CPU thread 1 directly returns to the Guest context and continues to execute the suspended virtual machine code. Meanwhile, virtual I / O thread 1 in the virtual I / O thread pool simulates the processing of I / O write request for I / O request 1. This is equivalent to virtual I / O thread 1 taking on the task of simulating write request that was originally required to be undertaken by virtual CPU thread 1, converting serial processing into parallel processing, saving the time for virtual CPU thread to process write request, and improving the execution efficiency of virtual CPU thread.
[0051] Assume that after the virtual CPU thread 1 returns to the Guest context to continue execution, it receives I / O request 2. I / O request 2 is a read request. At this time, assume that the address targeted by I / O request 1 and I / O request 2 is the same, and the virtual I / O thread 1 in the virtual I / O thread pool has not completed the write to I / O request 1, that is, there is an unfinished write request at the same address. In this case, complete the following again. Figure 4 The individual steps shown:
[0052] S401, after receiving the I / O request 2, the virtual CPU thread 1 suspends the execution of the virtual machine code again, switches from the Guest context to the Host context again, and proceeds to step S402.
[0053] S402, determine that the I / O request 2 is a read request. At this time, since the I / O request 2 is a read request, the process proceeds to step S405, and from step S405 to step S406.
[0054] S406, parsing the address pointed to by the read request, and then proceeding to step S407.
[0055] S407, determine whether there is an uncompleted write request at the address. Since there is an uncompleted write request at the address, that is, I / O request 1, therefore, the process proceeds to step S408.
[0056] S408, wait for I / O request 1 to complete, and then proceed to step S409 after I / O request 1 is completed. During the waiting process, virtual CPU thread 1 can enter a waiting, sleeping or scheduling mode, and in the above modes, wait for the write request at the address to be processed and then proceed to step S409.
[0057] S409, processing the read request - I / O request 2, completing the simulation of the I / O request 2, and finally turning to step S410.
[0058] S410, return the Guest context.
[0059] Assume that at this time, virtual CPU thread 2 also receives I / O request 3, which is a write request. However, the address pointed to by I / O request 3 is different from that of I / O request 1 and I / O request 2. Virtual I / O thread 1 in the virtual I / O thread pool has not completed the writing of I / O request 1. In this case, virtual CPU thread 2 completes the writing. Figure 4 Steps shown:
[0060] S401, after receiving I / O request 3, suspend the execution of the virtual machine code, transfer from the Guest context to the Host context, and transfer to step S402.
[0061] S402, determine whether the I / O request 3 is a write request or a write request. Since the I / O request 3 is a write request, the process proceeds to step S403, and from step S403 the process proceeds to step S404.
[0062] S404, the I / O request 3 is sent to other threads in the virtual I / O thread pool 420 for processing, and the process directly proceeds to step S410. However, since the virtual I / O thread 1 in the virtual I / O thread pool 420 is occupied by the I / O request 1, the I / O request 3 can be sent to other virtual I / O threads in the virtual I / O thread pool 420 for processing, for example, the I / O request 3 is sent to the virtual I / O thread 2 in the virtual I / O thread pool, and the virtual I / O thread 2 simulates the I / O request processing for the I / O request 3.
[0063] S410, return the Guest context.
[0064] At the same time, assume that virtual CPU thread 3 receives I / O request 4, which is a read request, but the address pointed to by this I / O request is different from I / O request 1, I / O request 2 and I / O request 3, and no write request is being processed at this address.
[0065] At this time, the virtual CPU thread 3 completes Figure 4 Steps shown:
[0066] S401, after receiving I / O request 4, suspend the execution of the virtual machine code, transfer from the Guest context to the Host context, and transfer to step S402.
[0067] S402, determine that the I / O request 4 is a read request, and proceed to step S405, and from step S405 proceed to step S406.
[0068] S406, parsing the address pointed to by the read request, and proceeding to step S407.
[0069] S407, and determine whether there is an uncompleted write request at the address. Since there is no uncompleted write request at the address, the process proceeds to step S409.
[0070] S409, directly complete the I / O request and proceed to step S410.
[0071] S410, return the Guest context.
[0072] The above specific embodiments list different exemplary embodiments and provide detailed explanations according to different types of I / O requests and different states of the virtual CPU threads when receiving I / O requests. It can be seen from the above embodiments that the I / O request processing method provided in this specification can reduce the time that the virtual CPU thread is blocked and improve the execution efficiency of the virtual CPU thread.
[0073] Figure 5 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of this specification. Figure 5, at the hardware level, the device includes a processor 502, an internal bus 504, a network interface 506, a memory 508 and a non-volatile memory 510. Of course, it may also include hardware required for other functions. The processor 502 reads the corresponding computer program from the non-volatile memory 510 into the memory 508 and then runs it, forming a processing device for I / O requests at the logical level. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0074] Corresponding to the above method embodiment, this specification also provides an I / O request processing device.
[0075] Please refer to Figure 6 , an I / O request processing device, applied to a virtual CPU thread running on a host CPU, wherein the virtual CPU thread is allocated to a virtual machine deployed on the host, and the device may include:
[0076] The receiving unit 610 is used to transfer from the Guest context to the Host context when receiving an I / O request;
[0077] The sending unit 620 is used to send the I / O request to other threads running on the host for processing, and return the Guest context after the sending is completed.
[0078] Optionally, the sending unit 620 may be specifically configured to:
[0079] Selecting the other thread from the virtual I / O thread pool on the host, and sending the I / O request to the selected other thread;
[0080] The virtual I / O thread pool includes at least one thread that is pre-created on the host and is used to assist in processing the I / O request of the virtual machine.
[0081] Optionally, the sending unit 620 may be specifically configured to:
[0082] In the case where the I / O request is a write request, the I / O request is sent to other threads running on the host for processing, and the Guest context is returned after the sending is completed.
[0083] Optionally, the sending unit 620 may be specifically configured to:
[0084] In the case where the I / O request is a read request, if it is determined that there is no write request issued by the virtual machine and not yet processed on other threads running on the host, the I / O request is sent to other threads running on the host for processing, and the Guest context is returned after the sending is completed.
[0085] Optionally, the I / O request processing device may further include:
[0086] The processing unit 630 is configured to process the read request and return the Guest context after the processing is completed if the I / O request is a read request.
[0087] Optionally, the processing unit 630 may be specifically configured to:
[0088] Parsing the address of the read request;
[0089] Determining whether there is an uncompleted write request at the address;
[0090] If there is an uncompleted write request for the address, the read request is processed after waiting for the uncompleted write request to be completed.
[0091] Optionally, the I / O request includes: a PIO request and / or an MMIO request.
[0092] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0093] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0094] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0095] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0096] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0097] In one or more embodiments of the present specification, the term "includes", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, commodity or device including the element.
[0098] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0099] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0100] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A method for processing an I / O request, characterized in that: The method is applied to a virtual CPU thread running on a host CPU, wherein the virtual CPU thread is allocated to a virtual machine deployed on the host, and comprises: When an I / O request is received, the guest context is transferred to the host context; The I / O request is sent to other threads running on the host for processing, and the Guest context is returned after the sending is completed.
2. The method according to claim 1, characterized in that The sending the I / O request to other threads running on the host for processing includes: Selecting the other thread from the virtual I / O thread pool on the host, and sending the I / O request to the selected other thread; The virtual I / O thread pool includes at least one thread that is pre-created on the host and is used to assist in processing the I / O request of the virtual machine.
3. The method according to claim 1, characterized in that The sending of the I / O request to other threads running on the host for processing, and returning the Guest context after the sending is completed, includes: In the case where the I / O request is a write request, the I / O request is sent to other threads running on the host for processing, and the Guest context is returned after the sending is completed.
4. The method according to claim 1, characterized in that The sending of the I / O request to other threads running on the host for processing, and returning the Guest context after the sending is completed, includes: In the case where the I / O request is a read request, if it is determined that there is no write request issued by the virtual machine and not yet processed on other threads running on the host, the I / O request is sent to other threads running on the host for processing, and the Guest context is returned after the sending is completed.
5. The method according to claim 1, characterized in that Also includes: In the case where the I / O request is a read request, the read request is processed and the Guest context is returned after the processing is completed.
6. The method according to claim 5, characterized in that The processing of the read request and returning the Guest context after the processing is completed include: Parsing the address of the read request; Determining whether there is an uncompleted write request at the address; If there is an uncompleted write request for the address, the read request is processed after waiting for the uncompleted write request to be completed.
7. The method according to claim 1, characterized in that The I / O request includes: a PIO request and / or an MMIO request.
8. A device for processing an I / O request, characterized in that: A virtual CPU thread is applied to a virtual CPU thread running on a host CPU, wherein the virtual CPU thread is allocated to a virtual machine deployed on the host, and the device comprises: The receiving unit is used to transfer from the Guest context to the Host context when receiving an I / O request; The sending unit is used to send the I / O request to other threads running on the host for processing, and return the Guest context after the sending is completed.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Virtual machine disk encryption method and system and computer readable storage medium
CN113626156A
Virtualization method and device for non-volatile high-speed transmission bus NVMe device
CN114281252A