Commit 9c4df090 authored by Stefano Garzarella's avatar Stefano Garzarella Committed by Michael S. Tsirkin

vdpa_sim_blk: limit the number of request handled per batch

Limit the number of requests (4 per queue as for vdpa_sim_net) handled
in a batch to prevent the worker from using the CPU for too long.
Suggested-by: default avatarEugenio Pérez <eperezma@redhat.com>
Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Message-Id: <20220630153221.83371-3-sgarzare@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
parent 42a84c09
...@@ -197,6 +197,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim, ...@@ -197,6 +197,7 @@ static bool vdpasim_blk_handle_req(struct vdpasim *vdpasim,
static void vdpasim_blk_work(struct work_struct *work) static void vdpasim_blk_work(struct work_struct *work)
{ {
struct vdpasim *vdpasim = container_of(work, struct vdpasim, work); struct vdpasim *vdpasim = container_of(work, struct vdpasim, work);
bool reschedule = false;
int i; int i;
spin_lock(&vdpasim->lock); spin_lock(&vdpasim->lock);
...@@ -206,6 +207,7 @@ static void vdpasim_blk_work(struct work_struct *work) ...@@ -206,6 +207,7 @@ static void vdpasim_blk_work(struct work_struct *work)
for (i = 0; i < VDPASIM_BLK_VQ_NUM; i++) { for (i = 0; i < VDPASIM_BLK_VQ_NUM; i++) {
struct vdpasim_virtqueue *vq = &vdpasim->vqs[i]; struct vdpasim_virtqueue *vq = &vdpasim->vqs[i];
int reqs = 0;
if (!vq->ready) if (!vq->ready)
continue; continue;
...@@ -218,10 +220,18 @@ static void vdpasim_blk_work(struct work_struct *work) ...@@ -218,10 +220,18 @@ static void vdpasim_blk_work(struct work_struct *work)
if (vringh_need_notify_iotlb(&vq->vring) > 0) if (vringh_need_notify_iotlb(&vq->vring) > 0)
vringh_notify(&vq->vring); vringh_notify(&vq->vring);
local_bh_enable(); local_bh_enable();
if (++reqs > 4) {
reschedule = true;
break;
}
} }
} }
out: out:
spin_unlock(&vdpasim->lock); spin_unlock(&vdpasim->lock);
if (reschedule)
schedule_work(&vdpasim->work);
} }
static void vdpasim_blk_get_config(struct vdpasim *vdpasim, void *config) static void vdpasim_blk_get_config(struct vdpasim *vdpasim, void *config)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment