Skip to content

Commit 9784df1

Browse files
mikechristiemstsirkin
authored andcommitted
vhost, vhost_net: add helper to check if vq has work
In the next patches each vq might have different workers so one could have work but others do not. For net, we only want to check specific vqs, so this adds a helper to check if a vq has work pending and converts vhost-net to use it. Signed-off-by: Mike Christie <michael.christie@oracle.com> Acked-by: Jason Wang <jasowang@redhat.com> Message-Id: <20230626232307.97930-5-michael.christie@oracle.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 737bdb6 commit 9784df1

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

drivers/vhost/net.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static void vhost_net_busy_poll(struct vhost_net *net,
546546
endtime = busy_clock() + busyloop_timeout;
547547

548548
while (vhost_can_busy_poll(endtime)) {
549-
if (vhost_has_work(&net->dev)) {
549+
if (vhost_vq_has_work(vq)) {
550550
*busyloop_intr = true;
551551
break;
552552
}

drivers/vhost/vhost.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ bool vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
266266
EXPORT_SYMBOL_GPL(vhost_work_queue);
267267

268268
/* A lockless hint for busy polling code to exit the loop */
269-
bool vhost_has_work(struct vhost_dev *dev)
269+
bool vhost_vq_has_work(struct vhost_virtqueue *vq)
270270
{
271-
return !llist_empty(&dev->worker->work_list);
271+
return !llist_empty(&vq->worker->work_list);
272272
}
273-
EXPORT_SYMBOL_GPL(vhost_has_work);
273+
EXPORT_SYMBOL_GPL(vhost_vq_has_work);
274274

275275
void vhost_poll_queue(struct vhost_poll *poll)
276276
{

drivers/vhost/vhost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ struct vhost_poll {
4545

4646
void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn);
4747
bool vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work);
48-
bool vhost_has_work(struct vhost_dev *dev);
4948

5049
void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn,
5150
__poll_t mask, struct vhost_dev *dev);
@@ -199,6 +198,7 @@ int vhost_get_vq_desc(struct vhost_virtqueue *,
199198
struct vhost_log *log, unsigned int *log_num);
200199
void vhost_discard_vq_desc(struct vhost_virtqueue *, int n);
201200

201+
bool vhost_vq_has_work(struct vhost_virtqueue *vq);
202202
bool vhost_vq_is_setup(struct vhost_virtqueue *vq);
203203
int vhost_vq_init_access(struct vhost_virtqueue *);
204204
int vhost_add_used(struct vhost_virtqueue *, unsigned int head, int len);

0 commit comments

Comments
 (0)