Skip to content

Commit 5a18ede

Browse files
ShadowCursebchalios
authored andcommitted
feat(virtio-net): increase max queue size to 512
Increase of the queue size helps with keeping both vmm thread and guest busy at high network load and improves performance. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent d65b1f4 commit 5a18ede

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/vmm/src/devices/virtio/net/device.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use libc::{iovec, EAGAIN};
1414
use log::error;
1515
use vmm_sys_util::eventfd::EventFd;
1616

17+
use super::NET_QUEUE_MAX_SIZE;
1718
use crate::devices::virtio::device::{DeviceState, IrqTrigger, IrqType, VirtioDevice};
1819
use crate::devices::virtio::gen::virtio_blk::VIRTIO_F_VERSION_1;
1920
use crate::devices::virtio::gen::virtio_net::{
@@ -104,7 +105,7 @@ pub struct RxBuffers {
104105
pub min_buffer_size: u32,
105106
// An [`IoVecBufferMut`] covering all the memory we have available for receiving network
106107
// frames.
107-
pub iovec: IoVecBufferMut,
108+
pub iovec: IoVecBufferMut<NET_QUEUE_MAX_SIZE>,
108109
// A map of which part of the memory belongs to which `DescriptorChain` object
109110
pub parsed_descriptors: VecDeque<ParsedDescriptorChain>,
110111
// Buffers that we have used and they are ready to be given back to the guest.

src/vmm/src/devices/virtio/net/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
66
use std::io;
77

8-
use crate::devices::virtio::queue::FIRECRACKER_MAX_QUEUE_SIZE;
9-
8+
/// Maximum size of the queue for network device.
9+
pub const NET_QUEUE_MAX_SIZE: u16 = 512;
1010
/// Maximum size of the frame buffers handled by this device.
1111
pub const MAX_BUFFER_SIZE: usize = 65562;
1212
/// The number of queues of the network device.
1313
pub const NET_NUM_QUEUES: usize = 2;
14-
pub const NET_QUEUE_SIZES: [u16; NET_NUM_QUEUES] = [FIRECRACKER_MAX_QUEUE_SIZE; NET_NUM_QUEUES];
14+
pub const NET_QUEUE_SIZES: [u16; NET_NUM_QUEUES] = [NET_QUEUE_MAX_SIZE; NET_NUM_QUEUES];
1515
/// The index of the rx queue from Net device queues/queues_evts vector.
1616
pub const RX_INDEX: usize = 0;
1717
/// The index of the tx queue from Net device queues/queues_evts vector.

src/vmm/src/devices/virtio/net/persist.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ use std::sync::{Arc, Mutex};
1010
use serde::{Deserialize, Serialize};
1111

1212
use super::device::{Net, RxBuffers};
13-
use super::{TapError, NET_NUM_QUEUES, RX_INDEX};
13+
use super::{TapError, NET_NUM_QUEUES, NET_QUEUE_MAX_SIZE, RX_INDEX};
1414
use crate::devices::virtio::device::DeviceState;
1515
use crate::devices::virtio::persist::{PersistError as VirtioStateError, VirtioDeviceState};
16-
use crate::devices::virtio::queue::FIRECRACKER_MAX_QUEUE_SIZE;
1716
use crate::devices::virtio::TYPE_NET;
1817
use crate::mmds::data_store::Mmds;
1918
use crate::mmds::ns::MmdsNetworkStack;
@@ -147,7 +146,7 @@ impl Persist<'_> for Net {
147146
&constructor_args.mem,
148147
TYPE_NET,
149148
NET_NUM_QUEUES,
150-
FIRECRACKER_MAX_QUEUE_SIZE,
149+
NET_QUEUE_MAX_SIZE,
151150
)?;
152151
net.irq_trigger.irq_status = Arc::new(AtomicU32::new(state.virtio_state.interrupt_status));
153152
net.avail_features = state.virtio_state.avail_features;

0 commit comments

Comments
 (0)