Page MenuHomeFreeBSD

virtio_random: Pipeline fetching the data
ClosedPublic

Authored by jhb on Aug 30 2023, 8:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 8, 10:27 AM
Unknown Object (File)
Thu, Nov 7, 10:22 AM
Unknown Object (File)
Wed, Nov 6, 8:21 PM
Unknown Object (File)
Tue, Nov 5, 11:26 AM
Unknown Object (File)
Fri, Nov 1, 2:48 AM
Unknown Object (File)
Wed, Oct 30, 4:06 PM
Unknown Object (File)
Oct 16 2024, 8:09 PM
Unknown Object (File)
Oct 15 2024, 1:24 AM
Subscribers

Details

Summary

Queue an initial fetch of data during attach and after every read
rather than synchronously fetching data and polling for completion.

If data has not been returned from an previous fetch during read,
just return EAGAIN rather than blocking.

Co-authored-by: John Baldwin <jhb@FreeBSD.org>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Aug 30 2023, 8:13 PM

This is an alternate version of D38898 with some of the review feedback there addressed (I believe), e.g using malloc_aligned. I also simplified the sglist handling by just initializing it once during attach.

sys/dev/virtio/random/virtio_random.c
152

The old code wanted 8-byte alignment, but here you're asking for 4 bytes of alignment. Is that intentional? It's not clear to me where the alignment requirement comes from.

303

Perhaps assert that cookie == sc.

307

I don't quite see the purpose of zeroing this value stored in the softc. Before, doing so made more reasonable since the read value was on the stack, but now there's no real way it'd be leaked.

sys/dev/virtio/random/virtio_random.c
152

Oh, interesting. If nothing else I should keep the old alignment and if the alignment needs changing it should be relaxed as its own commit,

307

Fair enough. I made the free of the vtrnd_value use zfree in detach. Do you think I should just revert that to a plain free?

sys/dev/virtio/random/virtio_random.c
307

I think the use of zfree() is reasonable, it just doesn't seem useful to clear the buffer upon every request.

jhb marked 4 inline comments as done.

Suggestions from Mark

This revision is now accepted and ready to land.Sep 4 2023, 2:07 PM
This revision was automatically updated to reflect the committed changes.