qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 26/34] hv-scsi: limit the number of requests per


From: Roman Kagan
Subject: [Qemu-devel] [RFC PATCH 26/34] hv-scsi: limit the number of requests per notification
Date: Tue, 6 Feb 2018 23:30:40 +0300

There's a vague feeling that, if there are too many requests in the
incoming ring buffer, processing and replying to them may usurp the
event loop (main thread) and thus induce lags, soft lockups, etc.

So ensure to yield the event loop at most every 1024 requests.

TODO: do something smarter than this
Signed-off-by: Roman Kagan <address@hidden>
---
 hw/scsi/hv-scsi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/scsi/hv-scsi.c b/hw/scsi/hv-scsi.c
index bbfc26bf0a..aa055340ef 100644
--- a/hw/scsi/hv-scsi.c
+++ b/hw/scsi/hv-scsi.c
@@ -294,8 +294,9 @@ static void hv_scsi_handle_packet(HvScsiReq *req)
 static void hv_scsi_notify_cb(VMBusChannel *chan)
 {
     HvScsi *scsi = HV_SCSI(vmbus_channel_device(chan));
+    int i;
 
-    for (;;) {
+    for (i = 1024; i; i--) {
         HvScsiReq *req = vmbus_channel_recv(chan, sizeof(*req));
         if (!req) {
             break;
@@ -304,6 +305,10 @@ static void hv_scsi_notify_cb(VMBusChannel *chan)
         hv_scsi_init_req(scsi, req);
         hv_scsi_handle_packet(req);
     }
+
+    if (!i) {
+        vmbus_notify_channel(chan);
+    }
 }
 
 static void hv_scsi_reset(HvScsi *scsi)
-- 
2.14.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]