Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752580AbdGFVha (ORCPT ); Thu, 6 Jul 2017 17:37:30 -0400 Received: from mail-hk2apc01on0100.outbound.protection.outlook.com ([104.47.124.100]:18844 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752341AbdGFVh1 (ORCPT ); Thu, 6 Jul 2017 17:37:27 -0400 From: Dexuan Cui To: "gregkh@linuxfoundation.org" , KY Srinivasan , Stephen Hemminger , "Haiyang Zhang" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" CC: "olaf@aepfle.de" , Vitaly Kuznetsov , "jasowang@redhat.com" , "apw@canonical.com" , Andy Lutomirski , "marcelo.cerri@canonical.com" , "leann.ogasawara@canonical.com" , "Rolf Neugebauer" , "'Marcelo Cerri'" Subject: [PATCH] vmbus: fix the missed signaling in hv_signal_on_read() Thread-Topic: [PATCH] vmbus: fix the missed signaling in hv_signal_on_read() Thread-Index: AdL2n6DfGk6DPr+uS0e659UzPwo8og== Date: Thu, 6 Jul 2017 21:37:11 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Ref=https://api.informationprotection.azure.com/api/72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2017-07-06T14:37:08.7769775-07:00; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General authentication-results: linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [131.107.169.23] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;KL1P15301MB0005;7:k/T1PGnN5fxeSijHeCUb6BrKT0rmJwag2BJUSo5p2j2lP7LEU2XylDbgIE3JYrL+eVxk9KOzlHxeQNP/wEmfR9gO6Jl1SohKA+YSs4t78L5eeDtXfTSqtkZHIiScwTx+CeMyp4XibKfIUuAguN4jl8o7BB9o1PH7VRffVFn8Tf3OcnQwouB/jRtWTPGUJmJ2bH7eJ9Znps3JxlFV58ZnBTsSLs8RizcPYdfFzZTf4EMXwfbffqxlJ+nIrg2HrfvrsKETh5cP8K2H+1mNz5q3IkXCqfDsy25ltREYhtcGYcIU575rUdRy2AUJHF/piruyOxria+tSt3QZL/mxsNTb4YbKFGw2Nj55p7Ej5+PXyJ4TA+HakRatU9snkoQ2l8YBKUbxWzgxv4v3YDChEzb44XNjEcC0c2ttxCKp+MI9LFLQpEGbnCp5s1KcOOLMOnwp5Tgz1T797gP49ZLGN07WHA2/WRAfIZHN7FrwRA7fQaV3zKafBVF4xQZ3XPb/1ZPSzWYEOXLyjtfzOzUvxBv3WhpVnG7UHYC1NCsNZYX/6u9BJHj6ZGXaG/7izI1PO+DPQz4R7gVYY/+YMmGJlfLdXd5UpoRbLofdKTsSm1NSCHUPF6VZ2Xpz9z5Ciq0fCzcd3nfPJYa4BPK5vvNYD6slKozfF8ldRCOGtXhBvQ3rU7RTOcb9PbOorGpmhpB5J5F4KaqflAZGs3E+odTuGtKCite27AjhudlpEtvmxwthdewqwgZb47lKxHEsqdjhnmAdKOBO/1tBbXxkPefB6mngRqzLEcFhOiO11TFZMij4Jc9coAC52dxV9ysFRHplUi4Z x-o365ent-eop-header: Message processed by - O365_ENT: Allow from ranges (Engineering ONLY) x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10019020)(6009001)(39840400002)(39410400002)(39400400002)(39450400003)(39850400002)(39860400002)(7416002)(478600001)(9686003)(4326008)(2900100001)(7696004)(6506006)(55016002)(25786009)(54906002)(6436002)(81166006)(2501003)(8936002)(50986999)(6116002)(54356999)(3846002)(2201001)(77096006)(66066001)(86362001)(1511001)(38730400002)(3280700002)(2906002)(8990500004)(8676002)(102836003)(53936002)(5660300001)(10290500003)(14454004)(5005710100001)(10090500001)(74316002)(3660700001)(33656002)(189998001)(7736002)(305945005)(2421001);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1P15301MB0005;H:KL1P15301MB0008.APCP153.PROD.OUTLOOK.COM;FPR:;SPF:None;MLV:sfv;LANG:en; x-ms-office365-filtering-correlation-id: 3cf4ad4d-368e-4848-4f61-08d4c4b72999 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:KL1P15301MB0005; x-ms-traffictypediagnostic: KL1P15301MB0005: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(236129657087228)(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(61426038)(61427038)(6041248)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1P15301MB0005;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1P15301MB0005; x-forefront-prvs: 03607C04F0 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jul 2017 21:37:11.7861 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0005 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v66LbxTA032316 Content-Length: 1253 Lines: 41 There is an off-by-one bug here, which can cause host-to-guest write to stall. When cur_write_sz == pending_sz, we shouldn't signal the host because it's meaningless: the ring mustn't be 100% full. But when cached_write_sz == pending_sz, we must signal the host. Fixes: 433e19cf33d3 ("Drivers: hv: vmbus: finally fix hv_need_to_signal_on_read()") Signed-off-by: John Starks Signed-off-by: Dexuan Cui Cc: Haiyang Zhang Cc: Stephen Hemminger Cc: "K. Y. Srinivasan" Cc: --- include/linux/hyperv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index ba93b7e..246bc6b 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1501,11 +1501,11 @@ static inline void hv_signal_on_read(struct vmbus_channel *channel) cur_write_sz = hv_get_bytes_to_write(rbi); - if (cur_write_sz < pending_sz) + if (cur_write_sz <= pending_sz) return; cached_write_sz = hv_get_cached_bytes_to_write(rbi); - if (cached_write_sz < pending_sz) + if (cached_write_sz <= pending_sz) vmbus_setevent(channel); return; -- 2.7.4