Conversation
The VirtIO BIO worker dequeued up to 16 requests even when fewer requests remained in its 32-request budget. Breaking the consuming iterator at the budget boundary could discard unpublished BIOs. Hardware QueueFull was also converted to a final EIO instead of retaining the request. A fixed 20 ms cooldown after each full round neither prevented queue exhaustion nor responded to descriptor reclamation. Bound each dequeue by the remaining work budget and process the entire returned batch. Retain the current BIO on QueueFull and retry through a device-local WaitQueue whose condition attempts submission. Completion reclamation wakes the queue before invoking callbacks; shutdown publishes non-Online and wakes it before joining the worker. Registration followed by condition rechecking closes the wake-before-sleep race without a duplicate capacity counter or completion epoch. Keep the worker in the default fair scheduling class and use cond_resched at bounded work-round boundaries instead of FIFO plus a fixed cooldown. Idle waits remain event driven. Preserve the journal, flush protocol and VirtQueue size; add an optional QueueFull retry diagnostic counter. Hold the device lock through hardware submission, token-context insertion and Submitted-state publication so another CPU cannot consume a completion before its context exists. Keep callbacks outside that lock. On the fatal duplicate-token invariant path, retain the exposed DMA context explicitly because kernel panic can unwind rather than halt the whole machine. Add a lightweight host test including the production BioQueue and a whitelisted, read-only dunitest using independently opened block-device descriptions. The test checks completion and contents without writing the raw disk, and bounds its controller if a BIO becomes stuck. Validation: - Before: deterministic dequeue test took 33 requests for budget 32; guest concurrent reads reported QueueFull errors and timed out. - After: two host queue tests pass, including FIFO, zero budget and stop. - Kernel and static dunitest builds pass. - Guest concurrent reads pass five rounds on two vCPUs and five on one; QueueFull retries are exercised with zero errors or remaining BIOs. - Full guest ext4 inode suite passes 44/44; Git object checking, local up-to-date pull and a 32 MiB root-filesystem sync probe pass. - Three-role adversarial review completed; the DMA unwind finding was fixed and rechecked. Hot-removal races and strict scheduler tail-latency bounds were not exhaustively fault-injected by this validation. Signed-off-by: longjin <longjin@dragonos.org>
Member
Author
|
@codex review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace VirtIO BIO budget cooldown with event-driven descriptor backpressure, and close related ownership/publication gaps.
QueueFullas retryable, retaining the current BIO in order. Reuse WaitQueue condition checking rather than adding an epoch or descriptor-count mirror.cond_resched(), removing the fixed 20 ms sleep and FIFO override.No journal, flush ordering, VirtQueue size, rate-limiting framework or public syscall ABI changes. The optional diagnostic counter
queue_full_retriescounts failed admission attempts, not failed BIOs.budget_hitsnow counts exhausted work rounds, not timed cooldowns.Before/after evidence
The guest regression is read-only and verifies stable LBA0 contents. Each reader opens its own file description to avoid VFS per-file serialization. It skips explicitly when the VirtIO block device is unavailable and is included in the dunitest whitelist.
Validation
make kernelwith diagnostic statistics enabled: pass.Host test command:
Limits
The host harness substitutes synchronization primitives and validates actual queue logic, not kernel scheduling. The guest tests do not exhaustively inject hot-removal races, media errors or all wakeup interleavings. The single-core CPU workload is a progress smoke test, not a fairness or tail-latency guarantee. This PR does not claim to remove the remaining ext4 small-file synchronization cost.