mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Use SmallVec for descriptor chains
Rather than instantiating a vector for parsing the descriptor chain in advance instead use a SmallVec bounded by the expected length of the descriptor chain. This removes vector allocations from those paths. As smallvec was already a block dependency move it to a workspace dependency and use it from there. Fixes: #5079 Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
@@ -15,6 +15,7 @@ use event_monitor::event;
|
||||
use log::{error, info, warn};
|
||||
use seccompiler::SeccompAction;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use smallvec::SmallVec;
|
||||
use thiserror::Error;
|
||||
use virtio_queue::{Queue, QueueT};
|
||||
use vm_memory::{Bytes, GuestAddressSpace, GuestMemoryAtomic};
|
||||
@@ -66,7 +67,7 @@ impl RngEpollHandler {
|
||||
// Validate the entire descriptor chain upfront so we never
|
||||
// partially fill buffers for a chain that turns out to be
|
||||
// invalid.
|
||||
let descs: Vec<_> = desc_chain
|
||||
let descs: SmallVec<[_; 4]> = desc_chain
|
||||
.checked_iter(self.access_platform.as_deref())
|
||||
.collect::<Result<_, _>>()
|
||||
.unwrap_or_default();
|
||||
|
||||
Reference in New Issue
Block a user