Page MenuHomeFreeBSD

bhyve/virtio-scsi: Preallocate all I/O requests
AcceptedPublic

Authored by rosenfeld_grumpf.hope-2000.org on Oct 30 2025, 7:38 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Feb 15, 8:37 PM
Unknown Object (File)
Sun, Feb 15, 5:22 PM
Unknown Object (File)
Jan 13 2026, 1:20 AM
Unknown Object (File)
Jan 12 2026, 2:30 PM
Unknown Object (File)
Jan 8 2026, 5:04 PM
Unknown Object (File)
Jan 7 2026, 6:52 AM
Unknown Object (File)
Dec 28 2025, 9:55 AM
Unknown Object (File)
Dec 26 2025, 11:50 AM

Details

Reviewers
jhb
corvink
markj
Group Reviewers
bhyve
Summary

By preallocating all I/O requests on all queues, we can take most
allocations out of the hot I/O code paths and simplify the code
significantly. While here, make sure we check all allocations for
success and make sure to handle failures gracefully.

Additionally, check for I/O request validity as early as possible,
and return illegal requests immediately.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68273
Build 65156: arc lint + arc unit

Event Timeline

rosenfeld_grumpf.hope-2000.org retitled this revision from bhyve/virtio-scsi: preallocate all I/O requests to bhyve/virtio-scsi: Preallocate all I/O requests.Mon, Feb 9, 4:26 PM

Sync with latest illumos bits after code review.

Use a size_t type where appropriate instead of the abomination that is uint.

This broadly looks ok, I have a few inline comments.

usr.sbin/bhyve/pci_virtio_scsi.c
111

Some comment explaining how these three mutexes are used would be appreciated.

572

Is the vsr_queue field used for anything?

669

Is it really necessary to clear the whole request structure like this?

840

There's no cleanup of the threads in this error path. If you allocate all of the worker structures at once, before the loop, then you don't need to think about cleaning up in this error path (aside from the requests allocated in the loop above, which are easy to deal with).

This revision is now accepted and ready to land.Mon, Feb 16, 9:41 PM