Skip to content

Commit 4ef1fd6

Browse files
committed
refactor(iov): remove SmallVec
As we don't create IoVecBuffer(Mut) types at runtime, but reuse existing ones in both virtio-net and virtio-vsock, we don't need to use SmallVec type anymore. With this we remove the type alias. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent de14998 commit 4ef1fd6

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

Cargo.lock

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vmm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ semver = { version = "1.0.23", features = ["serde"] }
3434
serde = { version = "1.0.210", features = ["derive", "rc"] }
3535
serde_json = "1.0.128"
3636
slab = "0.4.7"
37-
smallvec = "1.11.2"
3837
thiserror = "1.0.64"
3938
timerfd = "1.5.0"
4039
userfaultfd = "0.8.1"

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

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::io::ErrorKind;
55

66
use libc::{c_void, iovec, size_t};
7-
use smallvec::SmallVec;
87
use vm_memory::bitmap::Bitmap;
98
use vm_memory::{
109
GuestMemory, GuestMemoryError, ReadVolatile, VolatileMemoryError, VolatileSlice, WriteVolatile,
@@ -25,14 +24,6 @@ pub enum IoVecError {
2524
GuestMemory(#[from] GuestMemoryError),
2625
}
2726

28-
// Using SmallVec in the kani proofs causes kani to use unbounded amounts of memory
29-
// during post-processing, and then crash.
30-
// TODO: remove new-type once kani performance regression are resolved
31-
#[cfg(kani)]
32-
type IoVecVec = Vec<iovec>;
33-
#[cfg(not(kani))]
34-
type IoVecVec = SmallVec<[iovec; 4]>;
35-
3627
/// This is essentially a wrapper of a `Vec<libc::iovec>` which can be passed to `libc::writev`.
3728
///
3829
/// It describes a buffer passed to us by the guest that is scattered across multiple
@@ -41,7 +32,7 @@ type IoVecVec = SmallVec<[iovec; 4]>;
4132
#[derive(Debug, Default)]
4233
pub struct IoVecBuffer {
4334
// container of the memory regions included in this IO vector
44-
vecs: IoVecVec,
35+
vecs: Vec<iovec>,
4536
// Total length of the IoVecBuffer
4637
len: u32,
4738
}
@@ -222,7 +213,7 @@ impl IoVecBuffer {
222213
#[derive(Debug, Default)]
223214
pub struct IoVecBufferMut {
224215
// container of the memory regions included in this IO vector
225-
vecs: IoVecVec,
216+
vecs: Vec<iovec>,
226217
// Total length of the IoVecBufferMut
227218
len: u32,
228219
}
@@ -406,8 +397,7 @@ mod tests {
406397
vecs: vec![iovec {
407398
iov_base: buf.as_ptr() as *mut c_void,
408399
iov_len: buf.len(),
409-
}]
410-
.into(),
400+
}],
411401
len: buf.len().try_into().unwrap(),
412402
}
413403
}
@@ -437,8 +427,7 @@ mod tests {
437427
vecs: vec![iovec {
438428
iov_base: buf.as_mut_ptr().cast::<c_void>(),
439429
iov_len: buf.len(),
440-
}]
441-
.into(),
430+
}],
442431
len: buf.len().try_into().unwrap(),
443432
}
444433
}
@@ -690,7 +679,7 @@ mod verification {
690679
use vm_memory::bitmap::BitmapSlice;
691680
use vm_memory::VolatileSlice;
692681

693-
use super::{IoVecBuffer, IoVecBufferMut, IoVecVec};
682+
use super::{IoVecBuffer, IoVecBufferMut};
694683

695684
// Maximum memory size to use for our buffers. For the time being 1KB.
696685
const GUEST_MEMORY_SIZE: usize = 1 << 10;
@@ -702,7 +691,7 @@ mod verification {
702691
// >= 1.
703692
const MAX_DESC_LENGTH: usize = 4;
704693

705-
fn create_iovecs(mem: *mut u8, size: usize, nr_descs: usize) -> (IoVecVec, u32) {
694+
fn create_iovecs(mem: *mut u8, size: usize, nr_descs: usize) -> (Vec<iovec>, u32) {
706695
let mut vecs: Vec<iovec> = Vec::with_capacity(nr_descs);
707696
let mut len = 0u32;
708697
for _ in 0..nr_descs {

0 commit comments

Comments
 (0)