-
Notifications
You must be signed in to change notification settings - Fork 31
nvme: CQ db_buf EventIdx should slightly lag CQ tail #1026
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
base: master
Are you sure you want to change the base?
Conversation
Doorbell buffers want the CQ event index to roughly track with the tail, because most CQ doorbells are not interesting. If there are ten CQ entries, space for 54 more, and the guest has acknowledged one, we don't really care anything happened. If there are 64 CQ entries, 0 available, and one SQ entry that we're notified for, we'll try to reserve space in a full CQ, see it's at capacity, and the SQ will idle with the CQ aware that that SQ is corked. Without doorbell buffers, at some point the guest will process a CQE, ring a CQ doorbell, uncork the CQ, and we'll nudge the parked SQ worker thread into operation again. With doorbell buffers, if the event index matches the CQ tail we'll never get a doorbell when the CQ has been drained. If the guest never submits another I/O on the corked SQ, the pending I/O may never get processed. A more careful treatment would only have the event index lag if we are at risk of having a worker thread defer an I/O because this CQ would be full. This would look something like not letting EventIdx advance so far forward that there is less than one entry available for each SQ pointed at this CQ. Eating the unnecessary doorbell cost at least gets doorbell buffers correct in this case and we can turn it back on. The more careful treatment of EventIdx can come later.
This reverts commit d6cd957.
hawkw
left a comment
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.
looks good to me, though you may want a look from someone who knows more about the NVMe standard than I do.
3c8e3a4 to
9484c10
Compare
luqmana
left a comment
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.
Nice find!
dancrossnyc
left a comment
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.
Nice.
Might be worth recording that in the source commentary for future-you (or someone else). It seems like implementing that wouldn't be too onerous at some point down the line, and would get things back to nearly full elision. |
Doorbell buffers want the CQ event index to roughly track with the tail,
because most CQ doorbells are not interesting. If there are ten CQ
entries, space for 54 more, and the guest has acknowledged one, we don't
really care anything happened.
If there are 64 CQ entries, 0 available, and one SQ entry that we're
notified for, we'll try to reserve space in a full CQ, see it's at
capacity, and the SQ will idle with the CQ aware that that SQ is corked.
Without doorbell buffers, at some point the guest will process a CQE,
ring a CQ doorbell, uncork the CQ, and we'll nudge the parked SQ worker
thread into operation again.
With doorbell buffers, if the event index matches the CQ tail we'll
never get a doorbell when the CQ has been drained. If the guest never
submits another I/O on the corked SQ, the pending I/O may never get
processed.
A more careful treatment would only have the event index lag if we are
at risk of having a worker thread defer an I/O because this CQ would be
full. This would look something like not letting EventIdx advance so far
forward that there is less than one entry available for each SQ pointed
at this CQ.
Eating the unnecessary doorbell cost at least gets doorbell buffers
correct in this case and we can turn it back on. The more careful
treatment of EventIdx can come later.