A notification suppression method, apparatus, data processing unit, medium, and program product.
By reading the pointer update event of the virtual queue in the Virtio backend device, the request backlog is accurately quantified and the suppression state is updated, which solves the problem of low PCIe bus bandwidth utilization in hardware backend devices and achieves more efficient notification suppression and bandwidth utilization.
Patent Information
- Application Number
- CN202611369724.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-04
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2046-09-04
AI Technical Summary
Existing notification suppression schemes for the Virtio protocol have low PCIe bus bandwidth utilization in hardware-based backend device scenarios. This is because the suppression state switching relies on coarse judgment, leading to frequent DMA write operations, which consume bandwidth and reduce performance.
By responding to pointer update events in the virtual queue, the first, second, and third pointers are read to accurately quantify the request backlog and compare it with a preset threshold to determine the notification suppression status, update the suppression flag, and reduce unnecessary PCIe DMA write operations.
It improves PCIe bus bandwidth utilization, reduces invalid occupancy, enhances the accuracy and real-time performance of notification suppression, and reduces state switching frequency.
Smart Images

Figure CN122870753B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer network communication technology, specifically to a notification suppression method, apparatus, data processing unit, computer-readable storage medium, and computer program product. Background Technology
[0002] Virtio is a semi-virtualized I / O device virtualization standard widely used in cloud computing scenarios to provide virtual machines with networking, storage, and other functions. The implementation of Virtio devices is usually divided into two parts: front-end drivers and back-end devices. The front-end drivers run in the virtual machine (Guest), while the back-end devices run in the hypervisor (such as QEMU) or are offloaded to dedicated hardware such as smart network cards or DPUs (Data Processing Units).
[0003] In the Virtio protocol, the frontend driver informs the backend device of new requests (such as data packets to be sent) by sending notifications (also known as doorbells). To reduce the performance overhead caused by frequent notifications, the Virtio protocol provides a notification suppression mechanism.
[0004] Specifically, for Split type virtual queues, the flags field of the used ring table contains a NO_NOTIFY bit. When this NO_NOTIFY bit is set, the front-end driver stops sending notifications to the back-end device. For Packed type virtual queues, the flags value of the device event suppression register controls whether the front-end driver sends notifications to the back-end device.
[0005] However, existing notification suppression schemes in the Virtio protocol are primarily designed for software-based backend devices. In software implementations (such as QEMU-emulated PCI devices), notification suppression information (such as the aforementioned flags field and event suppression structure) is stored in Guest memory. Software backend devices can directly access this information, requiring only lightweight operations such as memory barriers to read and update the suppression status. Therefore, in software implementations, the overhead of setting or clearing notification suppression flags is low.
[0006] However, existing notification suppression schemes have drawbacks in hardware-based backend device scenarios. When the Virtio backend device is offloaded to hardware, it needs to initiate a DMA (Direct Memory Access) operation via the PCIe bus to update the suppression flag. Each switch in the suppression state requires a PCIe DMA write operation. If the suppression decision is not precise enough, and frequent switching of the suppression state is triggered based on rough judgments, it will generate a large number of DMA write operations, consuming PCIe bus bandwidth, which may outweigh the performance gains brought by notification suppression itself, leading to a decline in overall system performance. Summary of the Invention
[0007] This application provides a notification suppression method, apparatus, data processing unit, computer-readable storage medium, and computer program product to improve PCIe bus bandwidth utilization when backend devices are offloaded to dedicated hardware.
[0008] According to a first aspect, embodiments of this application provide a notification suppression method, the method being applied to a Virtio backend device, the method comprising:
[0009] In response to the detection of a pointer update event for any virtual queue, the first pointer, second pointer, and third pointer of the virtual queue are read from the pointer storage module of the backend device; wherein, the pointer update event refers to at least one of the first pointer update, the second pointer update, and the third pointer update, the first pointer indicates the descriptor position that the frontend driver has written to the virtual queue, the second pointer indicates the descriptor position that the backend device has read from the virtual queue, and the third pointer indicates that the backend device has completed and written back the descriptor position of the virtual queue; The request backlog of the virtual queue is determined based on the first pointer, the second pointer, and the third pointer; The request backlog is compared with a preset backlog threshold, and the notification suppression state of the virtual queue is determined based on the comparison result. The suppression flag of the virtual queue is updated according to the notification suppression status of the virtual queue; wherein the suppression flag is used to indicate whether the front-end driver sends a notification to the back-end device.
[0010] In one specific implementation, determining the request backlog of the virtual queue based on the first pointer, the second pointer, and the third pointer includes: When the first pointer is not null, the request backlog is the difference between the first pointer and the third pointer; when the first pointer is null, the request backlog is the difference between the second pointer and the third pointer.
[0011] In one specific implementation, comparing the request backlog with a preset backlog threshold and determining the notification suppression state of the virtual queue based on the comparison result includes: When the request backlog exceeds the first backlog threshold, the notification suppression state of the virtual queue is determined to be suppressed, instructing the front-end driver not to send notifications to the back-end device. When the request backlog is less than the second backlog threshold, the notification suppression state of the virtual queue is determined to be unsuppressed, and the front-end driver is instructed to send a notification to the back-end device. When the request backlog is greater than or equal to the second backlog threshold and less than or equal to the first backlog threshold, it is determined to maintain the current notification suppression state; Wherein, the first backlog threshold is greater than the second backlog threshold.
[0012] In one specific implementation, updating the suppression flag of the virtual queue according to the notification suppression state of the virtual queue includes: When it is determined that the notification suppression state of the virtual queue is suppressed or not suppressed, the current notification suppression state of the virtual queue is read from the suppression state storage module of the backend device. If the current notification suppression state is the same as the currently determined notification suppression state, the suppression flag of the virtual queue is not updated; otherwise, the suppression flag of the virtual queue is updated according to the currently determined notification suppression state. When the suppression flag is at a first preset value, the corresponding notification suppression state is non-suppression; when the suppression flag is at a second preset value, the corresponding notification suppression state is suppression.
[0013] In one specific implementation, the method further includes: Periodically poll each virtual queue; When any virtual queue is polled, the current notification suppression status of any virtual queue is read from the suppression status storage module of the backend device. If the current notification suppression status of any virtual queue is suppressed, its notification suppression status is updated to non-suppressed, and a preset time is waited. If no notification from the frontend driver is received after waiting for the preset time, the latest pointer information of any virtual queue is obtained from the host memory, and the first pointer of any virtual queue in the pointer storage module is updated according to the latest pointer information. The host memory is a shared physical memory space used for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side.
[0014] In one specific implementation, the method further includes: When the notification suppression status of any virtual queue is updated to non-suppressed, the timeout timestamp and validity flag of that virtual queue in the time storage unit of the backend device are respectively set to the current system time and the third preset value. The system periodically polls each virtual queue. When any virtual queue is polled, the system reads the timeout timestamp and valid flag of that virtual queue from the time storage unit of the backend device. If the valid flag of that virtual queue is a third preset value, the system obtains the time difference based on the timeout timestamp and the current system time. If the time difference is greater than a preset timeout threshold, a timeout is determined. The system then obtains the latest pointer information of that virtual queue from the host memory, updates the first pointer of that virtual queue in the pointer storage module based on the latest pointer information, and sets the valid flag of that virtual queue to a fourth preset value. Wherein, the host memory is the shared physical memory space for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side; the timeout timestamp records the time when the notification suppression state of the virtual queue is updated from suppressed to unsuppressed; when the valid flag bit is a third preset value, it indicates that the queue is in a timeout monitoring state; when the valid flag bit is a fourth preset value, it indicates that the queue is in a non-timeout monitoring state.
[0015] In one specific implementation, the method further includes: When a notification is received from any virtual queue, the valid flag bit of any virtual queue is read from the time storage unit of the backend device. If the valid flag bit of any virtual queue is a third preset value, the valid flag bit of any virtual queue is set to a fourth preset value; otherwise, the valid flag bit of any virtual queue is not updated.
[0016] In one specific implementation, the method further includes: When a notification is received for any virtual queue, the first pointer of that virtual queue in the pointer storage module is updated according to the notification.
[0017] According to a second aspect, embodiments of this application provide a notification suppression device, the device being applied to a Virtio backend device, the device comprising: A pointer storage module is used to store a first pointer, a second pointer, and a third pointer for each virtual queue; wherein, the first pointer indicates the descriptor position that the front-end driver has written to the virtual queue, the second pointer indicates the descriptor position that the back-end device has read from the virtual queue, and the third pointer indicates the descriptor position that the back-end device has completed and written back to the virtual queue. The decision module is configured to, in response to the detection of a pointer update event for any virtual queue, read the first, second, and third pointers of the virtual queue from the pointer storage module, determine the request backlog of the virtual queue based on the first, second, and third pointers, compare the request backlog with a preset backlog threshold, and determine the notification suppression state of the virtual queue based on the comparison result; the pointer update event refers to at least one of the first, second, and third pointer updates. An update module is used to update the suppression flag of the virtual queue according to the notification suppression status of the virtual queue; wherein the suppression flag is used to indicate whether the front-end driver sends a notification to the back-end device.
[0018] In one specific implementation, the decision module includes: The backlog calculation subunit is used to calculate the request backlog as the difference between the first pointer and the third pointer when the first pointer is not null; and to calculate the request backlog as the difference between the second pointer and the third pointer when the first pointer is null.
[0019] In one specific implementation, the decision module includes: The comparison decision subunit is configured to: determine that the notification suppression state of the virtual queue is suppressed when the request backlog is greater than a first backlog threshold, instructing the front-end driver not to send a notification to the back-end device; determine that the notification suppression state of the virtual queue is unsuppressed when the request backlog is less than a second backlog threshold, instructing the front-end driver to send a notification to the back-end device; and determine to maintain the current notification suppression state when the request backlog is greater than or equal to the second backlog threshold and less than or equal to the first backlog threshold. Wherein, the first backlog threshold is greater than the second backlog threshold.
[0020] In one specific implementation, the device further includes: The suppression state storage module is used to store the current notification suppression state of each virtual queue at the queue level. The update module is specifically used to: when it is determined that the notification suppression state of the virtual queue is suppressed or not suppressed, read the current notification suppression state of the virtual queue from the suppression state storage module; if the current notification suppression state is the same as the currently determined notification suppression state, then the suppression flag bit of the virtual queue is not updated; otherwise, the suppression flag bit of the virtual queue is updated according to the currently determined notification suppression state. When the suppression flag is at a first preset value, the corresponding notification suppression state is non-suppression; when the suppression flag is at a second preset value, the corresponding notification suppression state is suppression.
[0021] In one specific implementation, the device further includes a first timeout processing module, which comprises: The polling subunit is used to periodically poll the various virtual queues; The status reading subunit is used to read the current notification suppression status of any virtual queue from the suppression status storage module of the backend device when any virtual queue is polled. The timeout execution subunit is used to update the notification suppression status of any virtual queue to non-suppressed if the current notification suppression status of any virtual queue is suppressed, and wait for a preset time. If no notification from the front-end driver is received after waiting for the preset time, the latest pointer information of any virtual queue is obtained from the host memory, and the first pointer of any virtual queue in the pointer storage module is updated according to the latest pointer information. The host memory is a shared physical memory space used for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side.
[0022] In one specific implementation, the device further includes a second timeout processing module, which includes: A time storage unit is used to store the timeout timestamp and validity flag of each virtual queue; wherein, the timeout timestamp records the time when the notification suppression state of the virtual queue is updated from suppressed to unsuppressed; when the validity flag is a third preset value, it indicates that the queue is in a timeout monitoring state; when the validity flag is a fourth preset value, it indicates that the queue is in a non-timeout monitoring state. The timeout setting unit is used to set the timeout timestamp and validity flag of any virtual queue in the time storage unit to the current system time and a third preset value when the notification suppression status of any virtual queue is updated to non-suppression. The polling subunit is used to periodically poll each virtual queue. When any virtual queue is polled, the timeout timestamp and validity flag of that virtual queue are read from the time storage unit. The comparison subunit is used to obtain the time difference based on the timeout timestamp and the current system time if the valid flag bit of any virtual queue is a third preset value, and to determine a timeout if the time difference is greater than a preset timeout threshold. The detection subunit is used to obtain the latest pointer information of any virtual queue from the host memory when a timeout is determined, update the first pointer of any virtual queue in the pointer storage module according to the latest pointer information, and set the valid flag of any virtual queue to a fourth preset value; the host memory is the shared physical memory space for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side.
[0023] In one specific implementation, the second timeout processing module further includes: The notification processing subunit is used to read the valid flag bit of any virtual queue from the time storage unit when a notification is received from any virtual queue. If the valid flag bit of any virtual queue is a third preset value, the valid flag bit of any virtual queue is set to a fourth preset value; otherwise, the valid flag bit of any virtual queue is not updated.
[0024] In one specific implementation, the device further includes: The pointer update module is used to update the first pointer of any virtual queue in the pointer storage module according to the notification received from any virtual queue.
[0025] According to a third aspect, embodiments of this application provide a data processing unit including the notification suppression device as described in the second aspect.
[0026] According to a fourth aspect, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the notification suppression method as described in the first aspect.
[0027] According to a fifth aspect, embodiments of this application provide a computer program product, including a computer program or instructions that, when executed by a processor, implement the notification suppression method as described in the first aspect.
[0028] The notification suppression method, apparatus, data processing unit, computer-readable storage medium, and computer program product according to embodiments of this application have the following beneficial effects: In response to pointer update events, based on the first, second, and third pointers of the virtual queue, the actual backlog of requests waiting to be processed in the virtual queue is precisely quantified. The comparison result of this backlog of requests with a preset threshold is used as the decision basis for notifying the suppression state. This makes the suppression decision no longer rely on rough judgment, effectively avoiding frequent switching of the suppression state triggered by backlog fluctuations. In hardware-based backend device scenarios, this significantly reduces the number of PCIe DMA write operations initiated due to suppression state switching, and reduces the invalid occupation of PCIe bus bandwidth. Attached Figure Description
[0029] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings required in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0030] Figure 1 This is a flowchart illustrating a notification suppression method in one embodiment of this application.
[0031] Figure 2 This is a schematic diagram of the pointer storage module in one embodiment of this application.
[0032] Figure 3 This is a schematic diagram of the dual threshold comparison process in one embodiment of this application.
[0033] Figure 4 This is a timing diagram illustrating request backlog in a notification suppression scenario according to one embodiment of this application.
[0034] Figure 5 This is a schematic diagram of the structure of a time storage unit in one embodiment of this application.
[0035] Figure 6 This is a schematic diagram of the front-end and back-end interaction process of a Virtio device in one embodiment of this application.
[0036] Figure 7 This is a schematic diagram of the notification suppression device in one embodiment of this application. Detailed Implementation
[0037] The detailed description of the accompanying drawings is intended to illustrate embodiments of this application and is not intended to represent only the forms in which this application can be implemented. It should be understood that the same or equivalent functionality can be achieved by different embodiments intended to be included within the spirit and scope of this application.
[0038] Please see Figure 1 One embodiment of this application proposes a notification suppression method applied to a Virtio backend device, the method comprising: Step S10: In response to detecting a pointer update event for any virtual queue, read the first pointer, second pointer, and third pointer of the virtual queue from the pointer storage module of the backend device; wherein, the pointer update event refers to at least one of the first pointer update, the second pointer update, and the third pointer update, the first pointer indicates the descriptor position that the frontend driver has written to the virtual queue, the second pointer indicates the descriptor position that the backend device has read from the virtual queue, and the third pointer indicates that the backend device has completed and written back the descriptor position of the virtual queue; Specifically, in this embodiment, the Virtio device includes a front-end driver and a back-end device. The front-end driver runs on the host, and the back-end device is dedicated hardware plugged into the host's interface. The back-end device communicates with the front-end driver through a virtual queue. The pointer update event is triggered when the back-end device updates the first, second, or third pointer of any virtual queue. Specifically, when the back-end device receives a doorbell from the front-end driver, it retrieves the latest descriptor location information written by the front-end driver from the doorbell or host memory, and writes this descriptor location information to the first pointer of the corresponding virtual queue in the pointer storage module, thus triggering a pointer update event. When the back-end device retrieves a descriptor from the virtual queue for processing, it updates the second pointer of the corresponding virtual queue in the pointer storage module, thus triggering another pointer update event. When the back-end device completes the processing of the descriptor and writes the processing result back to the virtual queue, it updates the third pointer of the corresponding virtual queue in the pointer storage module, thus triggering another pointer update event. In other words, updating any one of the first, second, and third pointers constitutes a pointer update event. Step S10 is executed in response to any of the above situations.
[0039] The pointer storage module is located inside the backend device, such as a register file or on-chip random access memory (RAM), and is used to independently store the corresponding first pointer, second pointer, and third pointer for each virtual queue. The structure of the pointer storage module can be found in [reference needed]. Figure 2 Step S10 stores the three pointers centrally in the pointer storage module inside the back-end device, enabling the decision logic to obtain all three pointer values simultaneously within a single read cycle. This eliminates the need for multiple high-speed serial computer expansion bus (Peripheral Component Interconnect Express, PCIe) accesses to read from the host memory separately, thereby reducing decision latency and improving the response speed of suppression decisions.
[0040] Step S20: Determine the request backlog of the virtual queue based on the first pointer, the second pointer, and the third pointer; Specifically, in this embodiment, the request backlog reflects the number of requests in the virtual queue that have not yet been processed by the backend device at the current moment. Specifically, the total number of requests queued or being processed in the entire pipeline from the frontend driver to the backend device can be obtained based on the first, second, and third pointers; this value is the request backlog. The request backlog serves as the basis for subsequent decision-making regarding the suppression status. By quantifying the abstract queue status into a specific request backlog value, subsequent suppression decisions have a precise data foundation, avoiding decision bias caused by relying on rough judgments and improving the accuracy of suppression decisions.
[0041] Step S30: Compare the request backlog with a preset backlog threshold, and determine the notification suppression state of the virtual queue based on the comparison result; Specifically, in this embodiment, the preset backlog threshold is used to measure the load level of the current queue. After comparing the request backlog amount with the preset backlog threshold, the notification suppression state of the virtual queue is determined to be suppressed or unsuppressed based on the comparison result. The notification suppression state characterizes the control determination of whether the front-end driver sends a notification. For example, when the comparison result shows that the request backlog amount is high (e.g., greater than the preset backlog threshold), the notification suppression state can be determined to be suppressed, causing the front-end driver to stop sending notifications to reduce notification overhead; when the comparison result shows that the request backlog amount is low (e.g., less than the preset backlog threshold), the notification suppression state can be determined to be unsuppressed, causing the front-end driver to resume normal notification behavior. By comparing the quantified request backlog amount with the preset backlog threshold, the suppression decision is transformed into a quantifiable and repeatable hardware logic judgment, avoiding the uncertainty caused by manual setting or software intervention, and improving the real-time performance and consistency of the decision.
[0042] Step S40: Update the suppression flag of the virtual queue according to the notification suppression status of the virtual queue; wherein the suppression flag is used to indicate whether the front-end driver sends a notification to the back-end device.
[0043] Specifically, in this embodiment, the suppression flag is stored in a specific location in the host memory shared by the front-end driver and the back-end device. For Split type virtual queues, the suppression flag corresponds to the NO_NOTIFY bit in the flag field of the used ring table. For Packed type virtual queues, the suppression flag corresponds to the flag value of the device event suppression register. The back-end device writes the updated value of the suppression flag to the corresponding location in the host memory via a PCIe Direct Memory Access (DMA) write operation. Before each notification needs to be sent, the front-end driver reads the value of the suppression flag. If the value of the suppression flag indicates a suppression state, the front-end driver does not send a notification; if it indicates a non-suppressed state, the front-end driver sends a notification normally. This step S40, by updating the suppression flag, makes the notification sending behavior of the front-end driver controlled by the decision result of the back-end device, reducing unnecessary notification overhead when the queue load is high and restoring the normal notification mechanism when the queue load is low, thereby realizing closed-loop control of notification sending behavior.
[0044] As described above, the method in this embodiment responds to pointer update events and accurately quantifies the actual backlog of requests waiting to be processed in the virtual queue based on the first, second, and third pointers of the virtual queue. The comparison result of the request backlog with a preset threshold is used as the decision basis for notifying the suppression state, so that the suppression decision no longer relies on rough judgment, effectively avoiding frequent switching of the suppression state triggered by backlog fluctuations. In the hardware backend device scenario, it significantly reduces the number of PCIe DMA write operations initiated due to suppression state switching and reduces the invalid occupation of PCIe bus bandwidth.
[0045] In some embodiments, step S20 includes: When the first pointer is not null, the request backlog is the difference between the first pointer and the third pointer; when the first pointer is null, the request backlog is the difference between the second pointer and the third pointer.
[0046] Specifically, in this embodiment, the situation where the first pointer is null typically occurs when the Packed type virtual queue has not negotiated the VIRTIO_F_NOTIFICATION_DATA attribute. In this scenario, the front-end driver does not piggyback the latest first pointer value each time it sends a doorbell, and the back-end device cannot obtain the current write progress of the front-end driver through the doorbell. Therefore, the first pointer stored locally in the pointer storage module of the back-end device is always the initial value. In this case, the difference between the first pointer and the third pointer cannot be used to calculate the request backlog. Instead, the difference between the second pointer and the third pointer is used to calculate the request backlog. The second pointer records the position of the descriptor that the back-end device has read from the virtual queue, and the third pointer records the position of the descriptor that the back-end device has completed and written back. The difference between the second pointer and the third pointer represents the number of requests that the back-end device has read but has not yet completed processing. When the first pointer is not null, it indicates that the backend device can know the latest write position of the frontend driver. At this time, the difference between the first pointer and the third pointer is used to calculate the request backlog. This difference more accurately reflects the number of all pending requests in the queue, including requests that the backend device has not yet read and requests that have been read but not yet completed. Through the above judgment branch, the method of this application embodiment can be compatible with both Split queues and Packed queues, as well as different characteristic negotiation scenarios of Packed queues. It does not require designing different suppression decision logic for different queue types, reducing the complexity of hardware implementation and improving the versatility and portability of the solution.
[0047] In some embodiments, step S30 includes: When the request backlog is greater than the first backlog threshold, the notification suppression state of the virtual queue is determined to be suppressed, instructing the front-end driver not to send a notification to the back-end device; when the request backlog is less than the second backlog threshold, the notification suppression state of the virtual queue is determined to be unsuppressed, instructing the front-end driver to send a notification to the back-end device; when the request backlog is greater than or equal to the second backlog threshold and less than or equal to the first backlog threshold, the current notification suppression state is maintained. The preset backlog threshold includes the first backlog threshold and the second backlog threshold, and the first backlog threshold is greater than the second backlog threshold.
[0048] Specifically, such as Figure 3As shown, this embodiment employs a dual-threshold mechanism instead of a single-threshold mechanism to avoid frequent switching of the notification suppression state near the thresholds. If only a single threshold is used, when the request backlog fluctuates around that threshold—for example, when the request backlog repeatedly changes around the threshold—the notification suppression state will switch back and forth between suppression and non-suppression. Each switch requires updating the suppression flag in the host memory via a PCIe DMA write operation, resulting in significant unnecessary PCIe bus overhead. This embodiment sets a first backlog threshold and a second backlog threshold, introducing a hysteresis interval between the two thresholds. Suppression is only enabled when the request backlog exceeds the first backlog threshold, and only deactivated when the request backlog falls below the second backlog threshold. When the request backlog is between the two thresholds, the current notification suppression state remains unchanged. This effectively avoids frequent switching of the notification suppression state caused by small fluctuations in the request backlog near the thresholds, thereby reducing the number of PCIe DMA write operations and minimizing unnecessary PCIe bus bandwidth usage.
[0049] It should be noted that the specific values of the first backlog threshold and the second backlog threshold can be pre-configured by the system based on the processing capacity of the backend device, the depth of the virtual queue, and the requirements of the application scenario.
[0050] In some embodiments, step S40 includes: When it is determined that the notification suppression state of the virtual queue is suppressed or not suppressed, the current notification suppression state of the virtual queue is read from the suppression state storage module of the backend device. If the current notification suppression state is the same as the currently determined notification suppression state, the suppression flag of the virtual queue is not updated; otherwise, the suppression flag of the virtual queue is updated according to the currently determined notification suppression state. When the suppression flag is at a first preset value, the corresponding notification suppression state is non-suppressed, indicating that the front-end driver sends a notification to the back-end device; when the suppression flag is at a second preset value, the corresponding notification suppression state is suppressed, indicating that the front-end driver does not send a notification to the back-end device.
[0051] Specifically, in this embodiment, before writing the notification suppression state to the host memory, the backend device first queries the current notification suppression state of the virtual queue recorded in the suppression state storage module. The suppression state storage module is located inside the backend device and can be, for example, a bitmap memory organized by queues, where each bit corresponds to a virtual queue and is used to record the currently effective notification suppression state of that virtual queue. If the currently recorded state is the same as the state of the new decision, then no PCIe DMA write operation needs to be initiated for this decision. Based on this, unnecessary host memory write operations are further reduced, saving PCIe bus bandwidth. If the currently recorded state is different from the state of the new decision, the backend device updates the suppression flag bit in the host memory according to the decision result, and simultaneously updates the state of the corresponding queue in the suppression state storage module to the new value. The first preset value and the second preset value of the suppression flag bit can be, for example, 0 and 1, or vice versa; the specific values depend on the specification definition of the Virtio protocol.
[0052] In some embodiments, the method further includes: Step S50: Periodically poll each virtual queue; when any virtual queue is polled, read the current notification suppression status of any virtual queue from the suppression status storage module of the backend device. If the current notification suppression status of any virtual queue is suppressed, update its notification suppression status to non-suppressed and wait for a preset time. If no notification from the frontend driver is received after waiting for the preset time, obtain the latest pointer information of any virtual queue from the host memory and update the first pointer of any virtual queue in the pointer storage module according to the latest pointer information. The host memory is a shared physical memory space used for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side.
[0053] Specifically, in this embodiment, step S50 provides a timeout handling mechanism. This timeout handling mechanism addresses the following scenario: when the backend device enables notification suppression, the frontend driver no longer sends notifications. Subsequently, the backend device processes all backlogged requests and, based on the aforementioned decision logic, decides to lift the suppression and update the suppression flag to a non-suppressed state. However, at this time, the frontend driver may not have any new data packets to send, so it will not read the updated suppression flag or send new notifications. In this case, requests accumulated in the frontend driver during the suppression period may remain unprocessed for a long time. To solve this problem, step S50 uses a periodic polling method to traverse all virtual queues at predetermined time intervals and read the current notification suppression state of each virtual queue in the suppression state storage module. If a queue is found to still be in a suppressed state, the notification suppression state of that virtual queue is forcibly updated to a non-suppressed state, and a timeout timestamp (i.e., the current system time) is recorded, or a timer is started to determine whether a preset time has been reached. In subsequent polling cycles, if the virtual queue does not receive a notification (Doorbell) from the front-end driver within a preset time, it is determined that the front-end driver has not responded to this status update. The back-end device retrieves the latest pointer information of the virtual queue from the host memory and updates the first pointer of the virtual queue in the pointer storage module accordingly to ensure that the pointer value in the pointer storage module remains synchronized with the actual state in the host memory. Both the polling cycle and the timeout threshold can be configured by registers to adapt to different performance requirements. The host memory is the physical memory located on the host side, used to store the descriptor of the virtual queue written by the front-end driver and the suppression flag. The back-end device reads and writes to the host memory through direct memory access.
[0054] like Figure 4 As shown, at time T0, the pointer difference exceeds the first backlog threshold, and the backend device sets the NO_NOTIFY flag to 1, preventing the frontend driver from sending any more notifications. Assuming that at time T1, the frontend driver has some more packets to send, but because NO_NOTIFY=1, it won't send any notifications, and the value of the first pointer maintained by the backend device won't be updated. At time T2, after the backend device has processed the previously accumulated requests, it will update the second and third pointers, triggering an update event. Figure 5The suppression flag decision module re-compares the pointer difference. If the difference is lower than the second backlog threshold, the NO_NOTIFY flag is set to 0, allowing the front-end driver to continue sending notifications. However, since the front-end driver has no new messages to send at time T2, no new notifications will be sent, and the messages from time T1 will remain stuck in the front-end driver software. To address this issue, this embodiment also proposes a timeout handling mechanism.
[0055] In some embodiments, the method further includes: Step S60: When the notification suppression status of any virtual queue is updated to non-suppressed, the timeout timestamp and valid flag of the virtual queue in the time storage unit of the backend device are set to the current system time and the third preset value, respectively. Step S70: Periodically poll each virtual queue; when any virtual queue is polled, read the timeout timestamp and valid flag of any virtual queue from the time storage unit of the backend device; if the valid flag of any virtual queue is a third preset value, obtain the time difference based on the timeout timestamp and the current system time; if the time difference is greater than a preset timeout threshold, determine that a timeout has occurred, obtain the latest pointer information of any virtual queue from the host memory, update the first pointer of any virtual queue in the pointer storage module according to the latest pointer information, and set the valid flag of any virtual queue to a fourth preset value; The host memory is a shared physical memory space used for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side; the time storage unit is as follows: Figure 5 As shown, the timeout timestamp records the time when the notification suppression state of the virtual queue is updated from suppressed to unsuppressed; when the valid flag bit is a third preset value, it indicates that the queue is in a timeout monitoring state; when the valid flag bit is a fourth preset value, it indicates that the queue is in a non-timeout monitoring state.
[0056] Specifically, in this embodiment, steps S60 and S70 provide another timeout handling mechanism. Specifically, when the notification suppression state of a virtual queue switches from suppressed to unsuppressed, the backend device writes the current system time into the timeout timestamp corresponding to the virtual queue, and simultaneously sets the valid flag bit to the third preset value, indicating that the virtual queue has entered a timeout monitoring state. The polling logic scans the valid flag bits of each virtual queue at a fixed period. For queues where the valid flag bit is the third preset value, the difference between the current system time and the timeout timestamp is calculated, and this difference is compared with the preset timeout threshold. If the difference exceeds the preset timeout threshold, the virtual queue is determined to have timed out. After a timeout occurs, the backend device reads the latest pointer information of the virtual queue from the host memory, updates the first pointer of the virtual queue in the pointer storage module with the read latest pointer information, and then sets the valid flag bit to the fourth preset value, exiting the timeout monitoring state. This embodiment, through precise timestamp comparison, can trigger proactive detection at a determined timeout point, solving the problem of long-term request backlog. Meanwhile, by controlling the independent timeout monitoring status of each virtual queue through the effective flag bit, unnecessary polling comparison operations are avoided, reducing power consumption. The timeout timestamp can be represented by a 10-bit counter with an accuracy of 1 microsecond, and can represent a maximum of 1024 microseconds. The polling period and the preset timeout threshold can both be configured through registers. The timeout processing scheme of this embodiment provides a definite timeout accuracy and is suitable for scenarios with high real-time requirements.
[0057] It should be noted that the specific operation for retrieving the latest pointer information from the host memory varies depending on the type of virtual queue.
[0058] For a Split-type virtual queue, the available ring table in the host memory contains a separate index field. This index field records the position of the descriptor currently written by the front-end driver, i.e., the value of the first pointer. After determining a timeout, the back-end device initiates a DMA read request, reads the index field of the available ring table from the host memory, uses the read value as the latest pointer information, and directly updates the first pointer of the virtual queue in the pointer storage module.
[0059] For Packed type virtual queues, since there is no independent availability ring table, the host memory maintains a unified descriptor ring. The state of the descriptor itself is identified by the AVAIL and USED bits in the flag field. In this case, after the backend device determines a timeout, it initiates a DMA read request to read the descriptor entry or flag field at the corresponding position in the descriptor ring from the host memory. The update method differs depending on whether the VIRTIO_F_NOTIFICATION_DATA feature has been negotiated: If the Packed type virtual queue has negotiated the VIRTIO_F_NOTIFICATION_DATA attribute, the backend device reads the available index and package counter of the descriptor ring from the host memory, and updates the first pointer of the virtual queue in the pointer storage module with the read available index value.
[0060] If the Packed type virtual queue has not negotiated the VIRTIO_F_NOTIFICATION_DATA attribute, the backend device reads the flag field of the descriptor entry in the descriptor ring from the host memory, and infers the current write progress of the frontend driver by parsing the AVAIL bit in the flag field. Based on the inference result, the backend device updates the first pointer of the virtual queue in the pointer storage module.
[0061] In some embodiments, the method further includes: Step S80: When a notification of any virtual queue is received, the valid flag bit of any virtual queue is read from the time storage unit of the backend device. If the valid flag bit of any virtual queue is a third preset value, the valid flag bit of any virtual queue is set to a fourth preset value; otherwise, the valid flag bit of any virtual queue is not updated.
[0062] Specifically, in this embodiment, step S80 is used in conjunction with steps S60 and S70. When the backend device receives a notification from the frontend driver, it indicates that the frontend driver has resumed normal notification sending behavior. At this time, the backend device reads the valid flag bit of the virtual queue in the time storage unit. If the valid flag bit is the third preset value, it indicates that the virtual queue is currently in a timeout monitoring state. Then, the backend device sets the valid flag bit to the fourth preset value and stops timeout monitoring of the virtual queue. If the valid flag bit is already the fourth preset value, no operation is required. This process avoids unnecessary timeout monitoring when the frontend driver has resumed normal communication, reduces invalid polling comparison operations, reduces hardware power consumption, and ensures that the timeout monitoring mechanism can accurately take effect when needed.
[0063] In some embodiments, the method further includes: Step S90: When a notification of any virtual queue is received, update the first pointer of the virtual queue in the pointer storage module according to the notification; update the second pointer when the backend device retrieves a descriptor from the virtual queue for processing; and update the third pointer when the backend device completes the processing of the descriptor and writes the used descriptor back to the virtual queue.
[0064] Specifically, in this embodiment, step S90 is related to the triggering mechanism of the pointer update event described in step S10. When the backend device receives a notification from the frontend driver, the notification may or may not carry the latest descriptor write location information of the frontend driver. In the case where it does not carry the information, the backend device needs to initiate a DMA read operation to obtain the latest first pointer value from the host memory. In the case where it carries the information, the backend device directly extracts the piggybacked first pointer value from the notification. Regardless of the method used, the backend device needs to update the obtained latest pointer information to the first pointer corresponding to the virtual queue in the pointer storage module. After this update operation is completed, the pointer update event described in step S10 is generated, triggering the subsequent request backlog calculation and notification suppression state decision process. Step S90 ensures that the pointer value in the pointer storage module is synchronized with the actual state in the host memory, ensuring that the subsequent backlog calculation and suppression decision are based on correct data, thereby ensuring the correctness and reliability of the entire notification suppression method.
[0065] Furthermore, when the backend device retrieves a descriptor from the virtual queue for processing, the pointer update module updates the second pointer of the virtual queue in the pointer storage module to record the position of the descriptor currently read by the backend device. When the backend device completes processing the descriptor and writes the used descriptor back to the virtual queue, the pointer update module updates the third pointer of the virtual queue in the pointer storage module to record the position of the descriptor currently completed by the backend device. After the above update operations are completed, a pointer update event is also generated, triggering the subsequent request backlog calculation and notification suppression state decision process. The second and third pointers are updated automatically by the backend device according to its own processing progress, without needing to be read from the host memory.
[0066] It should be noted that the order of the method steps in the embodiments of this application, such as step numbers like S10 and S20, is set only for ease of description and does not constitute a limitation on the execution order of the steps. In actual execution, the order between steps can be adjusted as needed, for example, some steps can be executed in parallel or their order can be swapped.
[0067] The following example describes the front-end and back-end interaction process of a Virtio device using the method of this embodiment. In this example, as shown... Figure 6 As shown, the front-end driver and the back-end device interact using a Split type queue. The interaction steps between the front-end driver and the back-end device are described as follows: ① to ⑧: ① Front-end driver fills the sending buffer: The Virtio front-end driver fills the content of the data packets to be sent into the sending buffer in the Guest memory. The front-end driver is responsible for allocating and managing these buffers. After the data packets are sent, the buffers are reclaimed by the front-end driver.
[0068] ② The front-end driver fills in the descriptors and submits them to the descriptor queue: The front-end driver constructs a descriptor entry for each cache block, fills in the cache address (8B), length (4B), flag (2B) and next hop (2B), and then puts these descriptors into the descriptor queue (descriptor table) in sequence.
[0069] ③ The front-end driver updates the available ring table pointers and finally updates the index values in the available ring table.
[0070] ④ The front-end driver checks the suppression flag (FLAG) in the used ring table. If NO_NOTIFY=0 in the FLAG, it sends a doorbell notification to the back-end device that a new data packet is ready to be sent. If NO_NOTIFY=1 in the FLAG, it does not send a doorbell notification to the back-end device. After receiving the doorbell notification, the notification processing module in the back-end device sends the queue information carried in the doorbell notification to the available ring table read module. In addition, each time the notification processing module receives a pointer update event (including an update of the available ring table pointer caused by receiving a doorbell notification), it decides whether to update the FLAG value in the used ring table based on its internal decision logic. The notification processing module also periodically polls the status of each queue and resends a DMA read request to obtain the latest pointer information for queues that have timed out.
[0071] ⑤ The available ring table read module reads the available ring table index, reads the newly written pointer values in the available ring table according to the index, and passes these pointer values to the descriptor read module.
[0072] ⑥ The descriptor reading module reads the descriptor queue: The descriptor reading module retrieves the descriptors prepared by the front-end driver from the descriptor queue, obtains the address and length information of the data packet buffer to be sent, and determines the location of this packet in the host memory. Finally, it passes the above information to the data packet sending and used ring table write-back module.
[0073] ⑦ The data packet sending and used ring table write-back module reads data and writes back the descriptor based on the descriptor information: The data packet sending and used ring table write-back module initiates a DMA read operation based on the descriptor information, retrieves the data packet from the host memory, and simultaneously writes the used descriptor entries back to the used ring table. It should be noted that the data packet sending and used ring table write-back module will simultaneously receive FLAG update requests initiated by the notification processing module. Internally, the data packet sending and used ring table write-back module schedules normal data DMA write operations and DMA write operations for suppression flag (FLAG) update requests through a preset scheduling method (such as round-robin scheduling).
[0074] ⑧ Send interrupt notification to the front end: The interrupt sending module sends an interrupt signal to the host to notify the front end driver that the message just sent has been sent. After the front end driver is woken up, it reclaims the above-mentioned data transmission buffer and the corresponding descriptor.
[0075] It should be noted that the front-end and back-end interaction of the Packed type virtual queue is similar to that of the Split type queue, so examples of the Packed type virtual queue will not be listed separately here.
[0076] Corresponding to the notification suppression method described in the above embodiments, another embodiment of this application provides a notification suppression device, which is applied to a Virtio backend device, specifically it can be applied to / integrated into Figure 6 The example shown includes a notification processing module, a data packet sending module, and a used ring table write-back module, such as... Figure 7 As shown, the apparatus of this embodiment includes: The pointer storage module 1 is used to store a first pointer, a second pointer, and a third pointer for each virtual queue; wherein, the first pointer indicates the descriptor position that the front-end driver has written to the virtual queue, the second pointer indicates the descriptor position that the back-end device has read from the virtual queue, and the third pointer indicates the descriptor position that the back-end device has completed and written back to the virtual queue. Decision module 2 is configured to, in response to detecting a pointer update event of any virtual queue, read the first pointer, second pointer, and third pointer of the virtual queue from the pointer storage module, determine the request backlog of the virtual queue based on the first pointer, second pointer, and third pointer, compare the request backlog with a preset backlog threshold, and determine the notification suppression state of the virtual queue based on the comparison result; the pointer update event refers to at least one of the first pointer update, second pointer update, and third pointer update; Update module 3 is used to update the suppression flag of the virtual queue according to the notification suppression status of the virtual queue; wherein the suppression flag is used to indicate whether the front-end driver sends a notification to the back-end device.
[0077] In some embodiments, the decision module 2 includes: The backlog calculation subunit is used to calculate the request backlog as the difference between the first pointer and the third pointer when the first pointer is not null; and to calculate the request backlog as the difference between the second pointer and the third pointer when the first pointer is null.
[0078] In some embodiments, the decision module 2 includes: The comparison decision subunit is configured to: determine that the notification suppression state of the virtual queue is suppressed when the request backlog is greater than a first backlog threshold, instructing the front-end driver not to send a notification to the back-end device; determine that the notification suppression state of the virtual queue is unsuppressed when the request backlog is less than a second backlog threshold, instructing the front-end driver to send a notification to the back-end device; and determine to maintain the current notification suppression state when the request backlog is greater than or equal to the second backlog threshold and less than or equal to the first backlog threshold. The preset backlog threshold includes the first backlog threshold and the second backlog threshold, and the first backlog threshold is greater than the second backlog threshold.
[0079] In some embodiments, the apparatus further includes: Suppression state storage module 4 is used to store the current notification suppression state of each virtual queue at the queue granularity; The update module is specifically used to: when it is determined that the notification suppression state of the virtual queue is suppressed or not suppressed, read the current notification suppression state of the virtual queue from the suppression state storage module; if the current notification suppression state is the same as the currently determined notification suppression state, then the suppression flag bit of the virtual queue is not updated; otherwise, the suppression flag bit of the virtual queue is updated according to the currently determined notification suppression state. When the suppression flag is at a first preset value, the corresponding notification suppression state is non-suppressed, indicating that the front-end driver sends a notification to the back-end device; when the suppression flag is at a second preset value, the corresponding notification suppression state is suppressed, indicating that the front-end driver does not send a notification to the back-end device.
[0080] In some embodiments, the apparatus further includes a first timeout processing module 5, the first timeout processing module comprising: The polling subunit is used to periodically poll the various virtual queues; The status reading subunit is used to read the current notification suppression status of any virtual queue from the suppression status storage module of the backend device when any virtual queue is polled. The timeout execution subunit is used to update the notification suppression status of any virtual queue to non-suppressed if the current notification suppression status of any virtual queue is suppressed, and wait for a preset time. If no notification from the front-end driver is received after waiting for the preset time, the latest pointer information of any virtual queue is obtained from the host memory, and the first pointer of any virtual queue in the pointer storage module is updated according to the latest pointer information. The host memory is a shared physical memory space used for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side.
[0081] In some embodiments, the apparatus further includes a second timeout processing module 6, the second timeout processing module 6 comprising: A time storage unit is used to store the timeout timestamp and validity flag of each virtual queue; wherein, the timeout timestamp records the time when the notification suppression state of the virtual queue is updated from suppressed to unsuppressed; when the validity flag is a third preset value, it indicates that the queue is in a timeout monitoring state; when the validity flag is a fourth preset value, it indicates that the queue is in a non-timeout monitoring state. The timeout setting unit is used to set the timeout timestamp and validity flag of any virtual queue in the time storage unit to the current system time and a third preset value when the notification suppression status of any virtual queue is updated to non-suppression. The polling subunit is used to periodically poll each virtual queue. When any virtual queue is polled, the timeout timestamp and validity flag of that virtual queue are read from the time storage unit. The comparison subunit is used to obtain the time difference based on the timeout timestamp and the current system time if the valid flag bit of any virtual queue is a third preset value, and to determine a timeout if the time difference is greater than a preset timeout threshold. The detection subunit is used to retrieve the latest pointer information of any virtual queue from the host memory when a timeout is determined, update the first pointer of any virtual queue in the pointer storage module according to the latest pointer information, and set the valid flag of any virtual queue to a fourth preset value.
[0082] In some embodiments, the second timeout processing module 6 further includes: The notification processing subunit is used to read the valid flag bit of any virtual queue from the time storage unit when a notification is received from any virtual queue. If the valid flag bit of any virtual queue is a third preset value, the valid flag bit of any virtual queue is set to a fourth preset value; otherwise, the valid flag bit of any virtual queue is not updated.
[0083] In some embodiments, the apparatus further includes: The pointer update module 7 is configured to update the first pointer of any virtual queue in the pointer storage module according to the notification received when any virtual queue is received, update the second pointer when the backend device retrieves a descriptor from the virtual queue for processing, and update the third pointer when the backend device completes the processing of the descriptor and writes the used descriptor back to the virtual queue.
[0084] It should be noted that, Figure 7 The blocks formed by solid lines are required modules, while the blocks formed by dashed lines are optional modules, such as the suppression state storage module 4, the first timeout processing module 5, the second timeout processing module 6, and the pointer update module 7.
[0085] It should be noted that the notification suppression device in this embodiment corresponds to the notification suppression method described in the above embodiments. Each module in the notification suppression device in this embodiment is used to implement the corresponding steps in the method described in the above embodiments. Therefore, a detailed description of the relevant content of the notification suppression device in this embodiment can be found in the method described in the above embodiments, and will not be repeated here.
[0086] Another embodiment of this application provides a data processing unit (DPU) including the notification suppression device as described in the above embodiments.
[0087] Specifically, in this embodiment, the data processing unit can be a network processor in a smart network interface card (NIC), a processing core in a digital processing unit (DPU), or other dedicated data processing chips. This data processing unit integrates the notification suppression device described in the above embodiments, enabling it to independently complete notification suppression decisions and update operations for the Virtio backend device without intervention from the host CPU. By offloading the notification suppression function to the data processing unit, the context switching overhead caused by the host CPU's involvement in suppression decisions is avoided, further reducing the load on the host CPU and improving the overall system performance.
[0088] Another embodiment of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the notification suppression method as described in the above embodiments.
[0089] Specifically, in this embodiment, the computer-readable storage medium may be a read-only memory, random access memory, flash memory, hard disk, solid-state drive, or other forms of non-volatile storage medium. When the computer program stored in this storage medium is executed by a processor, the processor performs the various steps of the notification suppression method described in the foregoing embodiments.
[0090] Another embodiment of this application provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the notification suppression method as described in the above embodiments.
[0091] Specifically, in this embodiment, the computer program product may be an instruction set, executable code, application program, or firmware. This computer program product may be deployed on a host server or burned into the firmware of a hardware device. When the computer program or instructions in the computer program product are executed by a processor, the processor implements the various steps of the notification suppression method described in the foregoing embodiments.
[0092] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical applications, or technological improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A notification suppression method, the method being applied to a Virtio backend device, characterized in that, The method includes: In response to the detection of a pointer update event for any virtual queue, the first pointer, second pointer, and third pointer of the virtual queue are read from the pointer storage module of the backend device; wherein, the pointer update event refers to at least one of the first pointer update, the second pointer update, and the third pointer update, the first pointer indicates the descriptor position that the frontend driver has written to the virtual queue, the second pointer indicates the descriptor position that the backend device has read from the virtual queue, and the third pointer indicates that the backend device has completed and written back the descriptor position of the virtual queue; The request backlog of the virtual queue is determined based on the first pointer, the second pointer, and the third pointer; when the first pointer is not null, the request backlog is the difference between the first pointer and the third pointer; when the first pointer is null, the request backlog is the difference between the second pointer and the third pointer. The request backlog is compared with a preset backlog threshold, and the notification suppression state of the virtual queue is determined based on the comparison result. The suppression flag of the virtual queue is updated according to the notification suppression status of the virtual queue; wherein the suppression flag is used to indicate whether the front-end driver sends a notification to the back-end device.
2. The notification suppression method according to claim 1, characterized in that, The step of comparing the request backlog with a preset backlog threshold and determining the notification suppression state of the virtual queue based on the comparison result includes: When the request backlog exceeds the first backlog threshold, the notification suppression state of the virtual queue is determined to be suppressed, instructing the front-end driver not to send notifications to the back-end device. When the request backlog is less than the second backlog threshold, the notification suppression state of the virtual queue is determined to be unsuppressed, and the front-end driver is instructed to send a notification to the back-end device. When the request backlog is greater than or equal to the second backlog threshold and less than or equal to the first backlog threshold, it is determined to maintain the current notification suppression state; Wherein, the first backlog threshold is greater than the second backlog threshold.
3. The notification suppression method according to claim 2, characterized in that, The step of updating the suppression flag of the virtual queue according to the notification suppression status of the virtual queue includes: When it is determined that the notification suppression state of the virtual queue is suppressed or not suppressed, the current notification suppression state of the virtual queue is read from the suppression state storage module of the backend device. If the current notification suppression state is the same as the currently determined notification suppression state, the suppression flag of the virtual queue is not updated; otherwise, the suppression flag of the virtual queue is updated according to the currently determined notification suppression state. When the suppression flag is at a first preset value, the corresponding notification suppression state is non-suppression; when the suppression flag is at a second preset value, the corresponding notification suppression state is suppression.
4. The notification suppression method according to claim 1, characterized in that, The method further includes: Periodically poll each virtual queue; When any virtual queue is polled, the current notification suppression status of any virtual queue is read from the suppression status storage module of the backend device. If the current notification suppression status of any virtual queue is suppressed, its notification suppression status is updated to non-suppressed, and a preset time is waited. If no notification from the frontend driver is received after waiting for the preset time, the latest pointer information of any virtual queue is obtained from the host memory, and the first pointer of any virtual queue in the pointer storage module is updated according to the latest pointer information. The host memory is a shared physical memory space used for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side.
5. The notification suppression method according to claim 1, characterized in that, The method further includes: When the notification suppression status of any virtual queue is updated to non-suppressed, the timeout timestamp and validity flag of that virtual queue in the time storage unit of the backend device are respectively set to the current system time and the third preset value. The system periodically polls each virtual queue. When any virtual queue is polled, the system reads the timeout timestamp and valid flag of that virtual queue from the time storage unit. If the valid flag of that virtual queue is a third preset value, the system obtains the time difference based on the timeout timestamp and the current system time. If the time difference is greater than a preset timeout threshold, a timeout is determined. The system then retrieves the latest pointer information of that virtual queue from the host memory, updates the first pointer of that virtual queue in the pointer storage module based on the latest pointer information, and sets the valid flag of that virtual queue to a fourth preset value. Wherein, the host memory is the shared physical memory space for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side; the timeout timestamp records the time when the notification suppression state of the virtual queue is updated from suppressed to unsuppressed; when the valid flag bit is a third preset value, it indicates that the queue is in a timeout monitoring state; when the valid flag bit is a fourth preset value, it indicates that the queue is in a non-timeout monitoring state.
6. The notification suppression method according to claim 5, characterized in that, The method further includes: When a notification is received from any virtual queue, the valid flag bit of any virtual queue is read from the time storage unit of the backend device. If the valid flag bit of any virtual queue is a third preset value, the valid flag bit of any virtual queue is set to a fourth preset value; otherwise, the valid flag bit of any virtual queue is not updated.
7. The notification suppression method according to any one of claims 1 to 6, characterized in that, The method further includes: When a notification is received for any virtual queue, the first pointer of that virtual queue in the pointer storage module is updated according to the notification.
8. A notification suppression device, said device being applied to a Virtio backend device, characterized in that, The device includes: A pointer storage module is used to store a first pointer, a second pointer, and a third pointer for each virtual queue; wherein, the first pointer indicates the descriptor position that the front-end driver has written to the virtual queue, the second pointer indicates the descriptor position that the back-end device has read from the virtual queue, and the third pointer indicates the descriptor position that the back-end device has completed and written back to the virtual queue. A decision module is configured to, in response to the detection of a pointer update event for any virtual queue, read the first, second, and third pointers of the virtual queue from the pointer storage module, determine the request backlog of the virtual queue based on the first, second, and third pointers, compare the request backlog with a preset backlog threshold, and determine the notification suppression state of the virtual queue based on the comparison result; the pointer update event refers to at least one of the first, second, and third pointer updates; the decision module includes a backlog calculation subunit, which is configured to calculate the request backlog as the difference between the first and third pointers when the first pointer is not null, and calculate the request backlog as the difference between the second and third pointers when the first pointer is null; an update module is configured to update the suppression flag of the virtual queue according to the notification suppression state of the virtual queue; wherein the suppression flag is used to indicate whether the front-end driver sends a notification to the back-end device.
9. The apparatus according to claim 8, characterized in that, The decision-making module includes: The comparison decision subunit is configured to: determine that the notification suppression state of the virtual queue is suppressed when the request backlog is greater than a first backlog threshold, instructing the front-end driver not to send a notification to the back-end device; determine that the notification suppression state of the virtual queue is unsuppressed when the request backlog is less than a second backlog threshold, instructing the front-end driver to send a notification to the back-end device; and determine to maintain the current notification suppression state when the request backlog is greater than or equal to the second backlog threshold and less than or equal to the first backlog threshold. Wherein, the first backlog threshold is greater than the second backlog threshold.
10. The apparatus according to claim 9, characterized in that, The device further includes: The suppression state storage module is used to store the current notification suppression state of each virtual queue at the queue level. The update module is specifically used to: when it is determined that the notification suppression state of the virtual queue is suppressed or not suppressed, read the current notification suppression state of the virtual queue from the suppression state storage module; if the current notification suppression state is the same as the currently determined notification suppression state, then the suppression flag bit of the virtual queue is not updated; otherwise, the suppression flag bit of the virtual queue is updated according to the currently determined notification suppression state. When the suppression flag is at a first preset value, the corresponding notification suppression state is non-suppression; when the suppression flag is at a second preset value, the corresponding notification suppression state is suppression.
11. The apparatus according to claim 8, characterized in that, The device further includes a first timeout processing module, the first timeout processing module comprising: The polling subunit is used to periodically poll the various virtual queues; The status reading subunit is used to read the current notification suppression status of any virtual queue from the suppression status storage module of the backend device when any virtual queue is polled. The timeout execution subunit is used to update the notification suppression status of any virtual queue to non-suppressed if the current notification suppression status of any virtual queue is suppressed, and wait for a preset time. If no notification from the front-end driver is received after waiting for the preset time, the latest pointer information of any virtual queue is obtained from the host memory, and the first pointer of any virtual queue in the pointer storage module is updated according to the latest pointer information. The host memory is a shared physical memory space used for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side.
12. The apparatus according to claim 8, characterized in that, The device further includes a second timeout processing module, which includes: a time storage unit for storing the timeout timestamp and valid flag bit of each virtual queue; wherein, the timeout timestamp records the time when the notification suppression state of the virtual queue is updated from suppressed to unsuppressed; when the valid flag bit is a third preset value, it indicates that the queue is in a timeout monitoring state; when the valid flag bit is a fourth preset value, it indicates that the queue is in a non-timeout monitoring state; The timeout setting unit is used to set the timeout timestamp and validity flag of any virtual queue in the time storage unit to the current system time and a third preset value when the notification suppression status of any virtual queue is updated to non-suppression. The polling subunit is used to periodically poll each virtual queue. When any virtual queue is polled, the timeout timestamp and validity flag of that virtual queue are read from the time storage unit. The comparison subunit is used to obtain the time difference based on the timeout timestamp and the current system time if the valid flag bit of any virtual queue is a third preset value, and to determine a timeout if the time difference is greater than a preset timeout threshold. The detection subunit is used to obtain the latest pointer information of any virtual queue from the host memory when a timeout is determined, update the first pointer of any virtual queue in the pointer storage module according to the latest pointer information, and set the valid flag of any virtual queue to a fourth preset value; the host memory is the shared physical memory space for data interaction between the front-end driver and the back-end device, and the host memory is located on the host side.
13. The apparatus according to claim 12, characterized in that, The second timeout processing module also includes: The notification processing subunit is used to read the valid flag bit of any virtual queue from the time storage unit when a notification is received from any virtual queue. If the valid flag bit of any virtual queue is a third preset value, the valid flag bit of any virtual queue is set to a fourth preset value; otherwise, the valid flag bit of any virtual queue is not updated.
14. The apparatus according to any one of claims 8 to 13, characterized in that, The device further includes: The pointer update module is used to update the first pointer of any virtual queue in the pointer storage module according to the notification received from any virtual queue.
15. A data processing unit, characterized in that, Includes the notification suppression device as described in any one of claims 8 to 14.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the notification suppression method as described in any one of claims 1 to 7.
17. A computer program product comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by the processor, they implement the notification suppression method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
VIRTIO equipment interruption method and device, back-end equipment and chip
CN117931406A
Notification suppression method, electronic equipment and storage medium
CN122601599A
