-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vsock: Move iter
outside of while loop in process_rx_queue
#411
base: main
Are you sure you want to change the base?
Conversation
21620a4
to
8ea683a
Compare
Can we fix also that in this PR? (separate commit) |
Sure. And it is done now. |
6ed15e5
to
6f390a9
Compare
@cutelizebin LGTM but Curiosity: can creating the iterator only at the beginning result in performance losses, since we might not see descriptors added while we are processing others? Please also do a rebase since |
|
771d498
to
698cd1c
Compare
So, at this point, what about adding an external loop where we create the iterator to get the best of both approaches?
Please include that changes in the 2 commits, the warning seems related to that changes, and we prefer to avoid changing code introduced in the same PR. |
They all look good. I'll do the both. |
c7b1df0
to
dc7148c
Compare
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]>
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]>
dc7148c
to
ae31c18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
I left some comments.
I'd also suggest updating the commit descriptions, since we now have 2 nested loops and also tx loop covered.
} else { | ||
queue.iter(mem).unwrap().go_to_previous_position(); | ||
break; | ||
let mut iter_has_elemnt = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iter_has_element
is less cryptic IMHO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for replying. I'll fix these.
PKT_HEADER_SIZE + pkt.len() as usize | ||
} else { | ||
queue.iter(mem).unwrap().go_to_previous_position(); | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have 2 loops nested, IIUC this should exit both loops, so we may need to replace it with a return Ok(used_any)
, or set iter_has_elemnt
to false.
If you prefer the last one, maybe then better to change the name of that variable to something like processing_rx
.
match rx_queue_type { | ||
RxQueueType::Standard => { | ||
if !self.thread_backend.pending_rx() { | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I think the original idea was to stop processing new descriptors, since we don't have any packet to copy in it.
break; | ||
RxQueueType::RawPkts => { | ||
if !self.thread_backend.pending_raw_pkts() { | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
.iter(mem) | ||
.unwrap() | ||
.go_to_previous_position(); | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe also here.
@cutelizebin it's been a long time since this PR has been open. Do you have time to complete it? We'd like to merge it. |
@stefano-garzarella Apologies for being away for so long. I'll address the issues you pointed out next week and ensure I'm caught up with the main branch. And thank you for your patience! |
@cutelizebin don't worry :-) I'm glad you're back to work on this PR! |
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.
Summary of the PR
Please summarize here why the changes in this PR are needed.
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s
), and the commitmessage has max 60 characters for the summary and max 75 characters for each
description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafe
code is properly documented.