Patchwork [net-next] macvtap: use prepare_to_wait/finish_wait to ensure mb

login
register
mail settings
Submitter Hong zhi guo
Date June 7, 2012, 8:36 a.m.
Message ID <1339058187-6619-1-git-send-email-honkiko@gmail.com>
Download mbox | patch
Permalink /patch/163524/
State Accepted
Delegated to: David Miller
Headers show

Comments

Hong zhi guo - June 7, 2012, 8:36 a.m.
instead of raw assignment to current->state

Signed-off-by: Hong Zhiguo <honkiko@gmail.com>
---
 drivers/net/macvtap.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
David Miller - June 7, 2012, 8:19 p.m.
From: Hong Zhiguo <honkiko@gmail.com>
Date: Thu,  7 Jun 2012 16:36:27 +0800

> instead of raw assignment to current->state
> 
> Signed-off-by: Hong Zhiguo <honkiko@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 2ee56de..0737bd4 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -847,13 +847,12 @@  static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb,
 			       const struct iovec *iv, unsigned long len,
 			       int noblock)
 {
-	DECLARE_WAITQUEUE(wait, current);
+	DEFINE_WAIT(wait);
 	struct sk_buff *skb;
 	ssize_t ret = 0;
 
-	add_wait_queue(sk_sleep(&q->sk), &wait);
 	while (len) {
-		current->state = TASK_INTERRUPTIBLE;
+		prepare_to_wait(sk_sleep(&q->sk), &wait, TASK_INTERRUPTIBLE);
 
 		/* Read frames from the queue */
 		skb = skb_dequeue(&q->sk.sk_receive_queue);
@@ -875,8 +874,7 @@  static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb,
 		break;
 	}
 
-	current->state = TASK_RUNNING;
-	remove_wait_queue(sk_sleep(&q->sk), &wait);
+	finish_wait(sk_sleep(&q->sk), &wait);
 	return ret;
 }