Method and Application for IO Virtualization Data Processing Based on vhost Protocol
By implementing the vhost-blk kernel module in the kernel and directly communicating with GuestOS using the vhost protocol, the performance bottlenecks and complexity problems of IO virtualization in the existing technology are solved, and efficient IO performance improvement and system stability are achieved.
Patent Information
- Application Number
- CN202211611358.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-12-14
AI Technical Summary
The existing IO virtualization technology based on the vhost-user protocol has frequent system calls and context switching, large data copying, excessive protocol stack overhead, and complex concurrency mutual exclusion problems. It cannot meet the IO performance requirements in the cloud computing and big data era, and has high complexity and uncertainty in implementation on non-Intel hardware platforms.
The vhost-blk kernel module is added to the kernel, and the vhost protocol is used to communicate directly with GuestOS. The virtual file system VFS provided by the kernel is used to reduce data copying and context switching, and the initialization and configuration of vhost-blk devices are realized. The eventfd and irqfd mechanisms are used for KVM communication, which supports the universality of file and block devices.
IO performance improvement is achieved, up to twice the reading data and twice the writing data in most scenarios. At the same time, it reduces CPU usage, simplifies implementation complexity and uncertainty, and improves the ease of use and stability of the system.
Smart Images

Figure CN115904628B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a method and application for IO virtualization data processing based on the vhost protocol. Background Art
[0002] With the rapid development of cloud computing and the Internet, the amount of data that enterprises and related units need to process is increasing. In a cloud environment, traditional IO virtualization technologies have long suffered from problems such as frequent system calls and context switches, a large amount of data copying, excessive protocol stack overhead, and complex concurrent mutual exclusion. Due to the long access path, long latency, and low data throughput, they have been widely criticized and cannot meet the requirements for IO performance in the era of cloud computing and big data. In the face of the above difficulties, the most well-known solution in the industry at present is the IO virtualization performance acceleration solution implemented by Intel using the SPDK (Storage Performance Development Kit) based on the vhost-user protocol.
[0003] SPDK provides a set of tools and libraries for writing high-performance and scalable storage applications in user mode. SPDK provides a specific implementation of the virtio backend defined in the vhost-user protocol and provides three virtual devices, namely vhost-blk, vhost-scsi, and vhost-nvme, for the GuestOS.
[0004] The solution implemented by SPDK using the vhost-user protocol realizes the same functions as vhost in user space without going through the kernel, avoiding a large number of system calls, context switches, and the overhead of the kernel protocol stack. Usually, this way of bypassing the kernel to improve IO performance is called kernel bypass. The kernel bypass solution implemented by SPDK through the vhost-user protocol has significant disadvantages: 1) It increases the complexity and uncertainty of integration into the existing operating system environment and non-Intel hardware platforms; 2) It increases the complexity of virtualization management and reduces the ease of use; 3) Most storage manufacturers have relatively little investment in the kernel-bypass solution. In the actual production process, a series of unknown problems are inevitable and a large amount of effort is required to fix the actual problems.
[0005] Currently, the latest code of the main branches of Qemu and the Linux kernel community does not have an implementation of the vhost-blk device based on the vhost protocol. So far, there is no solution that uses the vhost protocol to implement in the kernel and has better IO performance than virtio-blk and supports both block devices and files to store data at the same time as virtio-blk.
[0006] The information disclosed in this background section is only intended to enhance the overall understanding of the background of the present invention and should not be regarded as an admission or any form of implication that this information constitutes prior art already known to those of ordinary skill in the art. Summary of the Invention
[0007] An object of the present invention is to provide a method and application for IO virtualization data processing based on the vhost protocol, which can provide a solution with performance close to SPDK vhost - blk and is more general and easier to implement.
[0008] To achieve the above object, an embodiment of the present invention provides a method for IO virtualization data processing based on the vhost protocol.
[0009] In one or more embodiments of the present invention, the method includes: adding a vhost - blk kernel module in the kernel, calling an initialization function provided by the vhost protocol to initialize the vhost - blk kernel module, and the initialization includes the implementation of a notification function from GuestOS; after receiving a notification from GuestOS, the vhost - blk kernel module obtains instructions and data addresses written by GuestOS from the virtqueue send queue shared with GuestOS; polling whether new instructions and data arrive in the virtqueue send queue shared with GuestOS, if so, taking them out and calling the VFS general entry function to process the data; if no data arrives after a time limit, notifying GuestOS that the data processing task is completed and ending the current data processing.
[0010] In one or more embodiments of the present invention, the initialization by calling an initialization function provided by the vhost protocol includes: the vhost - blk kernel module receives configuration information sent by the user space through ioctl to complete the initialization and configuration of vhost - blk.
[0011] In one or more embodiments of the present invention, the implementation of the notification function from GuestOS in the initialization includes: after receiving a notification from GuestOS through KVM, executing the GuestOS notification function, the notification function obtains instructions and data addresses written by GuestOS from the virtqueue, taking them out and calling the general entry function of the virtual file system VFS provided by the kernel to process the data, and after completing the data processing, sending a notification of completed data processing to KVM.
[0012] In one or more embodiments of the present invention, the notification of completing data processing sent to KVM includes: the processes between KVM and vhost-blk communicate through the invocation of the eventfd mechanism and the irqfd mechanism.
[0013] In one or more embodiments of the present invention, the method further includes: in the initialization stage of the vhost-blk kernel module, Qemu is used to configure and initialize vhost-blk.
[0014] In one or more embodiments of the present invention, the configuration and initialization of vhost-blk through Qemu includes: in the initialization stage, the initialization of PCI configuration of the device including vendor ID, device ID, and version number is added, and querying and setting the configuration of the device are supported.
[0015] In one or more embodiments of the present invention, the method further includes: through an ioctl system call, a configuration command is sent to the vhost-blk kernel module to complete the entire initialization and configuration process of the vhost-blk device.
[0016] In another aspect of the present invention, a device for IO virtualization data processing based on the vhost protocol is provided, which includes an initialization module, an information acquisition module, and a polling module.
[0017] The initialization module is used to add the vhost-blk kernel module in the kernel, and call the initialization function provided by the vhost protocol to initialize the vhost-blk kernel module, and the initialization includes the implementation of the notification function from GuestOS.
[0018] The information acquisition module is used to, after receiving the notification from GuestOS, the vhost-blk kernel module obtains the instructions and data addresses written by GuestOS from the virtqueue send queue shared with GuestOS.
[0019] The polling module is used to poll whether new instructions and data arrive in the virtqueue send queue shared with GuestOS; if so, take them out and call the VFS general entry function to process the data; if no data arrives after a period of time, notify GuestOS that the data processing task has been completed and end the current data processing.
[0020] In one or more embodiments of the present invention, the initialization module is further used for: the vhost-blk kernel module receives the configuration information sent by the user space through ioctl to complete the initialization and configuration of vhost-blk.
[0021] In one or more embodiments of the present invention, the initialization module is further configured to: after receiving a GuestOS notification through KVM, execute the GuestOS notification function. The notification function obtains the instructions and data addresses written by the GuestOS from the virtqueue, extracts and calls the general entry function of the virtual file system VFS provided by the kernel to process the data. After completing the data processing, a notification of completing the data processing is sent to KVM.
[0022] In one or more embodiments of the present invention, the initialization module is further configured to: the processes between KVM and vhost-blk communicate through calling the eventfd mechanism and the irqfd mechanism.
[0023] In one or more embodiments of the present invention, the initialization module is further configured to: in the initialization stage of the vhost-blk kernel module, configure and initialize vhost-blk through Qemu.
[0024] In one or more embodiments of the present invention, the initialization module is further configured to: in the initialization stage, add the initialization of the PCI configuration of the device including the vendor ID, device ID, and version number, and support querying and setting the configuration of the device.
[0025] In one or more embodiments of the present invention, the initialization module is further configured to: through an ioctl system call, send a configuration command to the vhost-blk kernel module to complete the complete initialization and configuration process of the vhost-blk device.
[0026] In another aspect of the present invention, an electronic device is provided, including: at least one processor; and a memory, where the memory stores instructions, and when the instructions are executed by the at least one processor, the at least one processor executes the method for IO virtualization data processing based on the vhost protocol as described above.
[0027] In another aspect of the present invention, a computer-readable storage medium is provided, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for IO virtualization data processing based on the vhost protocol as described are implemented.
[0028] Compared with the prior art, the method and application for IO virtualization data processing based on the vhost protocol according to the embodiments of the present invention can achieve vhost-blk data acceleration processing based on the vhost protocol. Through testing with the FIO tool and comparing with the most widely used virtio-blk solution currently, in all scenarios, the data reading is better than virtio-blk, with the IO performance improvement reaching up to twice at most. For data writing, the IO performance improvement reaches up to twice in most scenarios. At the same time, the CPU usage is basically the same as that of the virtio-blk solution, achieving generality and enhancing the IO performance, and reducing the complexity and uncertainty in actual production implementation. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a flowchart of a method for IO virtualization data processing based on the vhost protocol according to an embodiment of the present invention;
[0030] Figure 2 is a flowchart comparison diagram of the method for IO virtualization data processing based on the vhost protocol according to an embodiment of the present invention and the virtio-blk solution;
[0031] Figure 3 is a polling flowchart of a method for IO virtualization data processing based on the vhost protocol according to an embodiment of the present invention;
[0032] Figure 4 is a structural diagram of a device for IO virtualization data processing based on the vhost protocol according to an embodiment of the present invention;
[0033] Figure 5 is a hardware structural diagram of a computer device for IO virtualization data processing based on the vhost protocol according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0034] The following will describe in detail the specific embodiments of the present invention with reference to the accompanying drawings, but it should be understood that the protection scope of the present invention is not limited by the specific embodiments.
[0035] Unless otherwise clearly stated, in the whole specification and claims, the term "comprise" or its variations such as "comprises" or "including" etc. will be understood to include the stated elements or components, without excluding other elements or other components.
[0036] The following will detail the technical solutions provided by the embodiments of the present invention with reference to the accompanying drawings.
[0037] Embodiment 1
[0038] As Figure 1As shown, a method for IO virtualization data processing based on the vhost protocol of the present invention is introduced, and the method includes the following steps.
[0039] In step S101, a vhost-blk kernel module is added to the kernel, and the initialization function provided by the vhost protocol is called to initialize the vhost-blk kernel module. The initialization includes the implementation of the notification function from the GuestOS.
[0040] In this embodiment, the vhost-blk kernel module follows the vhost protocol and is initialized by calling the initialization function provided by the vhost protocol. Compared with the vhost-user protocol used by SPDK, the vhost-blk device virtualization is completed by the kernel without relying on the external program SPDK to create and manage the vhost-blk device, reducing the complexity and uncertainty in actual production implementation. The vhost protocol defines a backend implementation scheme for virtio to directly communicate with the GuestOS. During the data exchange process of the virtio scheme, the Qemu emulated device serves as the virtio backend, and the GuestOS needs to communicate with Qemu, which will cause multiple data copies and context switches. As an improved scheme for virtio, vhost does not require this part of the overhead.
[0041] In step S102, after receiving the notification from the GuestOS, the vhost-blk kernel module obtains the instructions and data addresses written by the GuestOS from the virtqueue send queue shared with the Guest OS.
[0042] Specifically, after receiving the notification from the GuestOS, the processing continues according to the standard processing flow of the vhost protocol. Inside the notification processing function, the vhost-blk kernel module shares the virtqueue with the GuestOS, and the vhost-blk kernel module can obtain a batch of instructions and data addresses written by the GuestOS from the send queue.
[0043] In step S103, poll whether new instructions and data have arrived in the virtqueue send queue shared with the GuestOS. If so, take them out and call the VFS general entry function to process the data.
[0044] Specifically, polling is triggered sequentially according to a certain algorithm. When polling, the index after the current execution is saved so that the starting index position can be obtained during the next execution, for the purpose of achieving load balancing. In this embodiment, the process can be simplified through polling. Polling through vhost-blk in the kernel saves a large part of the performance loss and latency caused by the data processing requests originally initiated from GuestOS downward, effectively reducing the number of data processing requests initiated by GuestOS to the kernel.
[0045] In step S104, if no data arrives within the time limit, GuestOS is notified that the data processing task has been completed and this data processing is ended.
[0046] Under the vhost protocol framework of this embodiment, a time limit is set for data arrival. If no data arrives after this time limit, the processing of the notification from GuestOS for this time is ended. By polling the virtqueue send queue shared with GuestOS, the latest arriving data to be processed is collected, thereby reducing the number of system calls and requests initiated by GuestOS, further improving the IO performance, and realizing another performance enhancement feature SQpolling of the vhost-blk module.
[0047] Embodiment 2
[0048] As Figures 1 to 3 shown, a method for IO virtualization data processing based on the vhost protocol of the present invention is introduced. The method includes the following steps.
[0049] In step S101, the vhost-blk kernel module is added to the kernel, and the initialization function provided by the vhost protocol is called to initialize the vhost-blk kernel module. The initialization includes the implementation of the notification function from GuestOS.
[0050] In the IO virtualization path optimization solution, virtio is the most widely accepted and applied semi-virtualization protocol specification, defined by OASIS (Advancing Open Standard For Information Society), which realizes a unified communication specification between GuestOS and Qemu. Virtio implements a front-end driver in GuestOS and a back-end driver in Host, and data is exchanged between the front and back ends through Virtqueue. The back-end driver is simulated by Qemu. Specifically, it is simulated as a PCI device, serving as an emulated device of GuestOS, while the front-end driver, as the driver of this PCI device, is located in the kernel of GuestOS.
[0051] The vhost protocol defines a backend implementation solution for virtio. It is a module located in the host kernel and is used to communicate directly with the Guest OS. Data exchange occurs directly between the Guest and the Host kernel through virtqueue. During the data exchange process of the virtio solution, the Qemu emulated device acts as the virtio backend, and the Guest OS needs to communicate with Qemu, which causes multiple data copies and context switches. As an improved solution for virtio, vhost does not require this part of the overhead.
[0052] The Vhost-user protocol has the same basic principle as vhost. It implements basically the same functions as vhost in the user space, and both achieve data exchange through virtqueue. The difference is that the virtio backend implemented by vhost is in the kernel, while the one implemented by vhost-user is in the user space.
[0053] SPDK provides a set of tools and libraries for writing high-performance and scalable storage applications in user mode. SPDK provides a specific implementation of the virtio backend defined in the vhost-user protocol and offers three virtual devices, namely vhost-blk, vhost-scsi, and vhost-nvme, for the Guest OS. The solution implemented by SPDK using the vhost-user protocol achieves the same functions as vhost in the user space without going through the kernel, avoiding a large number of system calls, context switches, and the overhead of the kernel protocol stack. Usually, this way of improving IO performance by bypassing the kernel is called kernel bypass.
[0054] The kernel bypass solution implemented by SPDK through the vhost-user protocol has the following disadvantages: 1) SPDK is an independent third-party suite provided by Intel, which requires the installation of a series of dependent packages and library files it demands, and only optimizes and fixes stability for Intel platforms, adding complexity and uncertainty to the integration into existing operating system environments and non-Intel hardware platforms. 2) The vhost emulation device provided by SPDK must be created and managed using the interfaces provided by SPDK, and cannot be directly created and managed by libvirt. This increases the complexity of virtualization management and reduces usability. 3) SPDK violates the existing working methods and design concepts of the operating system, completely bypassing the kernel to interact with storage hardware. The method of managing hardware devices through the kernel has been in existence for decades and has good stability. Most storage vendors have relatively little investment in the kernel-bypass solution. Inevitably, a series of unknown problems will occur during actual production, and a large amount of effort is required to fix the actual problems.
[0055] In this embodiment, a vhost-blk kernel module is added to the kernel. Following the vhost protocol, the initialization function provided by the vhost protocol is called for initialization, and the implementation of the user space ioctl system call function by the kernel module is added. The user space sends configuration information to the vhost-blk kernel module through ioctl, thus completing the complete initialization and configuration of vhost-blk.
[0056] In step S102, after receiving the notification from the Guest OS, the vhost-blk kernel module obtains the instructions and data addresses written by the Guest OS from the virtqueue send queue shared with the Guest OS.
[0057] Specifically, after receiving the notification through KVM, the program is executed. The notification function obtains the instructions and data addresses written by the Guest OS from the virtqueue, extracts and calls the general entry function of the virtual file system VFS provided by the kernel to process the data. After completing the data processing, a notification of completing the data processing is sent to KVM.
[0058] In this embodiment, the processes between KVM and vhost-blk communicate by calling the eventfd mechanism and the irqfd mechanism.
[0059] To achieve data acceleration for I / O virtualization based on the vhost protocol, in this embodiment, a vhost-blk device is implemented in the kernel, making full use of the virtual file system VFS provided by the kernel to support both files and block devices simultaneously, thus achieving the goal of generality. On the other hand, the generality also comes from the vhost protocol itself. Compared with the vhost-user protocol used by SPDK, the virtualization of the vhost-blk device is completed by the kernel without relying on an external program SPDK to create and manage the vhost-blk device, reducing the complexity and uncertainty in actual production implementation.
[0060] As Figure 2 shown, in the flow comparison diagram of the I / O virtualization data processing method based on the vhost protocol and the virtio-blk scheme in this embodiment, on the guest side, both schemes use virtio-blk drive in the Guest Kernel for driving. In the interaction between the guest and KVM, the comparison scheme uses virtio / PCI and virtio / VCPU interrupt threads, while this embodiment uses virtio / PCI and virtio / PCI interrupt threads. In the Qemu and Host Kernel architectures, the comparison scheme sets up a Qemu virtio-blk emulation device in Qemu for interaction with KVM, while this embodiment sets up vhost-blk in the Host Kernel for interaction with KVM. The comparison scheme uses VMExit and vIRQ / ioctl technologies to complete the communication between the Qemu virtio-blk emulation device and KVM, while this embodiment calls the eventfd mechanism and the irqfd mechanism to complete the communication between vhost-blk and KVM. In the call to the virtual file system VFS interface, the Qemu virtio-blk emulation device in the comparison scheme switches between kernel mode and user mode through system calls, while the vhost-blk in this embodiment is through vfs calls. In the subsequent processes, the file systems, Block layers, and storage devices Hardware transferred to in both schemes are the same.
[0061] In the process of this embodiment's scheme and the virtio-blk scheme, in the virtio-blk scheme, the communication between the GuestOS and Qemu will cause multiple data copies and context switches, while this embodiment's scheme does not require this part of the overhead, optimizing the communication performance. Moreover, the virtualization of the vhost-blk device is completed by the kernel, reducing the complexity and uncertainty in actual production implementation, and directly using the virtual file system VFS provided by the kernel to support both files and block devices simultaneously, thus achieving the goal of generality.
[0062] In step S103, inside the GuestOS notification function, poll whether there are new instructions and data arriving in the virtqueue send queue shared with the GuestOS. If so, retrieve them and call the VFS general entry function to process the data.
[0063] In step S104, if no data arrives within the time limit, notify the GuestOS that the data processing task is completed and end the current data processing.
[0064] As Figure 3 shown, after the vhost-blk kernel module receives the GuestOS notification, the vhost-blk kernel module retrieves all instructions and data from the virtqueue send queue. Next, enter the polling section, poll whether there are new instructions and data written to the virtqueue send queue shared with the GuestOS, and determine whether the reception times out. If there is no timeout and it is determined that the virtqueue has new data arriving, call the VFS general entry function, process all the data obtained from the virtqueue, and return to the polling state to enter a new round of polling; if it times out and it is determined that no new instructions and data will be written to the virtqueue by the GuestOS within a period of time, inform the GuestOS that the data processing task is completed, and then end the current polling.
[0065] Under the vhost protocol framework of this embodiment, by polling the virtqueue send queue shared with the GuestOS, the latest arriving data to be processed is collected, thereby reducing the number of system calls and requests initiated by the GuestOS, further improving the IO performance, and implementing another performance enhancement feature SQpolling of the vhost-blk module.
[0066] Specifically, through the polling operation, the number of data processing requests initiated by the GuestOS to the kernel can be effectively reduced, and a large part of the performance loss and latency generated by the data processing requests originally initiated from the GuestOS downward are saved by polling inside the vhost-blk in the kernel.
[0067] In this embodiment, during the initialization stage of the vhost-blk kernel module, Qemu is used to configure and initialize the vhost-blk. During the initialization stage, the initialization of the device including PCI configuration such as vendor ID, device ID, and version number is added, and querying and setting the device configuration are supported. Through the ioctl system call, configuration commands are sent to the vhost-blk kernel module to complete the complete initialization and configuration process of the vhost-blk device.
[0068] Specifically, during the use of vhost-blk, Qemu is used for initialization and basic control, as well as for processing configuration instructions, without performing data processing.
[0069] According to the method and application for IO virtualization data processing based on the vhost protocol according to an embodiment of the present invention, it can implement a vhost-blk data acceleration processing method based on the vhost protocol. Through testing with the FIO tool and comparing with the currently most widely used virtio-blk solution, in all scenarios, the data reading is better than virtio-blk, with a maximum IO performance improvement of up to twice. For data writing, in most scenarios, the maximum IO performance improvement is up to twice. At the same time, the CPU usage is basically the same as that of the virtio-blk solution, achieving generality and enhancing IO performance, and reducing the complexity and uncertainty in actual production implementation.
[0070] As Figure 4 shown, a device for IO virtualization data processing based on the vhost protocol according to a specific embodiment of the present invention is introduced.
[0071] In an embodiment of the present invention, the device for IO virtualization data processing based on the vhost protocol includes an initialization module 401, an information acquisition module 402, and a polling module 403.
[0072] The initialization module 401 is used to add a vhost-blk kernel module in the kernel and call the initialization function provided by the vhost protocol to initialize the vhost-blk kernel module. The initialization includes the implementation of a notification function from the GuestOS.
[0073] The information acquisition module 402 is used to, after receiving a notification from the GuestOS, the vhost-blk kernel module obtains the instructions and data addresses written by the GuestOS from the virtqueue send queue shared with the GuestOS.
[0074] The polling module 403 is used to poll whether new instructions and data have arrived in the virtqueue send queue shared with the GuestOS; if so, take them out and call the VFS general entry function to process the data; if no data has arrived after a certain period of time, notify the GuestOS that the data processing task has been completed and end the current data processing.
[0075] The initialization module 401 is further used for: after the vhost-blk kernel module receives the configuration information sent by the user space through ioctl, it completes the initialization and configuration of vhost-blk.
[0076] The initialization module 401 is further configured to: after receiving a GuestOS notification through KVM, execute the GuestOS notification function. The notification function obtains the instructions and data addresses written by the GuestOS from the virtqueue, extracts and calls the general entry function of the virtual file system VFS provided by the kernel to process the data. After completing the data processing, a notification of completing the data processing is sent to KVM.
[0077] The initialization module 401 is further configured to: the processes between KVM and vhost-blk communicate by calling the eventfd mechanism and the irqfd mechanism.
[0078] The initialization module 401 is further configured to: in the initialization stage of the vhost-blk kernel module, configure and initialize vhost-blk through Qemu.
[0079] The initialization module 401 is further configured to: in the initialization stage, add the initialization of the device's PCI configuration including the vendor ID, device ID, and version number, and support querying and setting the device's configuration.
[0080] The initialization module 401 is further configured to: through an ioctl system call, send a configuration command to the vhost-blk kernel module to complete the complete initialization and configuration process of the vhost-blk device.
[0081] Figure 5 The hardware structure diagram of the computing device 50 for IO virtualization data processing based on the vhost protocol according to the embodiments of the present specification is shown. As Figure 5 shown, the computing device 50 may include at least one processor 501, a memory 502 (such as a non-volatile memory), a memory 503, and a communication interface 504, and at least one processor 501, the memory 502, the memory 503, and the communication interface 504 are connected together via a bus 505. At least one processor 501 executes at least one computer-readable instruction stored or encoded in the memory 502.
[0082] It should be understood that the computer-executable instructions stored in the memory 502, when executed, cause at least one processor 501 to perform the various operations and functions described above in the various embodiments of the present specification in combination with Figures 1 - 5 the description.
[0083] In the embodiments of the present specification, the computing device 50 may include, but is not limited to: a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile computing device, a smart phone, a tablet computer, a cellular phone, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable computing device, a consumer electronic device, and so on.
[0084] According to one embodiment, there is provided a program product such as a machine-readable medium. The machine-readable medium may have instructions (i.e., the elements implemented in software as described above), which when executed by a machine, cause the machine to perform the various operations and functions described above in connection with the various embodiments of this specification. Figures 1 - 5 Specifically, a system or device provided with a readable storage medium may be provided, on which software program code for implementing the functions of any one of the above-described embodiments is stored, and cause a computer or a processor of the system or device to read and execute the instructions stored in the readable storage medium.
[0085] A method and application for IO virtualization data processing based on the vhost protocol according to an embodiment of the present invention can achieve vhost-blk data acceleration processing based on the vhost protocol. By testing with the FIO tool and comparing with the currently most widely used virtio-blk solution, in all scenarios, the read data is better than virtio-blk, with a maximum IO performance improvement of up to twice, and the write data has a maximum IO performance improvement of up to twice in most scenarios. At the same time, the CPU usage is basically the same as that of the virtio-blk solution, achieving generality and enhancing IO performance, and reducing the complexity and uncertainty in actual production implementation.
[0086] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0087] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or more flows and / or blocks
[0088] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means embodying the functionality specified in the flowchart(s) Figure 1 a flowchart or flowcharts and / or block(s) Figure 1 or block(s) specified therein.
[0089] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the functionality specified in the flowchart(s) Figure 1 a flowchart or flowcharts and / or block(s) Figure 1 or block(s) specified therein.
[0090] The foregoing description of specific exemplary embodiments of the present invention has been presented for purposes of illustration and example. It is not intended to limit the invention to the precise form disclosed, and obviously many modifications and variations are possible in light of the above teaching. The exemplary embodiments were chosen and described in order to explain the specific principles of the invention and its practical application to enable one skilled in the art to implement and utilize the invention in various different exemplary embodiments and with various different selections and modifications. The scope of the invention is intended to be defined by the claims and their equivalents.
Claims
1. A method for IO virtualization data processing based on the vhost protocol, characterized in that The method includes: Adding the vhost-blk kernel module to the kernel, and calling the initialization function provided by the vhost protocol to initialize the vhost-blk kernel module, where the initialization includes the implementation of the notification function from the Guest OS; After receiving the notification from the Guest OS, the vhost-blk kernel module obtains the instructions and data addresses written by the Guest OS from the virtqueue send queue shared with the Guest OS; Polling whether new instructions and data arrive in the virtqueue send queue shared with the Guest OS. If so, take them out and call the VFS general entry function to process the data; If no data arrives after the time limit, notify the Guest OS that the data processing task has been completed and end the current data processing; Among them, the initialization by calling the initialization function provided by the vhost protocol includes: The vhost-blk kernel module receives the configuration information sent by the user space through ioctl, and completes the initialization and configuration of vhost-blk; The initialization includes the implementation of the notification function from the Guest OS, including: After receiving the Guest OS notification through KVM, execute the Guest OS notification function. The notification function obtains the instructions and data addresses written by the Guest OS from the virtqueue, takes them out and calls the general entry function of the virtual file system VFS provided by the kernel to process the data. After completing the data processing, send a notification of completing the data processing to KVM.
2. The method for IO virtualization data processing based on the vhost protocol according to claim 1, characterized in that, The sending of the notification of completing the data processing to KVM includes: The processes between KVM and vhost-blk communicate by calling the eventfd mechanism and the irqfd mechanism.
3. The method for IO virtualization data processing based on the vhost protocol according to claim 1, characterized in that The method further includes: During the initialization stage of the vhost-blk kernel module, configure and initialize vhost-blk through Qemu.
4. The method for IO virtualization data processing based on the vhost protocol according to claim 3, characterized in that, The configuration and initialization of vhost-blk through Qemu includes: During the initialization stage, add the initialization of the PCI configuration of the device including the vendor ID, device ID, and version number, and support querying and setting the configuration of the device.
5. The method for IO virtualization data processing based on the vhost protocol according to claim 3, wherein The method further includes: Send a configuration command to the vhost-blk kernel module through the ioctl system call to complete the complete initialization and configuration process of the vhost-blk device.
6. An apparatus for IO virtualization data processing based on the vhost protocol, characterized in that, The device includes: An initialization module, which is used to add the vhost-blk kernel module in the kernel, call the initialization function provided by the vhost protocol to initialize the vhost-blk kernel module, and the initialization includes the implementation of the notification function from the Guest OS; the initialization module is also used for the vhost-blk kernel module to receive the configuration information sent by the user space through ioctl, complete the initialization and configuration of vhost-blk; and execute the Guest OS notification function after receiving the Guest OS notification through KVM. The notification function obtains the instructions and data addresses written by the Guest OS from the virtqueue, extracts and calls the general entry function of the virtual file system VFS provided by the kernel to process the data, and after completing the data processing, sends a notification of completing the data processing to KVM. An information acquisition module, which is used to, after receiving the notification of the Guest OS, the vhost-blk kernel module obtains the instructions and data addresses written by the Guest OS from the virtqueue send queue shared with the Guest OS; and A polling module, which is used to poll whether new instructions and data arrive in the virtqueue send queue shared with the Guest OS; if so, extract and call the VFS general entry function to process the data; if no data arrives after a period of time, notify the Guest OS that the data processing task has been completed and end the current data processing.
7. An electronic device, characterized in that, Comprising: At least one processor; And A memory, the memory stores instructions, and when the instructions are executed by the at least one processor, the at least one processor executes the method for IO virtualization data processing based on the vhost protocol as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for IO virtualization data processing based on the vhost protocol as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Implementing method for optimizing network performance of virtual machine by using multiqueue technology
CN102591715A
I / O redirection method, I / O virtualization system and method, and content delivery apparatus
US20150286490A1