Search

CN-121996380-A - Vsock quick notification method based on hardware interrupt request

CN121996380ACN 121996380 ACN121996380 ACN 121996380ACN-121996380-A

Abstract

The invention relates to the technical field of virtualized communication, and discloses a Vsock quick notification method based on a hardware interrupt request. The invention constructs the binding relation between physical interrupt and ioeventfd/irqfd by configuring special physical hardware interrupt number for Vsock virtual queue, binds interrupt to exclusive virtual CPU and forbids other interrupt interference, and utilizes ACRN drive to build the binding relation between physical interrupt and ioeventfd/irqfd, to realize the bidirectional mechanism of hardware interrupt triggering ioeventfd and irqfd writing generation interrupt, and by dynamically raising the priority of exclusive virtual CPU to ensure instant dispatch and raising the front and rear working threads to real-time level, a complete low-delay path from hardware interrupt to thread processing is formed. The invention effectively solves the problems of long path and high delay of the traditional work queue mechanism, and remarkably improves the instantaneity and the certainty of Vsock communication while maintaining the compatibility and the rollback capability of codes.

Inventors

  • ZHANG QIANG
  • MENG QINGYANG
  • SHAN ZHONGYUAN

Assignees

  • 宁波谦川科技有限公司

Dates

Publication Date
20260508
Application Date
20260126

Claims (10)

  1. 1. A quick Vsock notification method based on a hardware interrupt request, which is applied to a virtualized system including a host and at least one virtual machine, and is characterized in that the method comprises the following steps: s1, configuring a group of special physical hardware interrupt numbers for a plurality of virtual queues of Vsock equipment, wherein each virtual queue corresponds to two interrupt numbers and is respectively used for notifying from a virtual machine UOS to a host SOS and from the host SOS to the virtual machine UOS; S2, binding all Vsock configured physical hardware interrupts to a designated virtual CPU in the host machine, and prohibiting other hardware interrupts from being bound to the virtual CPU, so that the virtual CPU becomes an exclusive processing unit of Vsock interrupts; S3, establishing a binding relation between the physical hardware interrupt number and ioeventfd and irqfd in vhost architecture through an ioctl interface of an ACRN driver, so that the physical interrupt can trigger ioeventfd and the writing of irqfd can generate physical interrupt; S4, when Vsock hardware interrupt is triggered, dynamically improving the scheduling priority of the exclusive virtual CPU by utilizing the existing mechanism in the virtual CPU shared core scheduling algorithm, and ensuring that the exclusive virtual CPU is scheduled immediately; S5, the scheduling priority of the service operating system working thread at the back end of vhost and the scheduling priority of the user operating system working thread at the front end of Vsock are both improved to the real-time level.
  2. 2. The method of claim 1, wherein the Vsock device is configured with physical hardware interrupt numbers by modifying the sos.json or uos.lua configuration file to assign 12 consecutive interrupt numbers to the Vsock virtual queues in the order < VQ0 sos >, < VQ0 uos >, < VQ1 sos >, < VQ1 uos >,.
  3. 3. The method of claim 1, wherein prohibiting other hardware interrupts from being bound to the virtual CPU comprises explicitly prohibiting UFS interrupts that are processed for a millisecond level from being bound to the Vsock interrupt-specific virtual CPU.
  4. 4. The method for quickly notifying Vsock based on hardware interrupt request according to claim 1, wherein the step of establishing a binding relationship is performed by a VMM Agent module embedded in a host SOS, the module reads an interrupt number in a configuration file and binds the interrupt number with ioeventfd, irqfd through an ioctl call.
  5. 5. The method of claim 1, wherein the service operating system worker thread on the back end of vhost is scheduled to run on the Vsock interrupt-specific virtual CPU to avoid preemption by other hardware interrupts.
  6. 6. The method of claim 5, further comprising a rollback mechanism, wherein when the physical hardware interrupt number is not properly configured in the configuration file, the Vsock communication automatically rollbacks to an original notification mechanism using an ACRN-driven work queue.
  7. 7. The method for quick notification of Vsock based on a hardware interrupt request according to claim 6, wherein the method includes the following steps in the initialization phase: the first flow is that the system management program reads Vsock interrupt configuration in the configuration file and updates the system equipment tree; Vsock front end drive obtains interrupt number from equipment tree, and registers corresponding interrupt processing function; The VMM Agent module reads the configuration, acquires an interrupt number for notification, and completes ioeventfd, irqfd binding with a physical interrupt number through an ACRN driver; and in the fourth process, the bound ioeventfd and irqfd are forwarded to vhost back-end equipment, and vhost starts a working thread to monitor ioeventfd.
  8. 8. The method for quick notification of Vsock based on a hardware interrupt request according to claim 7, wherein a trigger flow of Vsock notification from a virtual machine UOS to a host SOS is: Vsock, the front end sends a security monitoring call SMC trapping system management program, and a general interrupt controller GIC register is directly written in the thread of the exclusive virtual CPU to trigger hardware interrupt; The hardware interrupt is routed to the exclusive virtual CPU bound on the SOS side of the host machine, and an interrupt processing function is triggered; The third process is that the interrupt processing function signals ioeventfd which is bound; And in a fourth process, ioeventfd, waking up the vhost working thread which is lifted to the real-time priority, and processing the corresponding virtual queue.
  9. 9. The method for quick notification of Vsock based on a hardware interrupt request according to claim 7, wherein a trigger flow of Vsock notification from a host SOS to a virtual machine UOS is: the back end of Vsock writes data into the bound irqfd; a irqfd object in the ACRN driver calls a security monitoring call SMC and injects physical interrupt into the general interrupt controller GIC; And thirdly, routing the hardware interrupt to the exclusive virtual CPU bound on the UOS side of the virtual machine, and triggering Vsock the front-end driver registered interrupt processing function to process the back-end message.
  10. 10. The method of claim 9, wherein the hardware interrupt request based Vsock fast notification mechanism is applicable to other virtual devices using vhost or vhost-user protocols after modifying only interrupt configuration and binding related code.

Description

Vsock quick notification method based on hardware interrupt request Technical Field The invention relates to the technical field of virtualized communication, in particular to a Vsock quick notification method based on a hardware interrupt request. Background In a virtualized environment, efficient communication between a virtual machine and a host machine or between virtual machines is a key to implementing high performance virtualized applications. Vsock as a high performance communication mechanism specifically designed for virtualized environments, a low latency data transmission channel is provided between the virtual machine and the host machine, and the core is that communication is achieved through the kernel module and data transmission is performed depending on VMCI. However, the existing Vsock notification mechanism has the problem of long notification path, the long path causes higher communication delay, and is difficult to meet the application scene with higher real-time requirement, for example, when the virtual machine needs to notify the host machine or otherwise under the ACRN architecture, a plurality of software-level processes and schedules are generally involved, including queuing of Workqueue, context switching of a scheduler and the like, and the links all introduce non-negligible time overhead, and particularly in the scene of frequently performing cross-virtual machine notification, the accumulated delay can seriously affect the overall system performance and user experience. Disclosure of Invention The technical problem to be solved by the invention is that a Vsock notification mechanism in the prior art has the defect of higher communication delay, and therefore, a Vsock rapid notification method based on a hardware interrupt request is provided. In order to achieve the above purpose, the application adopts the following technical scheme that the Vsock quick notification method based on the hardware interrupt request is applied to a virtualization system comprising a host machine and at least one virtual machine, and the method comprises the following steps: s1, configuring a group of special physical hardware interrupt numbers for a plurality of virtual queues of Vsock equipment, wherein each virtual queue corresponds to two interrupt numbers and is respectively used for notifying from a virtual machine UOS to a host SOS and from the host SOS to the virtual machine UOS; S2, binding all Vsock configured physical hardware interrupts to a designated virtual CPU in the host machine, and prohibiting other hardware interrupts from being bound to the virtual CPU, so that the virtual CPU becomes an exclusive processing unit of Vsock interrupts; S3, through an ioctl interface of the ACRN driver, a binding relation between a physical hardware interrupt number and ioeventfd and irqfd in vhost architecture is established, so that the physical interrupt can trigger ioeventfd, and writing to irqfd can generate physical interrupt; s4, when Vsock hardware interrupt is triggered, the existing mechanism in the virtual CPU shared core scheduling algorithm is utilized to dynamically improve the scheduling priority of the exclusive virtual CPU, so that the exclusive virtual CPU is ensured to be scheduled immediately; S5, the scheduling priority of the service operating system working thread at the back end of vhost and the scheduling priority of the user operating system working thread at the front end of Vsock are both improved to the real-time level. Preferably, the physical hardware interrupt numbers are configured for Vsock devices by modifying the sos.json or uos.lua profile to assign 12 consecutive interrupt numbers to the Vsock virtual queues in the order < VQ0 sos >, < VQ0 uos >, < VQ1 sos >, < VQ1 uos >,. Preferably, disabling other hardware interrupts from binding to the virtual CPU includes explicitly disabling UFS interrupts that are processed for a millisecond level from binding to the Vsock interrupt-specific virtual CPU. Preferably, the step of establishing the binding relationship is performed by a VMM Agent module embedded in the host SOS, which reads the interrupt number in the configuration file and binds the interrupt number with ioeventfd, irqfd through an ioctl call. Preferably, service operating system worker threads on the vhost back-end are scheduled to run on Vsock interrupt-specific virtual CPUs, thereby avoiding preemption by other hardware interrupts. Preferably, the method further comprises a rollback mechanism whereby Vsock communications are automatically rolled back to the original notification mechanism using an ACRN-driven work queue when the physical hardware interrupt number is not properly configured in the configuration file. Preferably, the method comprises the following steps in the initialization phase: the first flow is that the system management program reads Vsock interrupt configuration in the configuration file and updates the system equipment tree; Vso