Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6ed15e5

Browse files
committedJul 31, 2023
vsock: Move iter outside of while loop in process_tx_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. Signed-off-by: Li Zebin <cutelizebin@gmail.com>
1 parent 8ea683a commit 6ed15e5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
 

‎crates/vsock/src/vhu_vsock_thread.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -607,13 +607,15 @@ impl VhostUserVsockThread {
607607
None => return Err(Error::NoMemoryConfigured),
608608
};
609609

610-
while let Some(mut avail_desc) = vring
611-
.get_mut()
612-
.get_queue_mut()
610+
let mut vring_mut = vring.get_mut();
611+
612+
let queue = vring_mut.get_queue_mut();
613+
614+
let mut queue_iter = queue
613615
.iter(atomic_mem.memory())
614-
.map_err(|_| Error::IterateQueue)?
615-
.next()
616-
{
616+
.map_err(|_| Error::IterateQueue)?;
617+
618+
while let Some(mut avail_desc) = queue_iter.next() {
617619
used_any = true;
618620
let mem = atomic_mem.clone().memory();
619621

0 commit comments

Comments
 (0)
Please sign in to comment.