Skip to content

Commit c145abf

Browse files
committed
refactor(virtio-net): avoid copy on rx
Improve virtio-net performance by directly read into desc chain; introduce Readiness management to avoid redundant readv and make code more readable. Signed-off-by: ihciah <[email protected]>
1 parent abe5a89 commit c145abf

File tree

5 files changed

+516
-461
lines changed

5 files changed

+516
-461
lines changed

resources/seccomp/aarch64-unknown-linux-musl.json

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
{
2626
"syscall": "read"
2727
},
28+
{
29+
"syscall": "readv",
30+
"comment": "Used by the VirtIO net device to read from tap"
31+
},
2832
{
2933
"syscall": "write"
3034
},

resources/seccomp/x86_64-unknown-linux-musl.json

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
{
2626
"syscall": "read"
2727
},
28+
{
29+
"syscall": "readv",
30+
"comment": "Used by the VirtIO net device to read from tap"
31+
},
2832
{
2933
"syscall": "write"
3034
},

src/vmm/src/devices/virtio/iovec.rs

+17
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,23 @@ impl IoVecBufferMut {
327327
self.len = 0u32;
328328
}
329329

330+
/// Push an iovec into the `IoVecBufferMut`.
331+
/// # Safety
332+
/// The iovec must refer to a valid memory slice.
333+
pub unsafe fn push(&mut self, iovec: iovec) -> Result<(), IoVecError> {
334+
let iov_len = iovec
335+
.iov_len
336+
.try_into()
337+
.map_err(|_| IoVecError::OverflowedDescriptor)?;
338+
339+
self.vecs.push(iovec);
340+
self.len = self
341+
.len
342+
.checked_add(iov_len)
343+
.ok_or(IoVecError::OverflowedDescriptor)?;
344+
Ok(())
345+
}
346+
330347
/// Writes a number of bytes into the `IoVecBufferMut` starting at a given offset.
331348
///
332349
/// This will try to fill `IoVecBufferMut` writing bytes from the `buf` starting from

0 commit comments

Comments
 (0)