aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2010-10-06 09:34:45 -0400
committerMichael S. Tsirkin <mst@redhat.com>2010-11-04 07:22:11 -0400
commit64e1c80748afca3b4818ebb232a9668bf529886d (patch)
tree80f0be16eaed7b4561c54e3f4a26138848b816f4
parent533a19b4b88fcf81da3106b94f0ac4ac8b33a248 (diff)
vhost-net: batch use/unuse mm
Move use/unuse mm to vhost.c which makes it possible to batch these operations. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--drivers/vhost/net.c7
-rw-r--r--drivers/vhost/vhost.c7
2 files changed, 6 insertions, 8 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 4b4da5b86ff9..d10da280fa0f 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -10,7 +10,6 @@
10#include <linux/eventfd.h> 10#include <linux/eventfd.h>
11#include <linux/vhost.h> 11#include <linux/vhost.h>
12#include <linux/virtio_net.h> 12#include <linux/virtio_net.h>
13#include <linux/mmu_context.h>
14#include <linux/miscdevice.h> 13#include <linux/miscdevice.h>
15#include <linux/module.h> 14#include <linux/module.h>
16#include <linux/mutex.h> 15#include <linux/mutex.h>
@@ -142,7 +141,6 @@ static void handle_tx(struct vhost_net *net)
142 return; 141 return;
143 } 142 }
144 143
145 use_mm(net->dev.mm);
146 mutex_lock(&vq->mutex); 144 mutex_lock(&vq->mutex);
147 vhost_disable_notify(vq); 145 vhost_disable_notify(vq);
148 146
@@ -207,7 +205,6 @@ static void handle_tx(struct vhost_net *net)
207 } 205 }
208 206
209 mutex_unlock(&vq->mutex); 207 mutex_unlock(&vq->mutex);
210 unuse_mm(net->dev.mm);
211} 208}
212 209
213static int peek_head_len(struct sock *sk) 210static int peek_head_len(struct sock *sk)
@@ -312,7 +309,6 @@ static void handle_rx_big(struct vhost_net *net)
312 if (!sock || skb_queue_empty(&sock->sk->sk_receive_queue)) 309 if (!sock || skb_queue_empty(&sock->sk->sk_receive_queue))
313 return; 310 return;
314 311
315 use_mm(net->dev.mm);
316 mutex_lock(&vq->mutex); 312 mutex_lock(&vq->mutex);
317 vhost_disable_notify(vq); 313 vhost_disable_notify(vq);
318 hdr_size = vq->vhost_hlen; 314 hdr_size = vq->vhost_hlen;
@@ -391,7 +387,6 @@ static void handle_rx_big(struct vhost_net *net)
391 } 387 }
392 388
393 mutex_unlock(&vq->mutex); 389 mutex_unlock(&vq->mutex);
394 unuse_mm(net->dev.mm);
395} 390}
396 391
397/* Expects to be always run from workqueue - which acts as 392/* Expects to be always run from workqueue - which acts as
@@ -423,7 +418,6 @@ static void handle_rx_mergeable(struct vhost_net *net)
423 if (!sock || skb_queue_empty(&sock->sk->sk_receive_queue)) 418 if (!sock || skb_queue_empty(&sock->sk->sk_receive_queue))
424 return; 419 return;
425 420
426 use_mm(net->dev.mm);
427 mutex_lock(&vq->mutex); 421 mutex_lock(&vq->mutex);
428 vhost_disable_notify(vq); 422 vhost_disable_notify(vq);
429 vhost_hlen = vq->vhost_hlen; 423 vhost_hlen = vq->vhost_hlen;
@@ -500,7 +494,6 @@ static void handle_rx_mergeable(struct vhost_net *net)
500 } 494 }
501 495
502 mutex_unlock(&vq->mutex); 496 mutex_unlock(&vq->mutex);
503 unuse_mm(net->dev.mm);
504} 497}
505 498
506static void handle_rx(struct vhost_net *net) 499static void handle_rx(struct vhost_net *net)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 9920bae6ee43..c17c881e235a 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -15,6 +15,7 @@
15#include <linux/vhost.h> 15#include <linux/vhost.h>
16#include <linux/virtio_net.h> 16#include <linux/virtio_net.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/mmu_context.h>
18#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
19#include <linux/mutex.h> 20#include <linux/mutex.h>
20#include <linux/rcupdate.h> 21#include <linux/rcupdate.h>
@@ -177,6 +178,8 @@ static int vhost_worker(void *data)
177 struct vhost_work *work = NULL; 178 struct vhost_work *work = NULL;
178 unsigned uninitialized_var(seq); 179 unsigned uninitialized_var(seq);
179 180
181 use_mm(dev->mm);
182
180 for (;;) { 183 for (;;) {
181 /* mb paired w/ kthread_stop */ 184 /* mb paired w/ kthread_stop */
182 set_current_state(TASK_INTERRUPTIBLE); 185 set_current_state(TASK_INTERRUPTIBLE);
@@ -191,7 +194,7 @@ static int vhost_worker(void *data)
191 if (kthread_should_stop()) { 194 if (kthread_should_stop()) {
192 spin_unlock_irq(&dev->work_lock); 195 spin_unlock_irq(&dev->work_lock);
193 __set_current_state(TASK_RUNNING); 196 __set_current_state(TASK_RUNNING);
194 return 0; 197 break;
195 } 198 }
196 if (!list_empty(&dev->work_list)) { 199 if (!list_empty(&dev->work_list)) {
197 work = list_first_entry(&dev->work_list, 200 work = list_first_entry(&dev->work_list,
@@ -209,6 +212,8 @@ static int vhost_worker(void *data)
209 schedule(); 212 schedule();
210 213
211 } 214 }
215 unuse_mm(dev->mm);
216 return 0;
212} 217}
213 218
214/* Helper to allocate iovec buffers for all vqs. */ 219/* Helper to allocate iovec buffers for all vqs. */