aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjiangyiwen <jiangyiwen@huawei.com>2018-07-19 03:17:00 -0400
committerDominique Martinet <dominique.martinet@cea.fr>2018-08-12 20:34:58 -0400
commit31934da810365f603dec5a67e690e00cf900fc73 (patch)
tree634da305fd1364db1b0dc838cb37b908cb870944
parentc7ebbae7cf9c50253a978f25d72d16e012bd46f1 (diff)
net/9p/virtio: Fix hard lockup in req_done
When client has multiple threads that issue io requests all the time, and the server has a very good performance, it may cause cpu is running in the irq context for a long time because it can check virtqueue has buf in the *while* loop. So we should keep chan->lock in the whole loop. [ Dominique: reworded subject line ] Link: http://lkml.kernel.org/r/5B503AEC.5080404@huawei.com Signed-off-by: Yiwen Jiang <jiangyiwen@huawei.com> To: Andrew Morton <akpm@linux-foundation.org> To: Eric Van Hensbergen <ericvh@gmail.com> To: Ron Minnich <rminnich@sandia.gov> To: Latchesar Ionkov <lucho@ionkov.net> Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
-rw-r--r--net/9p/trans_virtio.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index c5464ec311fe..d422bfc81eca 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -144,24 +144,25 @@ static void req_done(struct virtqueue *vq)
144 struct virtio_chan *chan = vq->vdev->priv; 144 struct virtio_chan *chan = vq->vdev->priv;
145 unsigned int len; 145 unsigned int len;
146 struct p9_req_t *req; 146 struct p9_req_t *req;
147 bool need_wakeup = false;
147 unsigned long flags; 148 unsigned long flags;
148 149
149 p9_debug(P9_DEBUG_TRANS, ": request done\n"); 150 p9_debug(P9_DEBUG_TRANS, ": request done\n");
150 151
151 while (1) { 152 spin_lock_irqsave(&chan->lock, flags);
152 spin_lock_irqsave(&chan->lock, flags); 153 while ((req = virtqueue_get_buf(chan->vq, &len)) != NULL) {
153 req = virtqueue_get_buf(chan->vq, &len); 154 if (!chan->ring_bufs_avail) {
154 if (req == NULL) { 155 chan->ring_bufs_avail = 1;
155 spin_unlock_irqrestore(&chan->lock, flags); 156 need_wakeup = true;
156 break;
157 } 157 }
158 chan->ring_bufs_avail = 1; 158
159 spin_unlock_irqrestore(&chan->lock, flags);
160 /* Wakeup if anyone waiting for VirtIO ring space. */
161 wake_up(chan->vc_wq);
162 if (len) 159 if (len)
163 p9_client_cb(chan->client, req, REQ_STATUS_RCVD); 160 p9_client_cb(chan->client, req, REQ_STATUS_RCVD);
164 } 161 }
162 spin_unlock_irqrestore(&chan->lock, flags);
163 /* Wakeup if anyone waiting for VirtIO ring space. */
164 if (need_wakeup)
165 wake_up(chan->vc_wq);
165} 166}
166 167
167/** 168/**