refactor(blk): offload virtqueue drain to worker thread - #95
Merged
Merged
Conversation
agicy
force-pushed
the
refactor-blk-worker
branch
2 times, most recently
from
June 9, 2026 12:54
10eebf0 to
f90ae43
Compare
agicy
marked this pull request as ready for review
June 9, 2026 12:56
agicy
force-pushed
the
refactor-blk-worker
branch
from
July 31, 2026 09:44
f90ae43 to
9836392
Compare
agicy
force-pushed
the
refactor-blk-worker
branch
from
August 19, 2026 14:26
9836392 to
85a5dd8
Compare
Contributor
|
Thanks for the contribution. This update adds clearer documentation to the Only small nit, otherwise LGTM! |
li041
reviewed
Aug 20, 2026
li041
approved these changes
Aug 20, 2026
li041
reviewed
Aug 20, 2026
agicy
added a commit
that referenced
this pull request
Aug 24, 2026
refactor(blk): offload virtqueue drain to worker thread
agicy
added a commit
that referenced
this pull request
Aug 24, 2026
refactor(blk): offload virtqueue drain to worker thread
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
This PR refactors the virtio-blk worker threading model to eliminate the intermediate producer-consumer queue between the main thread and the I/O worker thread.
Before
blkp_reqstructs onto a cross-thread queue (procq).procq's mutex for every single I/O request.After
pthread_cond_signal— it never touches the virtqueue.Performance
Test setup: ramdisk backend, fio + io_uring, 120s runtime, RK3588.
Bug Fixes
While refactoring, several pre-existing issues were fixed:
pthread_joinsovirtio_blk_closedoesn't join an uninitialized thread handle if the worker was never started.written_lenon read error: Whenpreadvfails,written_lenno longer carries-1into the used-ring update (was reporting 0 bytes despite the status byte being written).written_lenforGET_ID: Now reports correct data length via the used ring so the guest sees the full device ID string.close(-1)on open failure: Removed spuriousclose(-1)in the error path whenopen()fails.fstatreturnsst_size = 0(real block devices), fall back toioctl(BLKGETSIZE64).