devices: virtio: improve the comment on a memory fence in Queue::peek

Improve the comment on why a fence is necessary in the middle of
`Queue::peek` so that it gets clearer.

BUG=b:258630435
TEST=`./tools/dev_container ./tools/presubmit` passed

Change-Id: I63f80975e6d04665948a6036998e7ed6e24be64c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4045661
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
Takaya Saeki 2022-11-22 11:59:38 +09:00 committed by crosvm LUCI
parent 59530f1e1a
commit 984a2f7c8b

View file

@ -628,7 +628,9 @@ impl Queue {
return None;
}
// so that following read from the descriptor doesn't pass get_avail_index
// This fence ensures that subsequent reads from the descriptor do not
// get reordered and happen only after fetching the available_index and
// checking that there is a slot available.
fence(Ordering::SeqCst);
let desc_idx_addr_offset = 4 + (u64::from(self.next_avail.0 % queue_size) * 2);