A virtual pass-through device hybrid interrupt-poll adaptive scheduling system

CN122985308APending Publication Date: 2026-10-27RES INST OF SUN YAT SEN UNIV & SHENZHEN
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611218311.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-12
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

但现有技术存在以下缺陷:(1)缺乏任务优先级感知能力,仅基于设备负载统计进行模式切换,无法区分虚拟机内部不同优先级任务的中断处理需求,低优先级任务的大量中断可能导致高优先级任务响应延迟;(2)中断/轮询模式的切换阈值采用静态配置,无法根据系统实时负载和任务紧急程度动态调整,难以兼顾实时性与CPU资源利用率;(3)多虚拟机共享物理主机时,缺乏硬件级中断隔离机制,低优先级虚拟机的中断风暴会抢占中断处理资源,导致高优先级虚拟机实时任务超时;(4)中断处理与任务调度相互独立,宿主机无法获知中断来源所对应的虚拟机内部任务优先级,无法实现中断响应与任务调度的协同

Benefits of technology

本发明提供的一种虚拟直通设备混合中断-轮询自适应调度系统,通过配置管理模块建立物理直通设备优先级与虚拟机内部实时任务优先级的双向映射关系,并确定各设备中断向量所对应的任务优先级权重,使得宿主机层面能够直接感知虚拟机内部不同实时任务对中断响应的差异化需求,打破了传统虚拟化场景中中断处理与任务调度相互独立的信息壁垒,为后续中断路由与模式切换提供了细粒度的优先级依据;硬件辅助中断重定向模块根据上述双向映射关系初始化硬件辅助中断重定向单元,将高优先级权重对应的设备中断映射至宿主机中专用的实时CPU核心,而将其他设备中断分配至其余CPU核心,该配置实现了中断请求在物理CPU核心层面的硬件级隔离与定向分发,显著降低关键中断的响应延迟及延迟抖动,通过将不同类型优先级的中断分散至不同核心,有效避免了低优先级或非关键中断对高优先级中断处理资源的争抢,增强了系统在混合负载场景下的实时确定性;负载监测模块通过综合系统负载信息、各设备对应的虚拟机任务状态信息以及任务优先级权重,计算得到优先级加权负载值,该值不仅反映了设备自身的负载程度,更融合了任务优先级维度,能够准确表征当前系统在实时任务优先级约束下的真实处理压力,克服了传统单一设备负载统计无法区分任务紧急程度的缺陷;模式切换控制模块依据所述优先级加权负载值的取值大小,自适应切换设备的工作模式。该机制使得中断模式与轮询模式的切换决策不再依赖静态阈值或局部负载指标,而是动态跟随系统整体优先级加权负载的变化,能够在高优先级任务密集时及时切换至轮询模式以降低中断开销,实现了虚拟直通设备在复杂工业控制等混合关键性应用场景中的自适应调度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985308A_ABST
    Figure CN122985308A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of virtual machine task scheduling, and particularly relates to a virtual pass-through device hybrid interrupt-polling adaptive scheduling system. The system comprises: a configuration management module, configured to establish a bidirectional mapping relationship between a physical pass-through device priority and a virtual machine internal real-time task priority, and determine a task priority weight; a hardware-assisted interrupt redirection module, configured to initialize a hardware-assisted interrupt redirection unit according to the bidirectional mapping relationship, map a device interrupt corresponding to a high priority weight to a dedicated real-time CPU core in a host computer, and map the remaining device interrupts to other CPU cores; a load monitoring module, configured to obtain a priority-weighted load value according to system load information, virtual machine task state information corresponding to each device, and the task priority weight; and a mode switching control module, configured to adaptively switch the working mode of the device according to the priority-weighted load value. The present application realizes adaptive scheduling of a virtual pass-through device in a complex application scenario.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of virtual machine task scheduling technology, and specifically to a hybrid interrupt-polling adaptive scheduling system for virtual passthrough devices. Background Technology

[0002] With the development of Industry 4.0 and intelligent manufacturing, industrial control systems generally adopt virtualization technology and PCIe device pass-through technology to achieve resource integration and isolation. In order to balance low latency and high throughput, existing technologies adopt a hybrid interrupt-polling scheduling mechanism, such as the NAPI technology of the Linux kernel. However, existing technologies have the following defects: (1) They lack task priority awareness and only switch modes based on device load statistics. They cannot distinguish the interrupt handling needs of different priority tasks inside the virtual machine. A large number of interrupts of low priority tasks may cause high priority tasks to respond late; (2) The switching threshold of interrupt / polling mode is statically configured and cannot be dynamically adjusted according to the real-time load of the system and the urgency of the task. It is difficult to balance real-time performance and CPU resource utilization; (3) When multiple virtual machines share a physical host, there is a lack of hardware-level interrupt isolation mechanism. The interrupt storm of low priority virtual machines will preempt interrupt handling resources, causing high priority virtual machine real-time tasks to time out; (4) Interrupt handling and task scheduling are independent of each other. The host cannot know the priority of the virtual machine task corresponding to the interrupt source and cannot achieve coordination between interrupt response and task scheduling. Summary of the Invention

[0003] To address the aforementioned technical problems, the present invention aims to provide a hybrid interrupt-polling adaptive scheduling system for virtual pass-through devices, the specific technical solution of which is as follows: This invention provides a hybrid interrupt-polling adaptive scheduling system for virtual pass-through devices, the system comprising: The configuration management module is used to establish a two-way mapping relationship between the priority of physical passthrough devices and the priority of real-time tasks inside virtual machines, and to determine the task priority weight corresponding to the interrupt vector of each device. The hardware-assisted interrupt redirection module is used to initialize the hardware-assisted interrupt redirection unit according to the bidirectional mapping relationship, map the device interrupts corresponding to high priority weights to the dedicated real-time CPU cores in the host machine, and map the remaining device interrupts to other CPU cores; the high priority weights are task priority weights that are greater than a preset weight threshold. The load monitoring module is used to obtain the priority-weighted load value based on the system load information, the virtual machine task status information corresponding to each device, and the task priority weight. The mode switching control module is used to adaptively switch the working mode of the device according to the value of the priority weighted load value.

[0004] Preferably, the step of adaptively switching the device's operating mode based on the value of the priority-weighted load includes: switching to polling mode when the priority-weighted load value is higher than an upper threshold; and switching to interrupt mode when the priority-weighted load value is lower than a lower threshold; wherein the upper threshold is greater than the lower threshold.

[0005] Preferably, the formula for calculating the priority-weighted load value is: in, The load value is weighted by priority. Let the task priority weight be the i-th task. Let be the device load value corresponding to the i-th task, and n be the total number of tasks.

[0006] Preferably, when forcibly switched to polling mode, the current interrupt state of the device is saved, and the previous interrupt state and working mode are automatically restored after the high-priority task is completed.

[0007] Preferably, before establishing the bidirectional mapping relationship between the physical passthrough device priority and the real-time task priority within the virtual machine, the method further includes: The priority of the physical passthrough device is specified by the device priority label, and the interrupt vector of the corresponding device is bound to the real-time tasks with different priorities inside the virtual machine by the task priority mapping label.

[0008] Preferably, the hardware-assisted interrupt redirection unit is integrated into the CPU's interrupt controller and is used to route interrupt requests of different priorities to a specified CPU core; the hardware-assisted interrupt redirection unit is implemented based on Intel APICv or AMD AVIC technology.

[0009] Preferably, the dedicated real-time CPU core is a CPU core that is pre-isolated from the host scheduling domain by kernel boot parameters.

[0010] Preferably, after the adaptive switching of the device's operating mode, the method further includes: Interrupt requests from different virtual machines are mapped to their respective independent interrupt vector tables via the IOMMU hardware. These independent interrupt vector tables are isolated from each other in the address space.

[0011] The present invention has at least the following beneficial effects: This invention provides a hybrid interrupt-polling adaptive scheduling system for virtual passthrough devices. Through a configuration management module, a bidirectional mapping relationship is established between the priority of physical passthrough devices and the priority of real-time tasks within the virtual machine. The system also determines the task priority weight corresponding to each device's interrupt vector. This allows the host machine to directly perceive the differentiated interrupt response requirements of different real-time tasks within the virtual machine, breaking down the information barrier between interrupt handling and task scheduling in traditional virtualization scenarios. This provides fine-grained priority criteria for subsequent interrupt routing and mode switching. A hardware-assisted interrupt redirection module initializes the hardware-assisted interrupt redirection unit based on the aforementioned bidirectional mapping relationship. It maps device interrupts with high priority weights to dedicated real-time CPU cores in the host machine, while allocating other device interrupts to other CPU cores. This configuration enables interrupt requests to be processed on the physical CPU cores. Hardware-level isolation and targeted distribution at the core level significantly reduce response latency and jitter of critical interrupts. By distributing interrupts of different priorities to different cores, it effectively avoids contention for high-priority interrupt processing resources by low-priority or non-critical interrupts, enhancing the real-time determinism of the system in mixed load scenarios. The load monitoring module calculates a priority-weighted load value by integrating system load information, virtual machine task status information corresponding to each device, and task priority weights. This value not only reflects the load level of the device itself but also incorporates the task priority dimension, accurately representing the actual processing pressure of the current system under real-time task priority constraints, overcoming the deficiency of traditional single-device load statistics in distinguishing task urgency. The mode switching control module adaptively switches the device's operating mode based on the value of the priority-weighted load value. This mechanism makes the switching decision between interrupt mode and polling mode no longer dependent on static thresholds or local load indicators, but dynamically follows the changes in the overall priority-weighted load of the system. It can switch to polling mode in a timely manner when high-priority tasks are intensive to reduce interrupt overhead, realizing adaptive scheduling of virtual pass-through devices in mixed critical application scenarios such as complex industrial control. Attached Figure Description

[0012] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This is a structural diagram of a virtual pass-through device hybrid interrupt-polling adaptive scheduling system provided in an embodiment of the present invention. Detailed Implementation

[0014] To further illustrate the technical means and effects adopted by the present invention to achieve the intended purpose, the following detailed description of a virtual pass-through device hybrid interrupt-polling adaptive scheduling system proposed according to the present invention is provided in conjunction with the accompanying drawings and preferred embodiments.

[0015] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0016] The following description, in conjunction with the accompanying drawings, details a specific scheme for a virtual pass-through device hybrid interrupt-polling adaptive scheduling system provided by the present invention.

[0017] An embodiment of a hybrid interrupt-polling adaptive scheduling system for virtual pass-through devices: This embodiment proposes a hybrid interrupt-polling adaptive scheduling system for virtual pass-through devices. This system is deployed on an x86 server equipped with Intel VT-d or AMD IOMMU hardware virtualization technology, running a KVM / QEMU virtualization platform and a PREEMT_RT real-time Linux kernel. The system structure is as follows: Figure 1 As shown, the system includes a configuration management module, a hardware-assisted interrupt redirection module, a load monitoring module, and a mode switching control module.

[0018] The configuration management module is used to establish a two-way mapping relationship between the priority of physical pass-through devices and the priority of real-time tasks inside virtual machines, and to determine the task priority weight corresponding to the interrupt vector of each device. The hardware-assisted interrupt redirection module is used to initialize the hardware-assisted interrupt redirection unit according to the bidirectional mapping relationship, map the device interrupts corresponding to high priority weights to the dedicated real-time CPU cores in the host machine, and map the remaining device interrupts to other CPU cores; the high priority weights are task priority weights that are greater than a preset weight threshold. The load monitoring module is used to obtain the priority-weighted load value based on the system load information, the virtual machine task status information corresponding to each device, and the task priority weight. The mode switching control module is used to adaptively switch the working mode of the device according to the value of the priority weighted load value.

[0019] I. Configuration Management Module: This module is used to establish a two-way mapping relationship between the priority of physical passthrough devices and the priority of real-time tasks within the virtual machine, and to determine the task priority weight corresponding to the interrupt vector of each device.

[0020] First, the configuration management module extends the QEMU virtual machine XML configuration file, adding...<device-prioritypriority="1" device="pci_0000_01_00_0" / > The tag is used to specify the global priority of the PCIe network card. (Add) <task-priority-map>The tags are as follows: xml <task-priority-map> <task priority="99" interrupt-vector="0x20" / > <task priority="50" interrupt-vector="0x21" / > <task priority="10" interrupt-vector="0x22" / > < / task-priority-map> The motion control task with priority 99 within the virtual machine is bound to the network card's interrupt vector 0x20, the data acquisition task with priority 50 is bound to interrupt vector 0x21, and the log transmission task with priority 10 is bound to interrupt vector 0x22. Here, 1 represents the highest global priority for the device.

[0021] Based on the XML configuration above, the configuration management module parses the specified device priority values ​​and task priority values ​​to determine the task priority weights corresponding to each device interrupt vector. The specific process is as follows: First, map the priority values ​​of each task in the task priority mapping label. Normalization is performed to map the original priority values ​​to the interval [0, 1]. The normalization calculation formula is as follows: .in, This represents the priority value corresponding to the i-th task. This represents the maximum task priority value supported by the system. Taking Linux's real-time scheduling policy as an example, the real-time task priority ranges from 1 to 99. =99. This normalization process ensures that the weights corresponding to tasks of different priorities have a unified dimensional range, which facilitates the unified calculation of subsequent priority-weighted load values ​​and the unified setting of preset weight thresholds.

[0022] For example: If the task priority value for motion control is 99, then... =99 / 99=1.0; the task priority value of the data acquisition task is 50, then... =50 / 99≈0.505; the task priority value of the log transmission task is 10, then =10 / 99≈0.101.

[0023] It should be noted that the device global priority value specified in the device priority label is used to determine the scheduling priority between devices in a multi-pass-through device concurrent scenario. When multiple devices generate high-priority task interruptions at the same time, the interruption request corresponding to the device with the higher device global priority is processed first, thereby achieving two-level priority scheduling at the device and task dimensions.

[0024] II. Hardware-assisted interrupt redirection module, used to initialize the hardware-assisted interrupt redirection unit according to the bidirectional mapping relationship, map the device interrupts corresponding to high priority weights to the dedicated real-time CPU cores in the host machine, and map the remaining device interrupts to other CPU cores; the high priority weight is the task priority weight that is greater than the preset weight threshold.

[0025] The hardware-assisted interrupt redirection unit in the hardware-assisted interrupt redirection module is integrated into the CPU's interrupt controller and is used to route interrupt requests of different priorities to the specified CPU cores; the hardware-assisted interrupt redirection unit is implemented based on Intel APICv or AMD AVIC technology.

[0026] Specifically, based on the bidirectional mapping relationship between device priorities and real-time task priorities within the virtual machine, a hardware-assisted interrupt redirection unit is initialized. Devices with priority weights greater than a preset weight threshold are designated as high-priority devices, where the preset weight threshold can be 0.5. The interrupts of these high-priority devices are mapped to dedicated real-time CPU cores in the host machine, and the interrupts of the remaining devices are mapped to other CPU cores. These dedicated real-time CPU cores are CPU cores pre-isolated from the host machine's scheduling domain using kernel boot parameters. The hardware-assisted interrupt redirection unit utilizes Intel APICv technology to map the network card's 0x20 interrupt vector to CPU core 3 in the host machine (pre-isolated using the isolcpus parameter), and to map interrupt vectors 0x21 and 0x22 to CPU core 2.

[0027] III. Load monitoring module, used to obtain priority-weighted load value based on system load information, virtual machine task status information corresponding to each device and the task priority weight.

[0028] The load monitoring module collects data packet reception rate, CPU utilization, and virtual machine task running status at 1ms intervals, and calculates the priority-weighted load value using the following formula: in, The load value is weighted by priority. Let the task priority weight be the i-th task. Let be the device load value corresponding to the i-th task, and n be the total number of tasks.

[0029] IV. Mode switching control module, used to adaptively switch the working mode of the device according to the value of the priority weighted load value.

[0030] The mode switching control module sets an upper threshold and a lower threshold, wherein the upper threshold is greater than the lower threshold. In this embodiment, the upper threshold can be 80 and the lower threshold can be 30. In specific applications, the implementer can set them according to the specific situation.

[0031] When the priority-weighted load value is higher than the upper threshold, the network card is automatically switched to polling mode; when the priority-weighted load value is lower than the lower threshold, it is automatically switched to interrupt mode. When a motion control task with priority 99 arrives, the mode switching control module immediately forces the network card to switch to polling mode, disables interrupt vectors 0x21 and 0x22, and only keeps the polling thread running on CPU core 3 until the motion control task is completed, then restores the previous interrupt state and working mode.

[0032] Furthermore, the IOMMU maps the network card interrupts of virtual machine A to interrupt vector tables 0-127, and the network card interrupts of virtual machine B to interrupt vector tables 128-255, ensuring that the interrupt requests of the two virtual machines are isolated from each other. When virtual machine B generates a large number of low-priority interrupts, it will not affect the high-priority interrupt processing of virtual machine A.

[0033] Testing revealed that this embodiment employs hardware-assisted interrupt redirection technology, directly routing high-priority interrupts to isolated real-time CPU cores, bypassing the host interrupt scheduler, significantly reducing interrupt handling latency with response latency fluctuations of less than 1μs. This embodiment balances hard real-time performance with CPU resource utilization, improving CPU resource utilization by 20%-30%. The maximum response latency for a hard real-time task with priority 99 is 5μs, with fluctuations of less than 1μs, meeting the hard real-time requirements of industrial control. Under the same load, CPU resource utilization is improved by 25% compared to the traditional static hybrid mode. When multiple virtual machines are running concurrently, the performance degradation of high-priority virtual machines is less than 5%.

[0034] Thus, the method provided in this embodiment has enabled hybrid interrupt-polling adaptive scheduling of virtual pass-through devices.

[0035] This embodiment provides a hybrid interrupt-polling adaptive scheduling system for virtual passthrough devices. Through a configuration management module, a bidirectional mapping relationship is established between the priority of physical passthrough devices and the priority of real-time tasks within the virtual machine. The system also determines the task priority weight corresponding to each device's interrupt vector. This allows the host machine to directly perceive the differentiated interrupt response requirements of different real-time tasks within the virtual machine, breaking down the information barrier between interrupt handling and task scheduling in traditional virtualization scenarios. This provides fine-grained priority criteria for subsequent interrupt routing and mode switching. The hardware-assisted interrupt redirection module initializes the hardware-assisted interrupt redirection unit based on the aforementioned bidirectional mapping relationship. It maps device interrupts with high priority weights to dedicated real-time CPU cores in the host machine, while allocating other device interrupts to other CPU cores. This configuration enables interrupt requests to be processed at the physical CPU core level. Hardware-level isolation and targeted distribution at the core level significantly reduce response latency and jitter of critical interrupts. By distributing interrupts of different priorities to different cores, it effectively avoids contention for high-priority interrupt processing resources by low-priority or non-critical interrupts, enhancing the real-time determinism of the system in mixed load scenarios. The load monitoring module calculates a priority-weighted load value by integrating system load information, virtual machine task status information corresponding to each device, and task priority weights. This value not only reflects the load level of the device itself but also incorporates the task priority dimension, accurately representing the actual processing pressure of the current system under real-time task priority constraints, overcoming the deficiency of traditional single-device load statistics in distinguishing task urgency. The mode switching control module adaptively switches the device's operating mode based on the value of the priority-weighted load value. This mechanism makes the switching decision between interrupt mode and polling mode no longer dependent on static thresholds or local load indicators, but dynamically follows the changes in the overall priority-weighted load of the system. It can switch to polling mode in a timely manner when high-priority tasks are intensive to reduce interrupt overhead, realizing adaptive scheduling of virtual pass-through devices in mixed critical application scenarios such as complex industrial control.

[0036] It should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A hybrid interrupt-polling adaptive scheduling system for virtual pass-through devices, characterized in that, The system includes: The configuration management module is used to establish a two-way mapping relationship between the priority of physical passthrough devices and the priority of real-time tasks inside virtual machines, and to determine the task priority weight corresponding to the interrupt vector of each device. The hardware-assisted interrupt redirection module is used to initialize the hardware-assisted interrupt redirection unit according to the bidirectional mapping relationship, map the device interrupts corresponding to high priority weights to the dedicated real-time CPU cores in the host machine, and map the remaining device interrupts to other CPU cores; the high priority weights are task priority weights that are greater than a preset weight threshold. The load monitoring module is used to obtain the priority-weighted load value based on the system load information, the virtual machine task status information corresponding to each device, and the task priority weight. The mode switching control module is used to adaptively switch the working mode of the device according to the value of the priority weighted load value.

2. The virtual pass-through device hybrid interrupt-polling adaptive scheduling system according to claim 1, characterized in that, The step of adaptively switching the device's operating mode based on the value of the priority-weighted load includes: switching to polling mode when the priority-weighted load value is higher than an upper threshold; switching to interrupt mode when the priority-weighted load value is lower than a lower threshold; wherein the upper threshold is greater than the lower threshold.

3. The virtual pass-through device hybrid interrupt-polling adaptive scheduling system according to claim 1, characterized in that, The formula for calculating the priority-weighted load value is as follows: in, The load value is weighted by priority. Let the task priority weight be the i-th task. Let be the device load value corresponding to the i-th task, and n be the total number of tasks.

4. The virtual pass-through device hybrid interrupt-polling adaptive scheduling system according to claim 1, characterized in that, When forced to switch to polling mode, the current interrupt state of the device is saved, and the previous interrupt state and working mode are automatically restored after the high-priority task is completed.

5. The virtual pass-through device hybrid interrupt-polling adaptive scheduling system according to claim 1, characterized in that, Before establishing the bidirectional mapping relationship between the physical passthrough device priority and the real-time task priority within the virtual machine, the following steps are also included: The priority of the physical passthrough device is specified by the device priority label, and the interrupt vector of the corresponding device is bound to the real-time tasks with different priorities inside the virtual machine by the task priority mapping label.

6. The virtual pass-through device hybrid interrupt-polling adaptive scheduling system according to claim 1, characterized in that, The hardware-assisted interrupt redirection unit is integrated into the CPU's interrupt controller and is used to route interrupt requests of different priorities to a specified CPU core; the hardware-assisted interrupt redirection unit is implemented based on Intel APICv or AMD AVIC technology.

7. The virtual pass-through device hybrid interrupt-polling adaptive scheduling system according to claim 1, characterized in that, The dedicated real-time CPU core is a CPU core that is pre-isolated from the host machine scheduling domain through kernel boot parameters.

8. The virtual pass-through device hybrid interrupt-polling adaptive scheduling system according to claim 1, characterized in that, After the adaptive switching of the device's operating mode, the following is also included: Interrupt requests from different virtual machines are mapped to their respective independent interrupt vector tables via the IOMMU hardware. These independent interrupt vector tables are isolated from each other in the address space.