From patchwork Tue Feb 6 20:30:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10204153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DBE8560247 for ; Tue, 6 Feb 2018 21:22:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF2A228B9F for ; Tue, 6 Feb 2018 21:22:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC98F28BBD; Tue, 6 Feb 2018 21:22:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 381D228B17 for ; Tue, 6 Feb 2018 21:22:29 +0000 (UTC) Received: from localhost ([::1]:35649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejAhA-0000pv-Cr for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Feb 2018 16:22:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej9uF-0001GV-QR for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej9uE-0003LW-Bx for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:55 -0500 Received: from mail-db5eur01on0132.outbound.protection.outlook.com ([104.47.2.132]:39281 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ej9uE-0003KQ-4C for qemu-devel@nongnu.org; Tue, 06 Feb 2018 15:31:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jTiD4ss5ViomQ1odMmGb43F2UO0eyiLrXQ9m7F8cBM4=; b=FYfCVgltsrbLA+bmCVEhfvPGS2aQ8EN2Utdv2b100nqJldgRKiFEPQNvWVTO3GywSILt63x5QRY5iHOieybQwaLtf8NHERJGKCsXSyf+PW8n/WJBjrry1D4WBOnORN8hOG/TmAS3yWF0qh0ORRWN2pazWg/pELPbtsh9d96EeJY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (195.214.232.6) by VI1PR0801MB1983.eurprd08.prod.outlook.com (2603:10a6:800:8a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Tue, 6 Feb 2018 20:31:51 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Tue, 6 Feb 2018 23:30:40 +0300 Message-Id: <20180206203048.11096-27-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180206203048.11096-1-rkagan@virtuozzo.com> References: <20180206203048.11096-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0301CA0008.eurprd03.prod.outlook.com (2603:10a6:3:76::18) To VI1PR0801MB1983.eurprd08.prod.outlook.com (2603:10a6:800:8a::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86057c6a-cbf6-4619-8cd4-08d56da0a815 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0801MB1983; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1983; 3:hInon0UOb5cXLjnMz77gj2Bq54GSvYktFG3ldJLxOn93LTphnFttplrPZhsDPCVIN2J8NAW+fObWEmmfgBSq/WtslsIEYoI+3DEI1mZq+vUhBFrNi1kY1pOdZGVrdHFaIhWEK6XlFN9DQe3v4rC7vMFmWsz+LSrP04DzTL/0s8U6hhW4OycUGszx6INilPf3iRW6JTwX/cOAb4M13ZRpWiPvCSR7Upsgyfbpv7qTgrshJp5SfV9agvGd3voxzFc7; 25:4/OUOS01H5YizhWdkNAkhaersgKS+p78ODHwfbzJ8tGrminmo7KKO1j/ISkZ0htnabbC43Uc54lNR7aRgoZmGeVEx61S4LtpLIVSeGhGN9wyPfLUzeZqL+N+Az7KC4eZ4+lxFBaIBstp7Und8ooKn9vYgp42qYnDHsY4kbbJtR102Dtb2/tU1sNmzooHpoKq/D2pM7egNUeEEIMgZ6q0XGMIonP1BzZEqV7U2j1q5XxxWm4IxU/ykd2xkAV+LSyHfVHea7UIV0fufnaq1a64df3OfV5bSX3R3+bCRboC5EkD3Wo1mxMPWhTJoPZkg3H2kYM6SBptQXU++i0/ST5RSg==; 31:UAvof2zQ3qaEZ2Ffikx6drw3PCPFb2+jRvdjlvsXx45ftqaLP+fAN1gyVBGryS3wpKAqAWh9KYT1muy2SUUmTxCARcKta5RZB3mbhhl89+qMxt4oEk8Uhb80wcMr4EgFG0AviEh+6/9zYHbegJCa24hoetVPFGTd7AO1QNH9MrhjO3KgISwEZS+kpXaZq1SdF0Iyp6APE2AsMfLlmG3mvRsjeWmUiOPICmXxllwRAMk= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1983: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1983; 20:Cg4IU7m1Wnclu4Bje7OOCiaUg1Z5SZHUJkepBHguswZSI0Ig0CI5TZv+Q81nvgQNP5GasN+0nDUUoS+9O9eULiYAZsjqTq+bqGCON/2aSLS1hjJF1I35ziIxF5Fz9dxJcTC0OoZnRM7sM0CpuifBfrIF4B5Q0nYMBLvSFfmTAoPI5kq/DDy3l+z/BciJKlND3Re3zm9HcxvJp2v1kuD7e3ZCOGKytQSPpHOt36kLT0PuDOuWl0yZ6rVFfR4dR2Yx6NXsbuqaw5FJXMEDR6xl2OZEijLhj4BOTh/gYfk1q49EDqLoBUaIWJU7zWTfluQmzsrHHWCz1vl6fQauXoVFjFpE/wuVFoA+KaR63fnf8SV9QOZwmBhSWHbmkAKOoGzVXfiErdq8gtJPtZyXljik0pUfh5/56jCCEtvIa12JyII=; 4:rkxifuFLiV0He6wDMLH2wZWkZ/bLcb7fYGVXW1EUISKv1JDVEBJivFG8tNdo2US/dFs0EtcjWquw+WMpXiUELye9caX77PvlWIS1ZaSpqQfqvOiGsU4C4w9mxntAN71jLePt73eY4VmqGjhxg7fz/SR+bgMT4b5K1uZWmHmXL8HOWOligS4You68SMqjrhjlDwQk7QX1yqkNNvnXeebEm4E8B9vI5D9O6iaNAfburACNfShyvmb7cZfeMzPSBT33jszmuIYntsntihJKIQH/mA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231101)(2400082)(944501161)(10201501046)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(6072148)(201708071742011); SRVR:VI1PR0801MB1983; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1983; X-Forefront-PRVS: 0575F81B58 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(1496009)(396003)(366004)(376002)(39380400002)(39850400004)(346002)(189003)(199004)(16586007)(53936002)(305945005)(54906003)(7736002)(3846002)(316002)(105586002)(2361001)(106356001)(2351001)(6116002)(1076002)(50226002)(8936002)(81156014)(5660300001)(8676002)(81166006)(7416002)(2950100002)(6666003)(6916009)(76176011)(575784001)(86362001)(68736007)(66066001)(16526019)(47776003)(50466002)(4326008)(97736004)(26005)(6512007)(51416003)(2906002)(52116002)(386003)(6506007)(59450400001)(48376002)(55236004)(36756003)(53416004)(69596002)(6486002)(478600001)(186003)(25786009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0801MB1983; H:rkaganb.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0801MB1983; 23:5Zbz19cCok334Yk/uOxewNMrIpJSXgHtArNxPuB?= =?us-ascii?Q?JS6ao23sRdFFqyfWDvl6rzfEUcu1blS2tatCp0ZH40Oy1csWlGAKKoaxtYbs?= =?us-ascii?Q?coz0hrgTOnyUOhnfpZ3KX2OXD0jiGWOsz4uECRWBr53dmFVkjoBvaNJPTWyH?= =?us-ascii?Q?4os6ZeH6ElLFqUeRWPPVSTJcNkw2vpQWMs/q+lulmoV/GQxHtDQCfmAyy/8h?= =?us-ascii?Q?KOIeOOTEKKbSVkP+JKXrgjIcZ4jLMU30w42FfZTXsQlB43cS7O+l+idBPqkb?= =?us-ascii?Q?wP0GcdDQOuEXnfZwUOzLfstGWuMKNwTbgz8/4NU78Rx0H9696D727MjyEpS8?= =?us-ascii?Q?x66ImLtEFCI8HjUd39FlS/wemEV2x6/mb3w+6s4pZvJ0G6HqEclKw4S1/ClC?= =?us-ascii?Q?VknCcPbiCBmjFoc6Vblfz+jqMIC7zV2mz/m1dA3oSvmC0M09hTL7T1z+AL5p?= =?us-ascii?Q?vOo+ti4iiNTN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F9lvnhO2D?= =?us-ascii?Q?W+pKxGA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1983; 6:+ZudJ8EFpW8a+W/LTpR3UIm1f/sp/2trgUE4MiLuQf/UmAhNAEObgP46Y/TNuyevi4vpV3b+yhRWXHl43iEUpc/put2bGZ9+0CYSkJOhKh0BgMLdnWkjM+XlZZKPKrEoOQ1CNURg7s1sxzDbVFey8knk/OaUOX50mFhc4ANBb/yDdvHyFuEEkH6HKWeKO/lCP+jxgjma25xmaYBI5qkHF9oE+s0OZ51lNRsiqPYPysel/m4vc/aFIlTW1vEvoQVCwgkPi4PHp8HKteop9KzCtfVlP0uYnG6k7y9IW79A0cXUuz7L2SgTAFZSCr/RkYwP/y7enFnqwNMCzP8RHDEnfeNCchZZzlq38Mq9/tjPAPw=; 5:7XPozzvzHJ7x/Cm8XF0Nk7MzHkLBJhfH/3+cRLJvRQuFFy0u9e13ZdRaTc4pWSVrEldOxOKBsCNlnZ9WCba5i76a+UevsIfDbNjAMrwHLzn8oya4M9yVHQEX270PQgyKfRpRHui0Mq6vEdy2TVUv9Oh1AM+Tlv842fk9GjE4Uww=; 24:2g6KbZqRXq6q6J+G+KNpOuF7SLmgVASFJqA2aoFKiiQC9dYQS4DpXvGMpZ6m4pnR99PY2j6gJRHaUrFTgsqxfxb68rFdk0iR2ccNUYCSnos=; 7:+RU07o+DTAn9TYmBw5iovCeWgRg4Vxk6a74KuqfxX986JcenCtx8egqjck39Dp7urgoIwg6141fhCqJWKuarK10s8jFvkvPeSvr8W49K/Y9gE742YD0xqQqNiKAjGl6EDDRtd/NuRhH2AKx9rHEdDOrmEHv9WwWQuJPSk6AOf0oGx7dNJZpccahFRSlhszmbchbqcz+x0FMcIpqWr8fNj5fvy6WnRxR0Fst89x6u/wmSjJKJe7Qg1m1vwS+fAL9F SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1983; 20:v8s20bSCnKhpatXiGnLcE/cS8xuZl2fMtRfUZYgZDBhV/cRaohkt80kD1qskEn7Ura0E7JgWQfxIVtK5+VVjei0Le8BTooEAKHOKei7RS+irujKYf9HjxY+ybVo11clSyJCA0psdkp3SE5L3JGrSBVQjyiq9UD5UjwJio8zOtJg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2018 20:31:51.3097 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86057c6a-cbf6-4619-8cd4-08d56da0a815 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1983 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.2.132 Subject: [Qemu-devel] [RFC PATCH 26/34] hv-scsi: limit the number of requests per notification X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Warren , Konrad Rzeszutek Wilk , Krish Sadhukhan , "Marcos E. Matsunaga" , Jan Dakinevich , Vadim Rozenfeld , "Denis V. Lunev" , si-wei liu , Paolo Bonzini , Vitaly Kuznetsov , Cathy Avery Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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)