mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-18 10:35:23 +00:00
vhost_user_net: Enable multithreaded multiqueue support
By implementing queues_per_thread(), this patch fills the last missing bit to enable multithreaded multiqueue support for the vhost-user-net backend implementation. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
1a0a2c0182
commit
6565e478e6
@ -215,6 +215,7 @@ pub struct VhostUserNetBackend {
|
|||||||
threads: Vec<Mutex<VhostUserNetThread>>,
|
threads: Vec<Mutex<VhostUserNetThread>>,
|
||||||
num_queues: usize,
|
num_queues: usize,
|
||||||
queue_size: u16,
|
queue_size: u16,
|
||||||
|
queues_per_thread: Vec<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VhostUserNetBackend {
|
impl VhostUserNetBackend {
|
||||||
@ -228,16 +229,19 @@ impl VhostUserNetBackend {
|
|||||||
let mut taps = open_tap(ifname, Some(ip_addr), Some(netmask), num_queues / 2)
|
let mut taps = open_tap(ifname, Some(ip_addr), Some(netmask), num_queues / 2)
|
||||||
.map_err(Error::OpenTap)?;
|
.map_err(Error::OpenTap)?;
|
||||||
|
|
||||||
|
let mut queues_per_thread = Vec::new();
|
||||||
let mut threads = Vec::new();
|
let mut threads = Vec::new();
|
||||||
for tap in taps.drain(..) {
|
for (i, tap) in taps.drain(..).enumerate() {
|
||||||
let thread = Mutex::new(VhostUserNetThread::new(tap)?);
|
let thread = Mutex::new(VhostUserNetThread::new(tap)?);
|
||||||
threads.push(thread);
|
threads.push(thread);
|
||||||
|
queues_per_thread.push(0b11 << (i * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(VhostUserNetBackend {
|
Ok(VhostUserNetBackend {
|
||||||
threads,
|
threads,
|
||||||
num_queues,
|
num_queues,
|
||||||
queue_size,
|
queue_size,
|
||||||
|
queues_per_thread,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,6 +343,10 @@ impl VhostUserBackend for VhostUserNetBackend {
|
|||||||
Some(3),
|
Some(3),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn queues_per_thread(&self) -> Vec<u64> {
|
||||||
|
self.queues_per_thread.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct VhostUserNetBackendConfig<'a> {
|
pub struct VhostUserNetBackendConfig<'a> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user