Skip to content

Commit 493b94b

Browse files
mikechristiemstsirkin
authored andcommitted
vhost: convert poll work to be vq based
This has the drivers pass in their poll to vq mapping and then converts the core poll code to use the vq based helpers. In the next patches we will allow vqs to be handled by different workers, so to allow drivers to execute operations like queue, stop, flush, etc on specific polls/vqs we need to know the mappings. Signed-off-by: Mike Christie <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent a6fc047 commit 493b94b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

drivers/vhost/net.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,10 @@ static int vhost_net_open(struct inode *inode, struct file *f)
13471347
VHOST_NET_PKT_WEIGHT, VHOST_NET_WEIGHT, true,
13481348
NULL);
13491349

1350-
vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev);
1351-
vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev);
1350+
vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev,
1351+
vqs[VHOST_NET_VQ_TX]);
1352+
vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev,
1353+
vqs[VHOST_NET_VQ_RX]);
13521354

13531355
f->private_data = n;
13541356
n->page_frag.page = NULL;

drivers/vhost/vhost.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,15 @@ EXPORT_SYMBOL_GPL(vhost_work_init);
187187

188188
/* Init poll structure */
189189
void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn,
190-
__poll_t mask, struct vhost_dev *dev)
190+
__poll_t mask, struct vhost_dev *dev,
191+
struct vhost_virtqueue *vq)
191192
{
192193
init_waitqueue_func_entry(&poll->wait, vhost_poll_wakeup);
193194
init_poll_funcptr(&poll->table, vhost_poll_func);
194195
poll->mask = mask;
195196
poll->dev = dev;
196197
poll->wqh = NULL;
198+
poll->vq = vq;
197199

198200
vhost_work_init(&poll->work, fn);
199201
}
@@ -297,7 +299,7 @@ EXPORT_SYMBOL_GPL(vhost_vq_has_work);
297299

298300
void vhost_poll_queue(struct vhost_poll *poll)
299301
{
300-
vhost_work_queue(poll->dev, &poll->work);
302+
vhost_vq_work_queue(poll->vq, &poll->work);
301303
}
302304
EXPORT_SYMBOL_GPL(vhost_poll_queue);
303305

@@ -508,7 +510,7 @@ void vhost_dev_init(struct vhost_dev *dev,
508510
vhost_vq_reset(dev, vq);
509511
if (vq->handle_kick)
510512
vhost_poll_init(&vq->poll, vq->handle_kick,
511-
EPOLLIN, dev);
513+
EPOLLIN, dev, vq);
512514
}
513515
}
514516
EXPORT_SYMBOL_GPL(vhost_dev_init);

drivers/vhost/vhost.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ struct vhost_poll {
4141
struct vhost_work work;
4242
__poll_t mask;
4343
struct vhost_dev *dev;
44+
struct vhost_virtqueue *vq;
4445
};
4546

4647
void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn);
4748
bool vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work);
4849

4950
void vhost_poll_init(struct vhost_poll *poll, vhost_work_fn_t fn,
50-
__poll_t mask, struct vhost_dev *dev);
51+
__poll_t mask, struct vhost_dev *dev,
52+
struct vhost_virtqueue *vq);
5153
int vhost_poll_start(struct vhost_poll *poll, struct file *file);
5254
void vhost_poll_stop(struct vhost_poll *poll);
5355
void vhost_poll_queue(struct vhost_poll *poll);

0 commit comments

Comments
 (0)