[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
- Re: [Qemu-devel] [RFC PATCH 19/34] vmbus: add vmbus protocol definitions, (continued)
- [Qemu-devel] [RFC PATCH 23/34] i386: en/disable vmbus by a machine property, Roman Kagan, 2018/02/06
- [Qemu-devel] [RFC PATCH 26/34] hv-scsi: limit the number of requests per notification,
Roman Kagan <=
- [Qemu-devel] [RFC PATCH 24/34] scsi: add Hyper-V/VMBus SCSI protocol definitions, Roman Kagan, 2018/02/06
- [Qemu-devel] [RFC PATCH 20/34] vmbus: vmbus implementation, Roman Kagan, 2018/02/06
- [Qemu-devel] [RFC PATCH 25/34] scsi: add Hyper-V/VMBus SCSI controller, Roman Kagan, 2018/02/06
- [Qemu-devel] [RFC PATCH 27/34] tests: hv-scsi: add start-stop test, Roman Kagan, 2018/02/06