vhost: Add polling mode
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 vhost: Add polling mode
Resubmitting the patch in: http://marc.info/?l=kvm&m=140594903520308&w=2
after fixing the whitespaces issues.
Thank you,
Razya
Quoted 1 line
From
f293e470b36ff9eb4910540c620315c418e4a8fcMon Sep 17 00:00:00 2001
From: Razya Ladelsky <[email protected]>
Date: Thu, 31 Jul 2014 09:47:20 +0300
Subject: [PATCH] vhost: Add polling mode
Add an optional polling mode to continuously poll the virtqueues for new buffers, and avoid asking the guest to kick us.
--- drivers/vhost/net.c | 6 +- drivers/vhost/scsi.c | 6 +- drivers/vhost/vhost.c | 245 +++++++++++++++++++++++++++++++++++++++++++++++-- drivers/vhost/vhost.h | 38 +++++++- 4 files changed, 277 insertions(+), 18 deletions(-)
drivers/vhost/net.c +4 -2
@@ -742,8 +742,10 @@ static int vhost_net_open(struct inode *inode, struct file *f) }vhost_dev_init (dev, vqs,VHOST_NET_VQ_MAX ); -vhost_poll_init (n->poll +VHOST_NET_VQ_TX , handle_tx_net,POLLOUT , dev); -vhost_poll_init (n->poll +VHOST_NET_VQ_RX , handle_rx_net,POLLIN , dev); +vhost_poll_init (n->poll +VHOST_NET_VQ_TX , handle_tx_net,POLLOUT , + vqs[VHOST_NET_VQ_TX ]); +vhost_poll_init (n->poll +VHOST_NET_VQ_RX , handle_rx_net,POLLIN , + vqs[VHOST_NET_VQ_RX ]); f->private_data = n;
drivers/vhost/scsi.c +3 -3
@@ -1528,9 +1528,9 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)if (!vqs) goto err_vqs; -vhost_work_init (&vs->vs_completion_work, vhost_scsi_complete_cmd_work); -vhost_work_init (&vs->vs_event_work, tcm_vhost_evt_work); - +vhost_work_init (&vs->vs_completion_work,NULL , + vhost_scsi_complete_cmd_work); +vhost_work_init (&vs->vs_event_work,NULL , tcm_vhost_evt_work); vs->vs_events_nr =0 ; vs->vs_events_missed = false;
drivers/vhost/vhost.c +236 -9
340 lines not on this page · raw message
drivers/vhost/vhost.h +34 -4
@@ -24,6 +24,7 @@ struct vhost_work {int flushing;unsigned queue_seq;unsigned done_seq; +struct vhost_virtqueue *vq; };/* Poll a file (eventfd or socket) */
@@ -37,11 +38,12 @@ struct vhost_poll {struct vhost_dev *dev; }; -void vhost_work_init (struct vhost_work *work,vhost_work_fn_t fn); +void vhost_work_init (struct vhost_work *work,struct vhost_virtqueue *vq, +vhost_work_fn_t fn);void vhost_work_queue (struct vhost_dev *dev,struct vhost_work *work);void vhost_poll_init (struct vhost_poll *poll,vhost_work_fn_t fn, -unsigned long mask,struct vhost_dev *dev); +unsigned long mask,struct vhost_virtqueue *vq);int vhost_poll_start (struct vhost_poll *poll,struct file *file);void vhost_poll_stop (struct vhost_poll *poll);void vhost_poll_flush (struct vhost_poll *poll);
@@ -54,8 +56,6 @@ struct vhost_log {u64 len; }; -struct vhost_virtqueue ; -/* The virtqueue structure describes a queue attached to a device. */ struct vhost_virtqueue {struct vhost_dev *dev;
@@ -110,6 +110,35 @@ struct vhost_virtqueue {/* Log write descriptors */ void __user *log_base;struct vhost_log *log; +struct { +/* When a virtqueue is in vqpoll.enabled mode, it declares +* that instead of using guest notifications (kicks) to +* discover new work, we prefer to continuously poll this +* virtqueue in the worker thread. +* If !enabled, the rest of the fields below are undefined. +*/ +bool enabled; +/* vqpoll.enabled doesn't always mean that this virtqueue is +* actually being polled: The backend (e.g., net.c) may +* temporarily disable it using vhost_disable/enable_notify(). +* vqpoll.link is used to maintain the thread's round-robin +* list of virtqueues that actually need to be polled. +* Note list_empty(link) means this virtqueue isn't polled. +*/ +struct list_head link; +/* If this flag is true, the virtqueue is being shut down, +* so vqpoll should not be re-enabled. +*/ +bool shutdown; +/* Various counters used to decide when to enter polling mode +* or leave it and return to notification mode. +*/ +unsigned long jiffies_last_kick; +unsigned long jiffies_last_work; +int work_this_jiffy; +struct page *avail_page; +volatile struct vring_avail *avail_mapped; + } vqpoll; };struct vhost_dev {
@@ -123,6 +152,7 @@ struct vhost_dev {spinlock_t work_lock;struct list_head work_list;struct task_struct *worker; +struct list_head vqpoll_list; };void vhost_dev_init (struct vhost_dev *,struct vhost_virtqueue **vqs,int nvqs);
Signature · 1 line
1.7.9.5
Michael S. Tsirkin
maintainerQuoted 6 lines · Razya Ladelsky
Resubmitting the patch in: http://marc.info/?l=kvm&m=140594903520308&w=2
after fixing the whitespaces issues.
Thank you,
RazyaQuoted 1 line
From
f293e470b36ff9eb4910540c620315c418e4a8fcMon Sep 17 00:00:00 2001
Above should come after --- below so git will ignore it.
Quoted 8 lines
From: Razya Ladelsky <[email protected]>
Date: Thu, 31 Jul 2014 09:47:20 +0300
Subject: [PATCH] vhost: Add polling modeAdd an optional polling mode to continuously poll the virtqueues for new buffers, and avoid asking the guest to kick us.
Signed-off-by Razya Ladelsky <[email protected]>
Pls include performance data with the submission next time.
Quoted 6 lines
--- drivers/vhost/net.c | 6 +- drivers/vhost/scsi.c | 6 +- drivers/vhost/vhost.c | 245 +++++++++++++++++++++++++++++++++++++++++++++++-- drivers/vhost/vhost.h | 38 +++++++- 4 files changed, 277 insertions(+), 18 deletions(-)
Please resubmit, copying all maintainer addresses for vhost. Get them from MAINTAINERS.
Signature · 1 line
MST