Skip to content

Commit

Permalink
vsock: Move iter outside of loop in process_tx_queue.
Browse files Browse the repository at this point in the history
the iter() function is used for produce a queue iterator to iterate over the descriptors.

But usually, it shouldn't be in the while loop, which might brings more unnecessary overhead.

So move iter outside of the while loop.

Signed-off-by: Li Zebin <[email protected]>
  • Loading branch information
cutelizebin committed Aug 2, 2023
1 parent 36a3f99 commit 00297f8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions crates/vsock/src/vhu_vsock_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,15 @@ impl VhostUserVsockThread {
None => return Err(Error::NoMemoryConfigured),
};

while let Some(mut avail_desc) = vring
.get_mut()
.get_queue_mut()
let mut vring_mut = vring.get_mut();

let queue = vring_mut.get_queue_mut();

let mut queue_iter = queue
.iter(atomic_mem.memory())
.map_err(|_| Error::IterateQueue)?
.next()
{
.map_err(|_| Error::IterateQueue)?;

while let Some(mut avail_desc) = queue_iter.next() {
used_any = true;
let mem = atomic_mem.clone().memory();

Expand Down

0 comments on commit 00297f8

Please sign in to comment.