dm: virtio-block: support NO_NOTIFY

disable NOTIFY during getting requests from virtqueue. This will improve
the IO performance.

Tracked-On: #7940
Signed-off-by: Conghui <conghui.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Conghui 2022-07-15 22:13:56 +08:00 committed by acrnsi-robot
parent 1bf3cb61f5
commit 7d987f9b0f
1 changed files with 23 additions and 2 deletions

View File

@ -380,8 +380,29 @@ virtio_blk_notify(void *vdev, struct virtio_vq_info *vq)
{
struct virtio_blk *blk = vdev;
while (vq_has_descs(vq))
virtio_blk_proc(blk, vq);
if (!vq_has_descs(vq))
return;
/*
* The two while loop here is to avoid the race:
*
* FE could send a request right after the BE break from internal while loop.
* At that time, FE still not aware the NO_NOTIFY is clear, so send the request
* without notification. This request would be lost.
*
* So, after enable NOTIFY, need to check the queue again to dry the
* requests in virtqueue.
* */
do {
vq->used->flags |= VRING_USED_F_NO_NOTIFY;
mb();
do {
virtio_blk_proc(blk, vq);
} while (vq_has_descs(vq));
vq_clear_used_ring_flags(&blk->base, vq);
mb();
} while (vq_has_descs(vq));
}
static uint64_t