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)
Tue, May 28, 3:37 AM
Unknown Object (File)
Apr 18 2024, 4:25 PM
Unknown Object (File)
Jan 27 2024, 12:33 PM
Unknown Object (File)
Jan 27 2024, 12:33 PM
Unknown Object (File)
Jan 27 2024, 12:33 PM
Unknown Object (File)
Jan 27 2024, 12:33 PM
Unknown Object (File)
Jan 26 2024, 8:43 PM
Unknown Object (File)
Dec 25 2023, 5:19 PM
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.