Skip to content

Commit

Permalink
vsock: Move iter outside of the loop in process_rx_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.

And the process_tx_queue has the same problem, maybe we can fix it, too.

Signed-off-by: Li Zebin <[email protected]>
  • Loading branch information
cutelizebin committed Jul 29, 2023
1 parent 637969d commit 8ea683a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/vsock/src/vhu_vsock_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,11 @@ impl VhostUserVsockThread {

let queue = vring_mut.get_queue_mut();

while let Some(mut avail_desc) = queue
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 8ea683a

Please sign in to comment.