Virtualized input and output optimization method and device, equipment and storage medium
By coordinating and linking virtual machines and host machines, and dynamically adjusting virtual circular queues and resource allocation, the problems of insufficient dynamic adaptability and resource utilization of VirtIO technology are solved, thereby improving the system stability and efficiency of virtualized input/output scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-03-31
AI Technical Summary
Existing VirtIO technology has limitations in terms of dynamic adaptability, resource utilization, and reliability, making it difficult to apply effectively in high-load, high-reliability scenarios.
By monitoring the status of the main virtual circular queue through the virtual machine, generating adjustment policies and sending requests to the host machine, a virtual circular shadow queue is created. Combined with snapshot technology and multi-level verification mechanisms, the resource allocation and scheduling priority of virtual devices are dynamically adjusted to achieve seamless switching of virtual circular queues and precise allocation of resources.
It improves system stability, resource utilization, and overall I/O processing efficiency in virtualized input/output scenarios, avoids system fluctuations caused by frequent queue expansion/shrinkage, optimizes resource competition and request dependencies among multiple devices, and ensures the continuity of input/output services.
Smart Images

Figure CN121764595A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud computing virtualization technology, and in particular to a virtualization input / output optimization method, apparatus, device, and storage medium. Background Technology
[0002] VirtIO, as the de facto standard for I / O (input / output, or read / write) devices in virtualized environments, significantly reduces the emulation overhead of virtual devices through paravirtualization technology. It has been widely adopted by mainstream virtualization platforms such as KVM (Kernel-based Virtual Machine, a virtualization module of the Linux kernel) and QEMU (Quick Emulator, an open-source hardware emulator and virtualization tool). Its core functionality involves using VRing (Virtual Circular Queues) to achieve efficient data interaction between the virtual machine and the host machine. I / O requests are placed in the available circular queue of VRing and the host machine is notified. After processing, the host machine writes the result to the used circular queue of VRing and triggers a virtual machine interrupt, completing one I / O interaction. However, existing VirtIO technology still has limitations in terms of dynamic adaptability, resource utilization, and reliability, restricting its further application in high-load, high-reliability scenarios. For example, how can VRing match real-time demands and adapt to the dynamic changes in business load in cloud computing scenarios? And how can resource contention caused by I / O devices sharing host resources be reduced?
[0003] Therefore, improving the dynamic adaptability, resource utilization, and reliability of VirtIO technology is a pressing technical problem that needs to be solved. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a virtualization input / output optimization method, apparatus, device and storage medium, which solves the problems of insufficient dynamic adaptability, resource utilization and reliability of the existing VirtIO technology.
[0005] To address the aforementioned technical problems, this invention provides a virtualization input / output optimization method, comprising: obtaining status information by monitoring the status of a main virtual circular queue through a virtual machine; generating an adjustment strategy based on the status information, three-level judgment conditions, and a hysteresis mechanism; and sending an adjustment request to the host machine based on the adjustment strategy; the three-level judgment conditions include early warning conditions, regular expansion / shrinkage conditions, and emergency expansion / shrinkage conditions; the hysteresis mechanism is to set a buffer area between triggering regular expansion conditions and regular shrinkage conditions; when the host machine receives the adjustment request sent by the virtual machine, it creates and initializes a virtual circular shadow queue with the same size as the target capacity, and captures the status of the main virtual circular queue based on snapshot technology. The system migrates ongoing input / output requests and descriptors from the main virtual circular queue to the virtual circular shadow queue, and updates the index of the active circular queue in the system based on the virtual circular shadow queue. The host machine monitors virtual devices, and when multiple virtual devices simultaneously request memory, the scheduling priority and resource requirements of each virtual device are determined based on its resource usage, request queue length, device type, and request dependency graph. Resources are dynamically allocated to each virtual device based on the scheduling priority and resource requirements. The request dependency graph is constructed by parsing the request data from the virtual device front-end driver and identifying the causal relationships between input / output requests based on the request data.
[0006] On one hand, status information is obtained by monitoring the main virtual circular queue through the virtual machine. Based on the status information, as well as the three-level judgment conditions and hysteresis mechanism, an adjustment strategy is generated, and an adjustment request is sent to the host machine based on the adjustment strategy. This includes: using the virtual machine's dynamic circular queue management module to monitor the utilization rate of the main virtual circular queue and the queuing status of input and output requests in real time to obtain monitoring information, and using historical data of the sliding time window combined with a load prediction algorithm to predict the input and output load trend within a future preset time to obtain prediction information; when the monitoring information and the prediction information reach the warning conditions, the monitoring frequency and prediction frequency are increased, and a background memory pre-allocation operation is performed; when the monitoring information and the prediction information reach the regular expansion / shrinkage conditions, a regular expansion / shrinkage request is triggered; the magnitude of the regular expansion / shrinkage is calculated and determined based on the current load status and the preset strategy; when the monitoring information and the prediction information reach the emergency expansion / shrinkage conditions, the highest priority emergency expansion / shrinkage request is triggered; the expansion / shrinkage is performed using an aggressive expansion strategy.
[0007] On one hand, when the host machine receives an adjustment request from the virtual machine, it creates and initializes a virtual circular shadow queue with the same size as the target capacity, captures the state of the main virtual circular queue based on snapshot technology, migrates in-process input / output requests and descriptors in the main virtual circular queue to the virtual circular shadow queue, and updates the index of active circular queues in the system according to the virtual circular shadow queue. This includes: when the host machine receives an adjustment request from the virtual machine, determining the target capacity size according to the adjustment request, allocating memory space of the corresponding capacity and initializing the virtual circular shadow queue, and recording the control block data structure of the virtual circular shadow queue; inserting a read memory barrier instruction into the main virtual circular queue, and atomically reading the key index value of the main virtual circular queue to generate a consistency block. The process involves: identifying ongoing input / output requests based on the consistency snapshot; migrating the ongoing input / output requests and descriptors to the virtual ring shadow queue; synchronizing the key index values of the main virtual ring queue to the virtual ring shadow queue; creating a control block containing metadata of the main virtual ring queue; employing a double-buffering mechanism and version number management to perform an atomic switch operation; updating the indexes of active ring queues in the system to those of the virtual ring shadow queue; the metadata includes a descriptor table, available ring base addresses, used ring base addresses, and the capacity of the virtual ring shadow queue; verifying the availability switch result of the virtual ring shadow queue; and releasing the memory resources occupied by the main virtual ring queue after the virtual ring shadow queue has been verified.
[0008] On one hand, the host machine monitors virtual devices. When multiple virtual devices simultaneously request memory, the scheduling priority and resource requirements of each virtual device are determined based on its resource usage, request queue length, device type, and request dependency graph. Resources are then dynamically allocated to each virtual device based on the scheduling priority and resource requirements. This includes: real-time collection of resource usage and request queue length of each virtual device by the host machine's coordinator, and determination of resource scarcity; identification of causal relationships between requests by parsing the virtual device request metadata, forming request chains; preset basic priorities according to the device type of the virtual devices, and performing dependency correction and load correction on the basic priorities based on the causal relationships of the request chains and the request queue length, dynamically adjusting the priority of each virtual device; when multiple virtual devices simultaneously request memory resources, the scheduling priority of each virtual device is determined based on its priority and the resource scarcity; and resource allocation is dynamically performed to each virtual device based on the scheduling priority and resource requirements. The resource requirements include the resource usage and request queue length.
[0009] On the one hand, it also includes: collecting indicator values corresponding to lightweight indicators through the virtual machine's status monitoring module; the lightweight indicators include queue pressure index, request processing latency index, and system load coefficient; determining the interrupt handling method based on the indicator values and a preset interrupt suppression dynamic algorithm; the preset interrupt suppression dynamic algorithm is any one of the weighted interrupt suppression dynamic algorithm, interval interrupt suppression dynamic algorithm, PID interrupt suppression dynamic algorithm, and differential interrupt suppression dynamic algorithm.
[0010] On the one hand, it also includes: employing a multi-level verification mechanism throughout the entire interaction process between the virtual machine and the host machine; the multi-level verification mechanism includes data buffer level verification, descriptor chain level verification, and transaction level verification; monitoring the response status of the virtual device through the host machine, monitoring the update status of the virtual circular shadow queue through the virtual machine, and using time series analysis to predict anomalies in conjunction with load and interruption-related monitoring indicators; when an error occurs during verification or an anomaly is detected / predicted, the virtual machine notifies the host machine to trigger a failover, copying unprocessed input / output requests to a backup virtual circular queue, and switching to the backup virtual circular queue through the virtual machine to continue running; the failover adopts a circular queue method based on hot backup or achieves seamless switching of active queues through atomic operations.
[0011] On one hand, when an error occurs during verification or an anomaly is detected / predicted, the virtual machine notifies the host machine to trigger a failover, copying unprocessed input / output requests to a standby virtual circular queue. After the virtual machine switches to the standby virtual circular queue to continue running, the process further includes: resetting the virtual circular shadow queue via the host machine; once the virtual circular shadow queue is repaired, the host machine synchronizes the unprocessed requests in the standby virtual circular queue to the virtual circular shadow queue, so that the virtual machine switches back to the virtual circular shadow queue to run, and the standby virtual circular queue returns to a standby state; if the virtual circular shadow queue cannot be repaired within a preset time, the input / output service is maintained through the standby virtual circular queue.
[0012] This invention also provides a virtualization input / output optimization device, comprising: a monitoring and decision-making module, used to obtain status information by monitoring the status of a main virtual circular queue through a virtual machine, generate an adjustment strategy based on the status information, a three-level judgment condition, and a hysteresis mechanism, and send an adjustment request to the host machine based on the adjustment strategy; the three-level judgment condition includes an early warning condition, a regular expansion / shrinkage condition, and an emergency expansion / shrinkage condition; the hysteresis mechanism is to set a buffer area between triggering the regular expansion condition and the regular shrinkage condition; and a migration synchronization module, used to create and initialize a virtual circular shadow queue with the same size as the target capacity when the host machine receives the adjustment request sent by the virtual machine, and capture the status of the main virtual circular queue based on snapshot technology. The system migrates ongoing input / output requests and descriptors from the main virtual circular queue to the virtual circular shadow queue, and updates the index of the active circular queue in the system based on the virtual circular shadow queue. A multi-device collaboration module monitors virtual devices through the host machine. When multiple virtual devices simultaneously request memory, it determines the scheduling priority and resource requirements of each virtual device based on their resource usage, request queue length, device type, and request dependency graph. It then dynamically allocates resources to each virtual device based on these scheduling priorities and resource requirements. The request dependency graph is constructed by parsing the request data from the virtual device front-end driver and identifying the causal relationships between input / output requests based on this request data.
[0013] The present invention also provides a virtualized input / output optimization device, comprising: a memory for storing a computer program; and a processor for implementing the virtualized input / output optimization method as described above when executing the computer program.
[0014] The present invention also provides a computer-readable storage medium storing computer-executable instructions, which, when loaded and executed by a processor, implement the virtualization input / output optimization method described above.
[0015] The present invention also provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the steps of the virtualization input / output optimization method described above.
[0016] As can be seen from the above technical solution, this invention obtains status information by monitoring the status of the main virtual circular queue through a virtual machine. Based on the status information, as well as three-level judgment conditions and a hysteresis mechanism, an adjustment strategy is generated, and an adjustment request is sent to the host machine based on the adjustment strategy. The three-level judgment conditions include early warning conditions, normal expansion / shrinkage conditions, and emergency expansion / shrinkage conditions. The hysteresis mechanism sets a buffer area between triggering normal expansion conditions and normal shrinkage conditions. When the host machine receives the adjustment request sent by the virtual machine, it creates and initializes a virtual circular shadow queue with the same size as the target capacity, captures the status of the main virtual circular queue based on snapshot technology, and sets the main virtual circular queue to the target capacity. In-process input / output requests and descriptors in the quasi-circular queue are migrated to the virtual circular shadow queue, and the index of the active circular queue in the system is updated according to the virtual circular shadow queue. Virtual devices are monitored by the host machine. When multiple virtual devices request memory simultaneously, the scheduling priority and resource requirements of each virtual device are determined based on the resource usage, request queue length, device type, and request dependency graph of each virtual device. Resources are dynamically allocated to each virtual device according to the scheduling priority and resource requirements. The request dependency graph is constructed by parsing the request data of the virtual device front-end driver and identifying the causal relationship between input and output requests based on the request data. The beneficial effects of this invention are as follows: Through the collaborative linkage between the virtual machine and the host machine, this invention, on the one hand, uses a three-level judgment condition and hysteresis mechanism to accurately generate adjustment strategies for the virtual circular queue, effectively avoiding system fluctuations caused by frequent queue expansion / shrinkage. Combined with snapshot migration technology, it achieves complete handling of ongoing requests during queue switching, ensuring the continuity of input / output services. On the other hand, by integrating multi-dimensional information such as virtual device resource usage and request queue length on the host machine, and combining request dependency graphs to identify causal relationships between requests to optimize scheduling priorities, this invention not only solves the problem of multi-device resource contention but also avoids the risk of priority inversion caused by conventional scheduling ignoring request dependencies, achieving precise dynamic allocation of resources. Ultimately, this significantly improves system stability, resource utilization, and overall I / O processing efficiency in virtualized input / output scenarios.
[0017] In addition, the present invention also provides a virtualization input / output optimization device, equipment and storage medium, which also have the above-mentioned beneficial effects. Attached Figure Description
[0018] To more clearly illustrate the technical solutions 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 embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0019] Figure 1A flowchart illustrating a virtualization input / output optimization method provided in an embodiment of the present invention;
[0020] Figure 2 A flowchart of virtualized I / O interaction based on Vring is provided for an embodiment of the present invention;
[0021] Figure 3 A flowchart of resource scheduling and VRing fault tolerance interaction provided in an embodiment of the present invention;
[0022] Figure 4 This is a schematic diagram of the structure of a virtualized input / output optimization device provided in an embodiment of the present invention;
[0023] Figure 5 This is a schematic diagram of the structure of a virtualized input / output optimization device provided in an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] First, let's analyze some of the terms used in this application:
[0026] VirtIO: A general-purpose virtualized I / O device standard that enables efficient I / O interaction between virtual machines and the host through paravirtualization technology, supporting various virtual devices (such as block devices and network devices).
[0027] VRing: The core transmission mechanism of VirtIO, a virtual circular queue. It implements data exchange based on a circular buffer and consists of three parts: a descriptor table, an available circular queue, and a used circular queue. It is a key structure for data exchange between the virtual machine and the host.
[0028] virtqueue: In VirtIO, a queue abstraction used to manage I / O requests. Each device can contain one or more virtqueues (such as the send queue and receive queue of a network device), which are implemented through VRing at the underlying level.
[0029] Interruption suppression: Reduce unnecessary interrupt notifications by setting flags (such as VRING_AVAIL_F_NO_INTERRUPT in VRing), thereby reducing the interaction overhead between the virtual machine and the host.
[0030] VirtIO-PCI: This is the implementation of VirtIO on the PCI bus. It uses the PCI configuration space and registers to negotiate device configuration and features, and is the mainstream deployment method for VirtIO devices.
[0031] Descriptor chain: A buffer chain formed by concatenating multiple VRing descriptors through the "next" field, used to transfer I / O data in scatter-gather form.
[0032] VRing utilization: The ratio of the number of currently used descriptors to the total capacity (e.g., 60% means that 60% of the descriptors are occupied by I / O requests), used to determine whether VRing needs to be expanded.
[0033] Request processing latency: The time from when the virtual machine puts a request into VRing to when the host completes processing and writes it into the used circular queue, reflecting the host's processing capacity.
[0034] Device priority: The weight assigned to VirtIO devices based on business importance (e.g., database disks have higher priority than ordinary network cards), used for resource allocation during collaborative scheduling.
[0035] Backup VRing: A redundant circular buffer independent of the primary VRing. It is synchronized with the primary VRing during initialization and seamlessly switches over to take over I / O requests in case of failure.
[0036] Virtual devices based on VirtIO refer to virtual I / O devices (such as virtual network adapters and virtual hard disks) simulated by the host virtualization layer and conforming to the VirtIO standard protocol, used to provide standardized I / O services for virtual machines. They are created through the host virtualization layer, follow the VirtIO protocol, and communicate with virtual machines through VRing queues.
[0037] The current VirtIO VRing size is determined during device initialization (e.g., 64 or 128 descriptors) and cannot be dynamically adjusted based on I / O request volume. When the load surges (e.g., a sudden increase in network packets), VRing is prone to buffer shortages leading to request blocking; conversely, during periods of low load, a fixed VRing size wastes memory resources. Furthermore, multiple virtual devices within the same virtual machine share the host machine's CPU and memory resources, but existing technologies schedule each virtual device's virtqueue independently, neglecting resource dependencies. For example, a large number of network interface card (NIC) receive requests may preempt disk I / O resources, causing disk response delays. To address these issues, this invention provides a virtualization input / output optimization method, which can be found in the following reference. Figure 1 , Figure 1 A flowchart illustrating a virtualization input / output optimization method provided in an embodiment of the present invention. The method may include:
[0038] S101: The virtual machine monitors the status of the main virtual circular queue to obtain status information. Based on the status information, as well as the three-level judgment conditions and hysteresis mechanism, an adjustment strategy is generated, and an adjustment request is sent to the host machine based on the adjustment strategy.
[0039] The execution subject in this embodiment is a terminal. This embodiment does not limit the type of terminal, as long as it can perform the virtualization input / output optimization method. It should be noted that the three-level judgment conditions in this embodiment include warning conditions, regular expansion / shrinkage conditions, and emergency expansion / shrinkage conditions; the hysteresis mechanism sets a buffer area between triggering regular expansion and regular shrinkage conditions. This embodiment does not limit the status information. The adjustment request in this embodiment refers to an adjustment request to the main Vring (i.e., the main virtual circular queue), which can be an expansion request or a shrinkage request.
[0040] It is understandable that when the virtual machine starts, the host machine completes the initialization of the virtual device through the VirtIO-PCI interface, and reserves resources for dynamic optimization and reliability mechanisms. Specifically, this may include: (1) Creation of primary VRing and standby VRing: The host machine creates a primary VRing (initial size can be 128 descriptors) and a standby VRing (the same size as the primary VRing) for the virtual device, and informs the virtual machine through the PCI configuration space. (2) Basic parameter settings: The virtual machine driver reads the characteristics of the virtual device (such as support for dynamic VRing, interrupt suppression), initializes the descriptor table of VRing, the available circular queue and the used circular queue, and sets the initial interrupt suppression flag (default is off, i.e., interrupts are allowed). (3) Cooperative scheduling registration: The virtual machine sends the priority of the virtual device (such as high, medium and low) to the host machine through the VirtIO configuration space, and records the virtual device information and includes it in the scheduling pool through the host machine's cooperative scheduler.
[0041] Furthermore, S101 may specifically include: using the virtual machine's dynamic circular queue management module to monitor the main virtual circular queue utilization and input / output request queuing status in real time to obtain monitoring information, and using historical data from a sliding time window combined with a load prediction algorithm to predict the input / output load trend within a preset future time period to obtain prediction information; when the monitoring information and prediction information reach the warning conditions, the monitoring frequency and prediction frequency are increased, and a background memory pre-allocation operation is performed; when the monitoring information and prediction information reach the conditions for regular expansion / shrinkage, a regular expansion / shrinkage request is triggered; the magnitude of regular expansion / shrinkage is calculated and determined based on the current load status and a preset strategy; when the monitoring information and prediction information reach the conditions for emergency expansion / shrinkage, the highest priority emergency expansion / shrinkage request is triggered; expansion / shrinkage is performed using an aggressive expansion strategy.
[0042] This embodiment does not specifically limit the warning conditions, regular expansion / shrinkage conditions, and emergency expansion / shrinkage conditions; these can be limited according to the actual situation. It is understood that when the condition is a threshold condition, the warning threshold corresponding to the warning condition is less than the first adjustment threshold for regular expansion / shrinkage conditions, which is less than the second adjustment threshold for emergency expansion / shrinkage requests. This embodiment is a runtime dynamic VRing adjustment. During the operation of virtual devices (referring to virtual hard disks, virtual network cards, etc.), the virtual machine monitors the main VRing utilization and I / O request queuing in real time, and initiates a main VRing size adjustment request to the host machine through the VirtIO-PCI interface. The host machine completes the expansion or shrinkage without interrupting service. Specifically, this may include:
[0043] (1) Load monitoring: The virtual machine’s dynamic VRing management module can count the main VRing utilization (used ring queue slot count / total slot count) and request queue length (number of waiting requests that have not entered VRing) every 10ms. At the same time, load prediction is further introduced. Using historical data of sliding time window and combined with exponential smoothing method, the I / O load trend in the short term is predicted. The trend of the load rising rapidly and about to exceed 85% of the current VRing capacity is identified, rather than waiting until the queue is full.
[0044] (2) Adjustment Decision: To further refine the response and anti-oscillation stability control, this embodiment introduces a three-level threshold and hysteresis mechanism in the adjustment decision. Taking the expansion scenario as an example, the expansion warning threshold in the warning threshold is applied to the scenario where the main VRing utilization rate is greater than 60%. It does not immediately trigger adjustment, but enters the warning state, starts more intensive monitoring and short-term prediction, and may start pre-allocating a part of memory in the background (but not immediately mounting) to prepare for possible expansion and reduce the latency when the actual expansion occurs. The warning threshold assists the system in taking proactive measures to advance some of the preparation work in the detection-decision-execution link. The first expansion threshold in the first adjustment threshold is applied to the scenario where the main VRing utilization rate is greater than 80% and the predicted main VRing utilization rate is greater than 85%. When the first expansion threshold is reached, the regular expansion operation is triggered. The decision engine calculates the expansion range based on the current main VRing utilization rate, the predicted trend and the preset strategy (such as aggressive / conservative). For example, the new Vring = current Vring * (1 + (current utilization - first expansion threshold) / 20), which may result in a 25%-50% increase in capacity, followed by a seamless switching process. The first expansion threshold is the main adjustment point for typical business growth, balancing response speed and resource efficiency. The second expansion threshold in the second adjustment threshold is applied to scenarios with utilization greater than 95%, handling sudden, explosive traffic surges and minimizing packet loss or congestion. This expansion requires the highest priority adjustment, and the strategy may be aggressive, such as doubling the capacity or expanding to the preset maximum allowable value, ensuring service maintenance even in the most extreme cases and achieving a design that enhances system reliability. The core idea of the hysteresis mechanism is to maintain a sufficiently large buffer area between the threshold that triggers expansion and the threshold that triggers shrinkage, preventing the main Vring from frequently switching between expansion and shrinkage states. The hysteresis mechanism is crucial in scenarios where the main Vring is dynamically adjusted because I / O load is inherently volatile. For example, the system starts in a stable state with a fixed VRing size. When the load increases and the utilization exceeds H_high (80%), the system leaves the stable state, triggers expansion, and enters the expansion state. After expansion, the system returns to the stable state. However, even if the utilization immediately drops to 81%, 70%, or even 50%, as long as it does not fall below H_low (30%), no shrinkage operation will be triggered. Only when the load remains low and the utilization falls below H_low (30%) will the system trigger shrinkage and enter the shrinkage state. After shrinkage, it returns to the stable state. At this point, even if the utilization briefly rebounds to 35%, as long as it does not exceed H_high (80%), it will not expand again.Compared to preset QoS (the length of the configuration interface priority queue) and relatively simple thresholds of preset algorithms, the hysteresis mechanism can effectively combat I / O jitter, avoid the performance loss caused by frequent memory allocation / release (frequent processing of a large number of small allocation and release requests by the memory management subsystem will lead to system performance degradation), data migration, and atomic switching operations that consume CPU and memory bandwidth. At the same time, it avoids frequent adjustments (although the adjustment process is designed to be imperceptible, it may still introduce small latency fluctuations) that amplify performance jitter and cause business instability.
[0045] S102: When the host receives an adjustment request from the virtual machine, it creates and initializes a virtual circular shadow queue with the same size as the target capacity, captures the state of the main virtual circular queue based on snapshot technology, migrates the in-process input / output requests and descriptors in the main virtual circular queue to the virtual circular shadow queue, and updates the index of the active circular queue in the system according to the virtual circular shadow queue.
[0046] In this embodiment, the host machine implements uninterrupted adjustment. Specifically, when the host machine receives an adjustment request, it creates a new temporary VRing of a new size (i.e., a new VRing, a virtual circular shadow queue), migrates the in-process input / output requests and descriptors of the main VRing to the new VRing, and notifies the virtual machine to switch to the new VRing via the PCI register. After a successful switch, the old VRing releases its memory.
[0047] Furthermore, S102 may specifically include: when the host receives an adjustment request from the virtual machine, determining the target capacity based on the adjustment request, allocating memory space of the corresponding capacity and initializing a virtual ring shadow queue, and recording the virtual ring shadow queue control block data structure; inserting a read memory barrier instruction into the main virtual ring queue, atomically reading the key index value of the main virtual ring queue to generate a consistent snapshot; the key index value includes the available ring write index and the used ring write index; identifying in-process input / output requests based on the consistent snapshot, migrating the in-process input / output requests and descriptors to the virtual ring shadow queue, and synchronizing the key index value of the main virtual ring queue to the virtual ring shadow queue; creating a control block containing the metadata of the main virtual ring queue, using a double buffering mechanism and version number management to perform an atomic switching operation, updating the index of the active ring queue in the system to the virtual ring shadow queue; the metadata includes the descriptor table, available ring base address, used ring base address, and the capacity of the virtual ring shadow queue; verifying the availability switching result of the virtual ring shadow queue, and releasing the memory resources occupied by the main virtual ring queue after the virtual ring shadow queue verification is successful.
[0048] This embodiment achieves dynamic expansion / shrinkage of the virtual circular queue without interrupting ongoing I / O operations through three core stages: shadow queue creation, precise state capture, and atomic metadata switching. Specifically, it includes:
[0049] Phase 1: Shadow Queue Creation. Determine the target capacity based on the adjustment request, and then allocate and initialize memory, including the descriptor table area, the used ring area, and the available ring area. Record the virtual ring shadow queue control block data structure: (1) Descriptor table base address field: points to the starting address of the descriptor array; (2) Available ring base address field: points to the starting address of the available descriptor ring; (3) Used ring base address field: points to the starting address of the processed descriptor ring; (4) Queue size field: records the current queue capacity (number of descriptors); (5) Status flag field: indicates the current queue status (normal, in migration, abnormal, etc.).
[0050] Phase 2: Precise State Capture. First, a consistent snapshot is created. Specifically, a read memory barrier instruction is inserted to ensure all CPU cache updates are complete. Then, the following key index values are atomically read: the available ring write index (avail_idx), which is the total number of requests submitted by the driver; the used ring write index (used_idx), which is the total number of requests processed by the device; and the number of requests in progress, i.e., avail_idx - used_idx. Finally, another read memory barrier instruction is inserted to ensure data consistency. Next, in-process requests are identified. Specifically, based on the acquired snapshot data, all requests in the processing state are identified: starting from the used_idx position, the available ring is traversed up to the avail_idx-1 position. For each position, its stored descriptor index is obtained, and the descriptor's status flag is checked to determine if it is the start of a descriptor chain. For the identified in-process requests, migration operations are performed. Finally, descriptor migration is performed. For a single descriptor request, a free descriptor entry is allocated in the descriptor table of the virtual circular shadow queue. All fields of the original descriptor (memory address, data length, flags) are copied. The corresponding new descriptor index is set at the same relative position in the available ring of the virtual circular shadow queue, and the correspondence between the original index and the new index is recorded in the mapping table. For descriptor chain requests (requests involving multiple descriptor links), the entire descriptor chain is traversed, all descriptors in the chain are identified, and each descriptor in the chain is assigned a continuous or discrete position in the virtual circular shadow queue, maintaining the linking relationship between descriptors and ensuring that the starting descriptor of the chain is in the correct position in the available ring of the virtual circular shadow queue. Finally, index synchronization is performed. The index values of the main virtual circular queue are copied to the virtual circular shadow queue: the write index value of the available ring of the virtual circular shadow queue is set to equal the available_idx in the snapshot, and the write index value of the used ring of the virtual circular shadow queue is set to equal the used_idx in the snapshot, ensuring that all data has been written to memory and passed the write barrier. Design a migration context management structure to track the complete state of the expansion process, including: old and new VRing pointers: pointing to the main virtual circular queue and the newly allocated shadow queue, respectively; migration stage flag: an atomic variable that identifies the current migration stage; state snapshot data: a snapshot of the key index values recorded at the start of the migration; and a descriptor mapping table: establishing a mapping relationship between the original descriptor index and the virtual circular shadow queue index.
[0051] Phase 3: Atomic Metadata Switching. First, a control block structure containing the metadata of the virtual circular shadow queue is created. The base address of the descriptor table, the available ring base address, and the used ring base address are set to their addresses in the new VRing. The size of the virtual circular shadow queue is updated to the new capacity value. Next, an atomic switch operation is performed. A version number field is added to the control block, incrementing with each switch. A double-buffering mechanism is used to maintain two queue metadata datasets. The active buffer index is atomically updated to point to the virtual circular shadow queue. The version number is atomically incremented to indicate switch completion. Finally, switch verification is performed. The migration status flag is updated to "completed," and optionally, a lightweight notification signal is sent to the device to verify that the virtual circular shadow queue is functioning correctly.
[0052] S103: Monitor virtual devices through the host machine. When multiple virtual devices request memory at the same time, determine the scheduling priority and resource requirements of each virtual device based on the resource usage, request queue length, device type and request dependency graph of each virtual device, and dynamically allocate resources to each virtual device according to the scheduling priority and resource requirements.
[0053] This embodiment does not limit the execution order of step S103. For example, S103 can be executed synchronously with steps S101 and S102. It should be noted that in this embodiment, the request dependency graph is constructed by parsing the request data from the virtual device front-end driver and identifying the causal relationship between input and output requests based on the request data. This step refers to multi-device collaborative scheduling. The host machine's collaborative scheduler dynamically allocates CPU and memory resources to each virtual device according to scheduling priority and resource requirements, avoiding contention among multiple devices. For example, resource requirement monitoring: the host side can collect the resource usage (such as CPU usage, VRing usage) and request queue length of each device every 20ms; scheduling priority: allocate more CPU time slices to high-priority devices (e.g., high priority 60%, medium 30%, low 10%). The request dependency graph solves the pain point of conventional priority scheduling's biased decision-making, that is, allocating resources only based on static priority without considering the temporal correlation of device I / O requests (e.g., when a data packet received by the network card needs to be written to the disk, there is a strong dependency between the two), leading to priority inversion (low-priority disk requests blocking high-priority network requests).
[0054] Furthermore, S103 may specifically include: collecting the resource usage and request queue length of each virtual device in real time through the host machine's coordinator, and determining the resource stress level; identifying the causal relationship between requests by parsing the virtual device request metadata, forming a request chain; pre-setting basic priorities according to the device type of the virtual devices, and performing dependency correction and load correction on the respective basic priorities based on the causal relationship of the request chain and the request queue length, dynamically adjusting the priority of each virtual device; when multiple virtual devices request memory resources simultaneously, determining the scheduling priority of each virtual device according to the priority of the virtual devices and the resource stress level; dynamically allocating resources to each virtual device based on the scheduling priority and resource requirements; resource requirements include resource usage and request queue length.
[0055] This embodiment enables request chain-aware dynamic priority scheduling and constructs a request dependency graph: by parsing the request metadata of the virtual device front-end driver (such as the ioprio field in virtio_blk_outhdr of block device requests and the TCP stream identifier of network devices), it identifies the causal relationships between requests (such as network card reception -> protocol stack parsing -> disk persistence) to form a request chain. Furthermore, it implements a dynamic priority correction algorithm. First, a basic priority is preset according to device type (such as real-time communication network card P1, database disk P2, and general storage P3). Second, dependency correction is implemented: based on the request chain, if a low-priority device request is a prerequisite for a high-priority request (such as disk write being a prerequisite for network response), the low-priority request's priority is temporarily raised to the same level as the high-priority request. Finally, load correction is implemented: by using a sliding window to count the length of the virtqueue's request queue, when the queue length exceeds a threshold (such as 80% capacity), the priority is temporarily increased by one level to avoid buffer overflow. When multiple virtual devices request memory simultaneously (such as VRing expansion), priority is given to virtual devices with a higher request queue length / current resource ratio (higher resource stress) and higher priority. Finally, the virtual machine reports the device load changes (such as a surge in network requests) to the host through the VirtIO configuration space. The host can also dynamically adjust the priority weights.
[0056] Furthermore, it may also include: collecting indicator values corresponding to lightweight indicators through the virtual machine's status monitoring module; lightweight indicators include queue pressure index, request processing latency index, and system load coefficient; determining the interrupt handling method based on the indicator values and a preset interrupt suppression dynamic algorithm; the preset interrupt suppression dynamic algorithm is any one of the following: weighted interrupt suppression dynamic algorithm, interval interrupt suppression dynamic algorithm, PID interrupt suppression dynamic algorithm, and differential interrupt suppression dynamic algorithm.
[0057] This embodiment dynamically adjusts the interruption suppression strategy based on VRing usage status and host processing capacity to reduce unnecessary interruption notifications. Interruption suppression condition judgment: The virtual machine can calculate the request processing latency (the difference between the current time and the time the request is placed in VRing) every 5ms. If the latency is <100μs (host processing speed is fast) and VRing utilization is <50% (circular queue buffer is sufficient), then VRING_AVAIL_F_NO_INTERRUPT (suppress interruption) is set, reducing notifications by batching requests. Interruption recovery trigger: If the latency is ≥100μs (host processing speed is slow) or VRing utilization is ≥80% (circular queue buffer is tight), the suppression flag is cleared, interruption notifications are restored, and request backlog is avoided. When the host detects the suppression flag, it triggers an interruption again after processing each batch of requests (e.g., 16) or after waiting 1ms, balancing batch processing and timeliness. This innovation is supported by a dynamic interruption suppression threshold, multi-dimensional status feedback, and a lightweight adjustment algorithm. The core of the preset dynamic interruption suppression algorithm in this embodiment lies in dynamically adjusting the interruption suppression threshold, mainly by calculating the interruption suppression threshold point in real time based on the VRing status. Three lightweight monitoring metrics are introduced through the virtual machine's status monitoring module: Queue Pressure Index (QPI), which is calculated as (current number of descriptors in use / VRing capacity * 100%) + utilization trend coefficient, where the trend coefficient is calculated based on the linear regression slope of the past N sampling points; Request Processing Latency Index (LDI), which is the current average latency / baseline latency, where the average latency is the average request processing time within the sliding window, and the baseline latency is the minimum latency measured during system initialization; and System Load Factor (SLC), corresponding to min(1.0, CPU utilization / 80%), normalized to [0, 1]. The following is an exemplary description of the preset interrupt suppression dynamic algorithm:
[0058] (1) Weighted interrupt suppression dynamic algorithm: Interrupt suppression threshold = base threshold * (1 + α * QPI_factor + β * LDI_factor - γ * SLC_factor). Wherein, the base threshold is the initial value related to the device type, QPI_factor is (QPI - QPI baseline) / QPI baseline, LDI_factor is (LDI - 1.0) / LDI baseline, SLC_factor is SLC, and α, β, and γ are adjustment coefficients (values range from 0.1 to 0.3). Based on the above algorithm, the interrupt suppression threshold is increased under high queue pressure (high QPI) to reduce interrupt frequency; the interrupt suppression threshold is increased under high processing latency (high LDI) to reduce interrupt overhead; and the interrupt suppression threshold is decreased under high system load (high SLC) to improve responsiveness.
[0059] (2) Interval interruption suppression dynamic algorithm introduces three dynamic threshold adjustment modes, which are dynamically switched according to the system state. Refer to Table 1. If (QPI>70% and lasts for T1 time) switch to response priority mode; if (LDI>2.0 and lasts for T2 time) switch to response priority mode; if (QPI<30% and LDI<1.5 and lasts for T3 time) switch to performance priority mode; otherwise, maintain the balance mode.
[0060] Table 1. Example Table of Interval Interruption Suppression Dynamic Algorithm
[0061]
[0062] (3) A lightweight PID (proportional-integral-derivative) interrupt suppression dynamic algorithm is adopted, as follows: New interrupt suppression threshold = Current interrupt suppression threshold + Kp * (target QPI - actual QPI). Where Kp = 0.5, target QPI = 50%; Algorithm constraints: a. New interrupt suppression threshold ∈ [minimum interrupt suppression threshold, maximum interrupt suppression threshold]; minimum value 2 (interruption at least once every 2 requests), maximum value 32 (interruption at most once every 32 requests); b. |ΔT| <= maximum adjustment step size; c. Interval between two adjustments >= minimum adjustment interval.
[0063] (4) The differential interruption suppression dynamic algorithm introduces a burst traffic identification and special processing mechanism: if ΔQPI / Δt>burst threshold and the current QPI>50%, it is judged as burst traffic. The processing strategy is divided into two steps: a. Immediate response stage, that is, temporarily cancel interruption suppression to ensure rapid response; b. Stable processing stage, after the burst ends, interruption suppression is gradually restored (the interruption suppression threshold is increased by the growth coefficient every Δt time until the interruption suppression threshold exceeds the interruption suppression threshold before the burst traffic * the recovery coefficient).
[0064] Furthermore, it can also include: employing a multi-level verification mechanism throughout the entire process of interaction between the virtual machine and the host machine; the multi-level verification mechanism includes data buffer-level verification, descriptor chain-level verification, and transaction-level verification; monitoring the response status of virtual devices through the host machine, monitoring the update status of the virtual circular shadow queue through the virtual machine, and using time series analysis to predict anomalies in conjunction with load and interruption-related monitoring indicators; when an error occurs during verification or an anomaly is detected / predicted, the virtual machine notifies the host machine to trigger a failover, copying unprocessed input / output requests to the standby virtual circular queue, and switching to the standby virtual circular queue through the virtual machine to continue running; the failover adopts a circular queue method based on hot backup or achieves seamless switching of active queues through atomic operations.
[0065] This embodiment introduces a multi-layered verification mechanism, allowing verification to be added at different levels. For example, data buffer-level verification calculates CRC32 (a 32-bit algorithm for cyclic redundancy check) for each data buffer and stores it in a reserved field of the descriptor; descriptor chain-level verification calculates a global hash (e.g., xxHash) for the entire descriptor chain (including all descriptors and data buffers) and stores it in the last descriptor in the chain; transaction-level verification calculates a transaction ID (identifier) and checksum for a complete I / O request (including request and response) to ensure end-to-end data integrity. Furthermore, to address the potential performance burden caused by these multi-layered verifications, an adaptive verification strategy and a hardware-assisted memory error detection and correction mechanism are introduced. Specifically, the verification strength is dynamically adjusted based on system load and error rate: under low load, a stronger verification algorithm (e.g., CRC64 or SHA1) is used; under high load, a lighter verification algorithm (e.g., CRC16 or simple XOR) is used; and when an increase in the error rate is detected, the verification strength is automatically increased. Memory protection techniques are utilized, such as hardware ECC (Elliptic Curve Cryptography) to correct single-bit errors. Simultaneously, the host machine can check device responsiveness every 10ms (e.g., whether it can read the PCI configuration space), and the virtual machine can monitor whether updates to the used circular queue in the virtual circular shadow queue time out (failure to update for a certain time threshold is considered abnormal). Furthermore, time-series-based anomaly detection is introduced, combined with the aforementioned dynamic adjustment of VRing function load monitoring and adaptive interrupt control monitoring. By monitoring the request submission rate, processing latency, and queue depth metrics of new VRing, a time-series analysis method based on exponential smoothing is used to predict normal behavior; when actual values exceed normal thresholds, anomalies are triggered. Additionally, an optimized heartbeat mechanism can be introduced, dynamically adjusting the heartbeat interval and timeout threshold: when the system is stable, the heartbeat interval is extended (e.g., from 10ms to 100ms) to reduce monitoring overhead; when the system fluctuates, the heartbeat interval is shortened to improve detection sensitivity. Adaptive timeouts are used, dynamically calculating the timeout threshold based on historical response times, rather than a fixed time. If a checksum error or an abnormal state occurs, the virtual machine notifies the host machine via the VirtIO-PCI interface to trigger a failover: the host machine copies unprocessed requests to a standby VRing, the virtual machine switches to the standby VRing to continue running, and the host machine resets the primary VRing (i.e., the new VRing). Failover technology initially supports hot backup VRing, maintaining a hot backup VRing that is synchronized in real-time with the primary VRing (through copy-on-write or log copying). This eliminates the need to copy unprocessed requests during failover; the pointer is switched directly.Secondly, it supports seamless failover technology, using atomic operations to switch VRing pointers, ensuring no requests are lost or inconsistent states arise during the switchover process. Specific steps include pausing new request submissions (a brief window), atomically switching the currently active VRing pointer from the primary VRing to the backup VRing, and resuming request submissions. Thirdly, regarding request handling during failover, for requests already submitted to the primary VRing but not yet processed, there are two handling methods: if the request has been submitted to the device but not yet acknowledged, it is resubmitted to the backup VRing; if the request has been processed but not yet returned to the driver, it waits for processing to complete before switching.
[0066] Furthermore, when the virtual machine submits an I / O request, it adds an empty data identifier to status query requests that do not involve actual data transmission. Once the host machine recognizes the empty data identifier, it skips the data buffer verification of the virtual circular queue and the full hash verification of the descriptor chain for the corresponding empty data request, and directly executes the status query and returns the result. This embodiment distinguishes requests without actual data through a simple identifier, simplifying the verification process for such requests and avoiding unnecessary resource consumption. On the one hand, empty data requests such as status queries do not need to execute a complete verification process, significantly shortening the processing chain for these requests and improving their response speed. On the other hand, it reduces meaningless verification calculation overhead, saving host machine CPU resources, while not affecting the integrity verification of requests with actual data. Under the premise of ensuring data security, it further optimizes the resource utilization efficiency of virtualized input / output scenarios.
[0067] Furthermore, it may also include: when a verification error occurs or an anomaly is detected / predicted, the virtual machine notifies the host machine to trigger a failover, copies unprocessed input / output requests to a standby virtual circular queue, and after the virtual machine switches to the standby virtual circular queue to continue running, the host machine resets the virtual circular shadow queue; when the virtual circular shadow queue is repaired, the host machine synchronizes the unprocessed requests in the standby virtual circular queue to the virtual circular shadow queue, so that the virtual machine switches back to running in the virtual circular shadow queue, and the standby virtual circular queue returns to a standby state; if the virtual circular shadow queue cannot be repaired within a preset time, the input / output service is maintained through the standby virtual circular queue.
[0068] This embodiment requires migration and repair operations after triggering failover. After the primary VRing is repaired, the host machine synchronizes unprocessed requests from the backup VRing back to the primary VRing, the virtual machine switches back to the primary VRing, and the backup VRing re-enters standby mode. This part first implements the repair of the primary VRing, that is, after the primary VRing fails, online repair is performed. If it is a software error (such as a descriptor chain linking error), the descriptor chain is reinitialized. If it is a memory error, an attempt is made to correct it using ECC. If correction fails, the faulty memory page is isolated, and VRing memory is reallocated. Secondly, data consistency is guaranteed. Before switching back to the primary VRing, it is ensured that all unprocessed requests in the backup VRing have been synchronized back to the primary VRing and that their states are consistent. Thirdly, a degraded operation mode can be implemented. When the primary VRing fails and cannot be quickly repaired, degraded operation can be performed. Service continues using the backup VRing, but performance may be lower (e.g., the backup VRing capacity is smaller). Some non-critical functions are disabled to ensure basic service availability.
[0069] The virtualization input / output optimization method provided in this embodiment of the invention proceeds as follows: S101: The virtual machine monitors the status of the main virtual circular queue to obtain status information. Based on the status information, a three-level judgment condition, and a hysteresis mechanism, an adjustment strategy is generated, and an adjustment request is sent to the host machine based on the adjustment strategy. The three-level judgment condition includes early warning conditions, regular expansion / shrinkage conditions, and emergency expansion / shrinkage conditions. The hysteresis mechanism sets a buffer area between triggering regular expansion and regular shrinkage conditions. S102: When the host machine receives the adjustment request from the virtual machine, it creates and initializes a virtual circular shadow queue with the same size as the target capacity, and captures the main virtual circular queue using snapshot technology. In the first state, ongoing input / output requests and descriptors in the main virtual circular queue are migrated to the virtual circular shadow queue, and the index of the active circular queue in the system is updated according to the virtual circular shadow queue; S103: The virtual devices are monitored by the host machine. When multiple virtual devices request memory at the same time, the scheduling priority and resource requirements of each virtual device are determined based on the resource usage, request queue length, device type and request dependency graph of each virtual device. Resources are dynamically allocated to each virtual device according to the scheduling priority and resource requirements; The request dependency graph is constructed by parsing the request data of the virtual device front-end driver and identifying the causal relationship between input and output requests based on the request data. This invention, through the collaborative interaction between the virtual machine and the host machine, on the one hand, uses a three-level judgment condition and hysteresis mechanism to accurately generate adjustment strategies for the virtual circular queue, effectively avoiding system fluctuations caused by frequent queue expansion / shrinkage. Combined with snapshot migration technology, it achieves complete handling of ongoing requests during queue switching, ensuring the continuity of input and output services. On the other hand, by integrating multi-dimensional information such as virtual device resource usage and request queue length on the host machine, and combining request dependency graphs to identify causal relationships between requests to optimize scheduling priorities, this invention not only solves the problem of multi-device resource contention but also avoids the risk of priority inversion caused by conventional scheduling ignoring request dependencies. It achieves accurate and dynamic allocation of resources, ultimately significantly improving system stability, resource utilization, and overall I / O processing efficiency in virtualized input / output scenarios.Furthermore, dynamic VRing adjustments increase I / O throughput by 30%-50% under varying loads (avoiding blocking due to insufficient buffers) while reducing memory usage by 20%-30% (reducing size under low load); adaptive interrupt suppression reduces interrupt counts by 40%-60%, lowers context switching overhead between host and virtual machines, and reduces CPU utilization by 15%-25%; multi-device collaborative scheduling avoids resource contention, reduces I / O response latency for high-priority devices by 20%-40%, and improves overall resource utilization by 15%-20%; fault detection and switching streamline I / O... Interruption time is reduced from seconds to milliseconds (average switching time <10ms), and the error data processing rate is reduced to 0 (through checksum and interception), significantly shortening fault interruption time; multi-device collaborative scheduling is extended to mixed scenarios of VirtIO and physical PCI devices (such as VirtIO network cards in virtual machines and physical network cards of the host), improving overall I / O efficiency through unified scheduling; in multi-virtual machine scenarios, the host machine scheduler integrates the VirtIO device requirements of all virtual machines to achieve global resource optimization (such as avoiding multiple virtual machine network cards from simultaneously preempting physical network card resources).
[0070] To better understand this solution, Figure 2 This invention provides a virtualized I / O interaction flowchart based on Vring, which revolves around Vring's state monitoring, dynamic adjustment, and interrupt control.
[0071] The virtual machine performs two types of status monitoring on Vring: Vring utilization monitoring and processing latency monitoring. Based on the monitoring results of Vring utilization, the virtual machine generates expansion / shrinkage requests and sends them to the host machine. Based on the monitoring results of Vring utilization and processing latency, the virtual machine adjusts the interrupt suppression flag and synchronizes it with the host machine.
[0072] Host machine response: When receiving a virtual machine expansion / shrinkage request, it executes the creation of a new Vring (i.e., virtual circular shadow queue) to complete the dynamic adjustment of the Vring; combined with the virtual machine's interrupt suppression flag, it executes batch processing requests and finally triggers the interrupt triggering stage to complete the feedback of the request.
[0073] Collaborative dynamic adjustment: There is also a dynamic Vring (size changes with load) interaction between the virtual machine and the host machine. That is, the two parties coordinate to adjust the size of the Vring based on the load, so as to achieve elastic adaptation of resources.
[0074] Figure 3 A flowchart illustrating resource scheduling and VRing fault tolerance interaction is provided in this embodiment of the invention, and is described in detail below:
[0075] The host continuously performs two types of monitoring: first, resource usage monitoring, which performs priority scheduling based on the monitoring results (matching resources to high-priority devices on the virtual machine side); second, fault monitoring, which triggers a primary / standby VRing failover if an anomaly is detected. Simultaneously, the host allocates resources (CPU / memory) to the virtual machine to provide operational support.
[0076] Virtual machine response: High-priority virtual devices receive priority scheduling and resource allocation from the host machine; when the host machine triggers a primary / standby VRing failure switch, the virtual machine sends a switch notification to cooperate with the host machine to complete the switch, ultimately enabling continued operation and ensuring uninterrupted service.
[0077] The entire process embodies a collaborative model where the host actively manages resources and monitors for faults, while the virtual machine responds accordingly. This achieves precise resource scheduling and ensures the continuity of virtualized I / O through primary / standby VRing switching. In this embodiment, multi-device resource scheduling is limited to the coordinated allocation of CPU resources among multiple virtual devices within the same virtual machine based on weights, with the VirtIO driver within the virtual machine coordinating the resource allocation. If the allocation involves coordinating resource allocation between the virtual machine and other virtual machines on the host, or with I / O devices on the host, then the coordinator component must be transferred to the host. The VirtIO driver within the virtual machine and the kernel (host's) general block device driver need to act as auxiliary roles, coordinating with the coordinator.
[0078] The virtualized input / output optimization device provided in the embodiments of the present invention will be described below. The virtualized input / output optimization device described below can be referred to in correspondence with the virtualized input / output optimization method described above.
[0079] Please refer to the details. Figure 4 , Figure 4 A schematic diagram of a virtualized input / output optimization device provided in an embodiment of the present invention may include:
[0080] The monitoring and decision-making module 100 is used to obtain status information by monitoring the status of the main virtual circular queue through the virtual machine, generate an adjustment strategy based on the status information, as well as three-level judgment conditions and a hysteresis mechanism, and send an adjustment request to the host machine based on the adjustment strategy; the three-level judgment conditions include early warning conditions, normal expansion / shrinkage conditions, and emergency expansion / shrinkage conditions; the hysteresis mechanism is to set a buffer area between triggering normal expansion conditions and normal shrinkage conditions;
[0081] A migration synchronization module 200 is created to create and initialize a virtual ring shadow queue with the same size as the target capacity when the host machine receives an adjustment request sent by the virtual machine. The module captures the state of the main virtual ring queue based on snapshot technology, migrates the in-process input / output requests and descriptors in the main virtual ring queue to the virtual ring shadow queue, and updates the index of the active ring queue in the system according to the virtual ring shadow queue.
[0082] The multi-device collaboration module 300 is used to monitor virtual devices through the host machine. When multiple virtual devices request memory simultaneously, it determines the scheduling priority and resource requirements of each virtual device based on the resource usage, request queue length, device type, and request dependency graph of each virtual device, and dynamically allocates resources to each virtual device according to the scheduling priority and resource requirements. The request dependency graph is constructed by parsing the request data of the virtual device front-end driver and identifying the causal relationship between input and output requests based on the request data.
[0083] Based on the above embodiments, the monitoring decision module 100 may include:
[0084] The monitoring and prediction unit is used to monitor the utilization rate of the main virtual circular queue and the queuing status of input and output requests in real time using the dynamic circular queue management module of the virtual machine to obtain monitoring information, and to predict the input and output load trend within a preset time period based on historical data of the sliding time window and the load prediction algorithm to obtain prediction information.
[0085] The first result unit is used to increase the monitoring frequency and the prediction frequency and perform a background memory pre-allocation operation when the monitoring information and the prediction information reach the warning condition.
[0086] The second result unit is used to trigger a regular expansion / shrinkage request when the monitoring information and the prediction information reach the regular expansion / shrinkage conditions; the magnitude of the regular expansion / shrinkage is calculated and determined based on the current load status and a preset strategy.
[0087] The third result unit is used to trigger the highest priority emergency expansion / shrinkage request when the monitoring information and the prediction information reach the emergency expansion / shrinkage conditions; the expansion / shrinkage is performed using an aggressive expansion strategy.
[0088] Based on the above embodiments, the creation of the migration synchronization module 200 may include:
[0089] An initialization creation unit is used to determine the target capacity size according to the adjustment request when the host machine receives the adjustment request sent by the virtual machine, allocate memory space of the corresponding capacity and initialize the virtual circular shadow queue, and record the virtual circular shadow queue control block data structure.
[0090] The status acquisition unit is used to insert a read memory barrier instruction into the main virtual circular queue and atomically read the key index value of the main virtual circular queue to generate a consistent snapshot; the key index value includes the available ring write index and the used ring write index.
[0091] The migration synchronization unit is used to identify the in-process input / output request based on the consistency snapshot, migrate the in-process input / output request and descriptor to the virtual circular shadow queue, and synchronize the key index value of the main virtual circular queue to the virtual circular shadow queue.
[0092] The index update unit is used to create a control block containing the metadata of the main virtual ring queue. It uses a double buffering mechanism and version number management to perform an atomic switching operation to update the index of the active ring queue in the system to the virtual ring shadow queue. The metadata includes a descriptor table, available ring base addresses, used ring base addresses, and the capacity of the virtual ring shadow queue.
[0093] The verification unit is used to verify the availability switching result of the virtual ring shadow queue. When the virtual ring shadow queue is verified, the memory resources occupied by the main virtual ring queue are released.
[0094] Based on the above embodiments, the multi-device collaboration module 300 may include:
[0095] The resource stress determination unit is used to collect the resource usage and request queue length of each virtual device in real time through the host machine's cooperative scheduler, and determine the resource stress level.
[0096] The request chain generation unit is used to identify the causal relationship between requests by parsing the virtual device request metadata and to form a request chain.
[0097] The priority correction unit is used to preset a basic priority according to the device type of the virtual device, and perform dependency correction and load correction on the basic priority based on the causal relationship of the request chain and the length of the request queue, so as to dynamically adjust the priority of each virtual device.
[0098] A priority determination unit is used to determine the scheduling priority of each virtual device based on the priority of the virtual devices and the resource scarcity level when multiple virtual devices request memory resources simultaneously.
[0099] The resource allocation unit is used to dynamically allocate resources to each virtual device based on the scheduling priority and the resource requirements; the resource requirements include the resource usage status and the request queue length.
[0100] Based on the above embodiments, the virtualization input / output optimization device may further include:
[0101] The indicator value monitoring and acquisition module is used to collect indicator values corresponding to lightweight indicators through the virtual machine's status monitoring module; the lightweight indicators include queue pressure index, request processing latency index, and system load coefficient;
[0102] The interrupt handling mode determination module is used to determine the interrupt handling mode based on the index value and the preset interrupt suppression dynamic algorithm; the preset interrupt suppression dynamic algorithm is any one of the weighted interrupt suppression dynamic algorithm, the interval interrupt suppression dynamic algorithm, the PID interrupt suppression dynamic algorithm and the differential interrupt suppression dynamic algorithm.
[0103] Based on the above embodiments, the virtualization input / output optimization device may further include:
[0104] A multi-level verification module is used to employ a multi-level verification mechanism throughout the entire process of interaction between the virtual machine and the host machine; the multi-level verification mechanism includes data buffer level verification, descriptor chain level verification, and transaction level verification.
[0105] The dual-end monitoring module is used to monitor the response status of the virtual device through the host machine, monitor the update status of the virtual circular shadow queue through the virtual machine, and combine load and interruption-related monitoring indicators to achieve anomaly prediction using time series analysis.
[0106] The failover module is used to notify the host machine through the virtual machine to trigger failover when an error occurs during verification or an anomaly is detected / predicted. Unprocessed input / output requests are copied to a standby virtual circular queue, and the virtual machine switches to the standby virtual circular queue to continue running. The failover adopts a circular queue method based on hot backup or achieves seamless switching of active queues through atomic operations.
[0107] Based on the above embodiments, the virtualization input / output optimization device may further include:
[0108] The reset module is used to notify the host machine to trigger a failover when an error occurs during verification or an anomaly is detected / predicted. It copies unprocessed input / output requests to a standby virtual circular queue, switches the virtual machine to the standby virtual circular queue to continue running, and then resets the virtual circular shadow queue through the host machine.
[0109] The switching module is used to synchronize unprocessed requests in the backup virtual ring queue to the virtual ring shadow queue through the host machine after the virtual ring shadow queue is repaired, so that the virtual machine switches back to the virtual ring shadow queue to run and the backup virtual ring queue is restored to the standby state.
[0110] The maintenance module is used to maintain input / output services through the backup virtual circular queue if the virtual circular shadow queue cannot be repaired within a preset time.
[0111] It should be noted that the order of the modules and units in the aforementioned virtualized input / output optimization device can be changed without affecting the logic.
[0112] The virtualization input / output optimization device provided in this embodiment of the invention uses a monitoring and decision-making module 100 to monitor the status of the main virtual circular queue through the virtual machine to obtain status information. Based on the status information, a three-level judgment condition, and a hysteresis mechanism, an adjustment strategy is generated, and an adjustment request is sent to the host machine based on the adjustment strategy. The three-level judgment condition includes an early warning condition, a regular expansion / shrinkage condition, and an emergency expansion / shrinkage condition. The hysteresis mechanism sets a buffer area between triggering the regular expansion condition and the regular shrinkage condition. A migration synchronization module 200 is used to create and initialize a virtual circular shadow queue with the same size as the target capacity when the host machine receives the adjustment request sent by the virtual machine, and capture the main virtual circular queue based on snapshot technology. The system migrates ongoing input / output requests and descriptors from the main virtual circular queue to the virtual circular shadow queue, and updates the index of the active circular queue in the system based on the virtual circular shadow queue. The multi-device collaboration module 300 monitors virtual devices through the host machine. When multiple virtual devices simultaneously request memory, it determines the scheduling priority and resource requirements of each virtual device based on their resource usage, request queue length, device type, and request dependency graph. It then dynamically allocates resources to each virtual device based on these scheduling priorities and resource requirements. The request dependency graph is constructed by parsing the request data from the virtual device front-end driver and identifying the causal relationships between input / output requests based on the request data. This device, through the collaborative operation of the virtual machine and the host machine, on the one hand, uses a three-level judgment condition and hysteresis mechanism to accurately generate adjustment strategies for the virtual circular queue, effectively avoiding system fluctuations caused by frequent queue expansion / shrinkage. Combined with snapshot migration technology, it can fully handle ongoing requests during queue switching, ensuring the continuity of input and output services. On the other hand, by integrating multi-dimensional information such as virtual device resource usage and request queue length on the host machine, and combining request dependency graphs to identify causal relationships between requests to optimize scheduling priorities, it not only solves the problem of multi-device resource contention, but also avoids the risk of priority inversion caused by conventional scheduling ignoring request dependencies, achieving accurate and dynamic allocation of resources. Ultimately, it significantly improves system stability, resource utilization, and overall I / O processing efficiency in virtualized input / output scenarios.
[0113] Figure 5 A schematic diagram of a virtualized input / output optimization device provided in an embodiment of the present invention is shown below. Figure 5As shown, the virtualized input / output optimization device includes: a memory 60 for storing computer programs; and a processor 61 for executing the computer program to implement the steps of the virtualized input / output optimization method as described in the above embodiment. The virtualized input / output optimization device provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers. The processor 61 may include one or more processing cores, such as a 4-core processor or an 8-core processor. The processor 61 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 61 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the wake-up state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 61 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content required to be displayed on the screen. In some embodiments, processor 61 may further include an Artificial Intelligence (AI) processor for processing computational operations related to machine learning. Memory 60 may include one or more computer-readable storage media, which may be non-transitory. Memory 60 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, memory 60 is used to store at least the following computer program 601, which, after being loaded and executed by processor 61, is capable of implementing the relevant steps of the virtualization input / output optimization method disclosed in any of the foregoing embodiments. Additionally, the resources stored in memory 60 may also include an operating system 602 and data 603, and the storage method may be temporary or permanent. Operating system 602 may include Windows, Unix, Linux, etc. Data 603 may include, but is not limited to, data related to the virtualization input / output optimization method. In some embodiments, the virtualization input / output optimization device may also include a display screen 62, an input / output interface 63, a communication interface 64, a power supply 65, and a communication bus 66. Those skilled in the art will understand that... Figure 5 Figure 5 The structure shown does not constitute a limitation on virtualized input / output optimization devices and may include more or fewer components than illustrated.
[0114] It is understood that if the virtualization input / output optimization method in the above embodiments is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the current technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, magnetic disks, or optical disks, and various other media capable of storing program code. Based on this, the embodiments of the present invention also provide a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the virtualization input / output optimization method described above.
[0115] The following describes a computer program product provided by an embodiment of this application. The computer program product described below can be referred to in conjunction with other embodiments described herein.
[0116] A computer program product includes a computer program / instructions that, when executed by a processor, implement the steps of the aforementioned disclosed virtualization input / output optimization method.
[0117] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0118] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0119] Finally, it should be noted that in this document, relationships such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0120] The present invention provides a detailed description of a virtualized input / output optimization method, apparatus, device, and computer-readable storage medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for virtualized input / output optimization, the method comprising: The method comprises the following steps: The state information is obtained by monitoring the state of the main virtual ring queue through the virtual machine, and an adjustment strategy is generated based on the state information, three-level judgment conditions and a hysteresis mechanism, and an adjustment request is sent to the host based on the adjustment strategy; the three-level judgment conditions include a pre-warning condition, a regular expansion / shrinkage condition and an emergency expansion / shrinkage condition; the hysteresis mechanism is to set a buffer area between triggering the regular expansion condition and the regular shrinkage condition; When the host receives the adjustment request sent by the virtual machine, a virtual ring shadow queue with a target capacity size is created and initialized, the state of the main virtual ring queue is captured based on snapshot technology, the input / output requests and descriptors in the main virtual ring queue are migrated to the virtual ring shadow queue, and the index of the active ring queue in the system is updated according to the virtual ring shadow queue. The virtual devices are monitored by the host, when multiple virtual devices simultaneously request memory, the scheduling priority and resource demand of each virtual device are determined based on the resource usage, request queue length, device type and request dependency graph of each virtual device, and resources are dynamically allocated to each virtual device according to the scheduling priority and resource demand; the request dependency graph is constructed based on the causal relationship between input / output requests identified according to the request data of the virtual device front-end driver.
2. The virtualized input / output optimization method of claim 1, wherein, The state information is obtained by monitoring the state of the main virtual ring queue through the virtual machine, and an adjustment strategy is generated based on the state information, three-level judgment conditions and a hysteresis mechanism, and an adjustment request is sent to the host based on the adjustment strategy, comprising: The usage rate of the main virtual ring queue and the input / output request queuing situation are monitored in real time by the dynamic ring queue management module of the virtual machine to obtain monitoring information, and the input / output load trend in a future preset time is predicted based on historical data of a sliding time window combined with a load prediction algorithm to obtain prediction information; When the monitoring information and the prediction information reach the pre-warning condition, the monitoring frequency and the prediction frequency are increased, and a background memory pre-allocation operation is performed; When the monitoring information and the prediction information reach the regular expansion / shrinkage condition, a regular expansion / shrinkage request is triggered; the amplitude of the regular expansion / shrinkage is determined based on the current load state and a preset strategy; When the monitoring information and the prediction information reach the emergency expansion / shrinkage condition, an emergency expansion / shrinkage request with the highest priority is triggered; the expansion / shrinkage adopts an aggressive expansion strategy to perform expansion.
3. The virtualized input / output optimization method of claim 1, wherein, When the host receives the adjustment request sent by the virtual machine, a virtual ring shadow queue with a target capacity size is created and initialized, the state of the main virtual ring queue is captured based on snapshot technology, the input / output requests and descriptors in the main virtual ring queue are migrated to the virtual ring shadow queue, and the index of the active ring queue in the system is updated according to the virtual ring shadow queue, comprising: When the host computer receives the adjustment request sent by the virtual machine, the target capacity size is determined according to the adjustment request, the memory space corresponding to the capacity is allocated, the virtual ring-shaped shadow queue is initialized, and the virtual ring-shaped shadow queue control block data structure is recorded; A read memory barrier instruction is inserted into the main virtual ring-shaped queue, and a consistent snapshot is generated by atomically reading the key index value of the main virtual ring-shaped queue; the key index value includes an available ring write index and a used ring write index; Based on the consistent snapshot, the in-process input / output request is identified, the in-process input / output request and the descriptor are migrated to the virtual ring-shaped shadow queue, and the key index value of the main virtual ring-shaped queue is synchronized to the virtual ring-shaped shadow queue; A control block containing the main virtual ring-shaped queue metadata is created, an atomic switching operation is performed using a double buffering mechanism combined with a version number management, and the index of the active ring-shaped queue in the system is updated to the virtual ring-shaped shadow queue; the metadata includes a descriptor table, an available ring base address, a used ring queue base address, and the capacity size of the virtual ring-shaped shadow queue; The availability switching result of the virtual ring-shaped shadow queue is verified, and when the virtual ring-shaped shadow queue passes the verification, the memory resources occupied by the main virtual ring-shaped queue are released.
4. The virtualized input / output optimization method of claim 1, wherein, The host computer monitors the virtual devices, determines the scheduling priority and resource demand of each virtual device based on the resource usage, request queue length, device type, and request dependency graph of each virtual device when multiple virtual devices simultaneously request memory, and dynamically allocates resources to each virtual device according to the scheduling priority and resource demand, including: The resource usage and request queue length of each virtual device are collected in real time by the cooperative scheduler of the host computer, and the resource tension degree is determined; The causal relationship between requests is identified by analyzing the virtual device request metadata, and a request chain is formed; The priority of each virtual device is dynamically adjusted based on the causal relationship of the request chain and the request queue length according to the preset basic priority of the device type of the virtual device; When multiple virtual devices simultaneously request memory resources, the scheduling priority of each virtual device is determined according to the priority of the virtual device and the resource tension degree; Based on the scheduling priority and the resource demand, resources are dynamically allocated to each virtual device; the resource demand includes the resource usage and the request queue length.
5. The virtualization I / O optimization method of claim 1, wherein, Further comprising: The state monitoring module of the virtual machine collects the index values corresponding to the lightweight indicators; the lightweight indicators include the queue pressure index, the request processing delay index, and the system load coefficient; The interrupt handling mode is determined based on the index values and the preset interrupt suppression dynamic algorithm; the preset interrupt suppression dynamic algorithm is any one of the weighted interrupt suppression dynamic algorithm, the interval interrupt suppression dynamic algorithm, the PID interrupt suppression dynamic algorithm, and the differential interrupt suppression dynamic algorithm.
6. The virtualization input / output optimization method of claim 1, wherein, Further comprising: A multi-level checking mechanism is adopted in the whole process of interaction between the virtual machine and the host computer; The multi-level checking mechanism includes data buffer level checking, descriptor chain level checking and transaction level checking; The response state of the virtual device is monitored by the host computer, the update state of the virtual ring shadow queue is monitored by the virtual machine, and combined with load and interrupt related monitoring indicators, time series analysis is used to realize abnormal prediction; When the checking error occurs or the abnormality is monitored / predicted, the host computer is notified by the virtual machine to trigger a fault switch, the unprocessed input / output requests are copied to the standby virtual ring queue, and the virtual machine is switched to the standby virtual ring queue to continue running; The fault switching adopts a ring queue method based on hot backup or realizes seamless switching of active queue through atomic operation.
7. The virtualized input / output optimization method of claim 6, wherein, After the virtual machine notifies the host computer to trigger a fault switch when the checking error occurs or the abnormality is monitored / predicted, the unprocessed input / output requests are copied to the standby virtual ring queue, and the virtual machine is switched to the standby virtual ring queue to continue running, it further includes: The virtual ring shadow queue is reset by the host computer; When the virtual ring shadow queue is repaired, the host computer synchronizes the unprocessed requests in the standby virtual ring queue to the virtual ring shadow queue, so that the virtual machine switches back to the virtual ring shadow queue to run, and the standby virtual ring queue recovers to standby state; If the virtual ring shadow queue cannot be repaired within a preset time, the input / output service is maintained through the standby virtual ring queue.
8. A virtualized input / output optimization apparatus, comprising: It includes: A monitoring decision module is configured to monitor the state of the main virtual ring queue by the virtual machine to obtain state information, generate an adjustment strategy based on the state information, three-level judgment conditions and hysteresis mechanism, and send an adjustment request to the host computer based on the adjustment strategy; The three-level judgment conditions include early warning conditions, regular expansion / shrinkage conditions and emergency expansion / shrinkage conditions; The hysteresis mechanism sets a buffer area between triggering regular expansion conditions and regular shrinkage conditions; A multi-device cooperation module is configured to create and initialize a virtual ring shadow queue consistent with the target capacity size when the host computer receives the adjustment request sent by the virtual machine, capture the state of the main virtual ring queue based on snapshot technology, migrate the ongoing input / output requests and descriptors in the main virtual ring queue to the virtual ring shadow queue, and update the index of the active ring queue in the system according to the virtual ring shadow queue. A multi-device coordination module is configured to monitor virtual devices by a host computer, determine scheduling priorities and resource requirements of the virtual devices based on resource usage, request queue length, device type and request dependency graph of each virtual device when multiple virtual devices simultaneously request memory, and dynamically allocate resources to the virtual devices according to the scheduling priorities and resource requirements.
9. A virtualized input-output optimization device, comprising: The method comprises: a memory configured to store a computer program; a processor configured to execute the computer program to implement the virtualized input / output optimization method according to any one of claims 1 to 7.
10. A computer readable storage medium characterized by, The computer readable storage medium stores computer executable instructions, and the computer executable instructions are loaded and executed by the processor to implement the virtualized input / output optimization method according to any one of claims 1 to 7.