Skip to content

Commit 21620a4

Browse files
committed
vsock: Move iter outside of the loop in process_rx_queue
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]>
1 parent 637969d commit 21620a4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/vsock/src/vhu_vsock_thread.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,11 @@ impl VhostUserVsockThread {
453453

454454
let queue = vring_mut.get_queue_mut();
455455

456-
while let Some(mut avail_desc) = queue
456+
let mut queue_iter = queue
457457
.iter(atomic_mem.memory())
458-
.map_err(|_| Error::IterateQueue)?
459-
.next()
460-
{
458+
.map_err(|_| Error::IterateQueue)?;
459+
460+
for mut avail_desc in queue_iter {
461461
used_any = true;
462462
let mem = atomic_mem.clone().memory();
463463

0 commit comments

Comments
 (0)