Received: by 10.223.185.116 with SMTP id b49csp1826271wrg; Sun, 11 Feb 2018 22:30:04 -0800 (PST) X-Google-Smtp-Source: AH8x227auQFBbJxyw2EKkWfA/o1telz7AzvJGdDljUdqY7Aug/uQdSr3QiR9MGPu33tuetHA+9QZ X-Received: by 2002:a17:902:44a4:: with SMTP id l33-v6mr9784537pld.115.1518417004635; Sun, 11 Feb 2018 22:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518417004; cv=none; d=google.com; s=arc-20160816; b=cE35K4MvZ4xMYJw9BWYiTjl1awyoFcFfF3l3GgZHTX6UnaF3cbO1V6x392yxZcE2Uy iBufu+6IqhoBeJv0r5PpCPVs1JzTmZfSTL6V3AtyFpzGLn8155rjrnl0l9PtTa7QMNOj hwVX+AAgscX0Gy6wkj3dWcjfq5sNMDpwYdtKwh0TKg9GSmS1B6SWpu6oixsE+LRBWyaV 7sb0dt5x7gmOe6Rr1GaIdV2hiH520f6dlbvHb0npkq+27IbtXuqEU+z04z0gYB6yPV6J 3U65N9LI+0fBfvKtZJfFxcod3+yHaBDlTTDh9KY3xiBuyS9rk6vIpfvtnTIPqkPO9gF3 2yMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:msip_labels :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from:dkim-signature :arc-authentication-results; bh=3dmm26AOmxBwjjvTsRXz26i1nLIvTTYBVV12gXlKM4E=; b=T+zGSGWlGF7+sejRcaeO7X+toCNlrmJN9bx5T2et0O8ylDqB32qMJZXLRSdTLPwDk7 LqYVc+72CFmzjX2ygzgrAv17B5Qlk89TSUYOq/T8DfgnpctaxUV2XvZRmuWvlCKufI+U ReQHyNXajw70ebk2S8K+yabD4GNRjHxKrmUWRtGACQTKMKNw3G5jsyQ2wrQwIalk5ad6 +Gct5UN+5sCqUAx5DopDou/8yliJrLtkc3i65rumwoFPRQoTtbiAcRXLaxmFjeUZiv+u IXsNcz0tRRglx4NSVO+gBhUGSC1foNjiORaeQJhFx/PDkjUu+VfnCyUTTJm+oArmIP4h eqQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=BRpqmBHi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si1633878plz.756.2018.02.11.22.29.50; Sun, 11 Feb 2018 22:30:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=BRpqmBHi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751345AbeBLFNR (ORCPT + 99 others); Mon, 12 Feb 2018 00:13:17 -0500 Received: from mail-by2nam01on0128.outbound.protection.outlook.com ([104.47.34.128]:10063 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751263AbeBLFNQ (ORCPT ); Mon, 12 Feb 2018 00:13:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=3dmm26AOmxBwjjvTsRXz26i1nLIvTTYBVV12gXlKM4E=; b=BRpqmBHighteuXdiKpCjg6HRyGP6Yl2QcJomB/0hLBAABtCzzYIYrpK7L9uGPOMgRflbpSpXJf44o8shoNIeSbvEmxQu9u1usTsUiLxZPLhtexLbwsxJQeR56YFuKiUBvO2jGVgnp65TO7JJawKGBgjUzsAqKIWQJk8WI31Jzls= Received: from DM5PR2101MB1030.namprd21.prod.outlook.com (52.132.128.11) by DM5PR2101MB0967.namprd21.prod.outlook.com (52.132.133.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.527.3; Mon, 12 Feb 2018 05:13:12 +0000 Received: from DM5PR2101MB1030.namprd21.prod.outlook.com ([fe80::3551:2328:8961:9424]) by DM5PR2101MB1030.namprd21.prod.outlook.com ([fe80::3551:2328:8961:9424%3]) with mapi id 15.20.0527.002; Mon, 12 Feb 2018 05:13:08 +0000 From: "Michael Kelley (EOSG)" To: KY Srinivasan , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "vkuznets@redhat.com" , "jasowang@redhat.com" , "leann.ogasawara@canonical.com" , "marcelo.cerri@canonical.com" , Stephen Hemminger Subject: RE: [PATCH char-misc 1/1] Drivers: hv: vmbus: Fix ring buffer signaling Thread-Topic: [PATCH char-misc 1/1] Drivers: hv: vmbus: Fix ring buffer signaling Thread-Index: AQHTorCNaQB4t9RCq0qElSZLQrwNpaOf8abQgABFFXA= Date: Mon, 12 Feb 2018 05:13:07 +0000 Message-ID: References: In-Reply-To: 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_Owner=mikelley@ntdev.microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-02-12T05:13:06.2328730Z; 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 x-originating-ip: [24.22.167.197] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0967;7:E2ZBUays2W2YPFp5GF/dstEQW7R5rERIlkrXF1gQyihZfSEHSD/5jPdw5RjrofDYyWJ2gwbQBoBSo+rI/xNKO2cfvnABYam33co4lDDI1YXYPyQtToIN3u4PxjT27slpzmKVraVuLRHP35tODECjQlYtfCQVjWp+XzUuHbnTZpvnfLmAMcLU0jhipuhYxObko9tKydMFFX+ifNEOAz2A5EVmUK7DDhCAXAc2IQp0YKW6uF/n0o8UIWsFqpYv6LlR x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10019020)(366004)(39380400002)(396003)(39860400002)(376002)(346002)(13464003)(189003)(199004)(10090500001)(7736002)(86612001)(106356001)(305945005)(74316002)(8990500004)(33656002)(6116002)(81156014)(81166006)(229853002)(8676002)(68736007)(14454004)(3846002)(97736004)(2900100001)(26005)(1511001)(6506007)(59450400001)(66066001)(6346003)(72206003)(105586002)(102836004)(2950100002)(6636002)(2906002)(25786009)(3280700002)(8936002)(110136005)(76176011)(3660700001)(6246003)(316002)(5250100002)(478600001)(53936002)(10290500003)(86362001)(2501003)(9686003)(55016002)(99286004)(5660300001)(7696005)(6436002)(2201001)(22452003)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0967;H:DM5PR2101MB1030.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 0695b209-8b5b-46b5-e440-08d571d74ddf x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:DM5PR2101MB0967; x-ms-traffictypediagnostic: DM5PR2101MB0967: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231101)(944501161)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0967;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0967; x-forefront-prvs: 0581B5AB35 received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Michael.H.Kelley@microsoft.com; x-microsoft-antispam-message-info: NjTCBsFHK0BCyW7SgB5/KVH9fTMqwxRP40horNu0HBsSMl2KUAdKjPAKMPO3rkqbZL4B8JAQaAH23+UsCHtV+Q== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0695b209-8b5b-46b5-e440-08d571d74ddf X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Feb 2018 05:13:07.9417 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0967 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: KY Srinivasan > Sent: Sunday, February 11, 2018 5:14 PM --- snip --- > > if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) { > > u32 pending_sz =3D READ_ONCE(rbi->ring_buffer- > > >pending_send_sz); > > > > /* > > + * Ensure the read of write_index in > > hv_get_bytes_to_write() > > + * happens after the read of pending_send_sz. > > + */ > > + virt_rmb(); > We can avoid the read barrier by making the initialization of curr_write_= sz conditional > on pending_send_sz being non-zero. Indeed you can make all the signaling = code conditional > on pending_send_sz being non-zero. >=20 >=20 I agree that we can immediately test pending_send_sz for zero, and exit if zero. A zero value will be by far the most common path, and would save executing the read barrier and hv_get_bytes_to_write(). Can also move the calculation of "delta" to after the test for zero. But I believe the read barrier is still needed on the path where pending_send_sz is non-zero. Just the testing the value of pending_send_sz doesn't guarantee that the write_index wouldn't be speculatively read, and potentially out-of-order. And we have to consider the out-of-order behaviors on ARM64 as well. >=20 > > + curr_write_sz =3D hv_get_bytes_to_write(rbi); > > + > > + /* > > * If there was space before we began iteration, > > * then host was not blocked. Also handles case where > > * pending_sz is zero then host has nothing pending > > * and does not need to be signaled. > > */ > > - if (orig_write_sz > pending_sz) > > + if (curr_write_sz - delta > pending_sz) > > return; > > > > /* If pending write will not fit, don't give false hope. */ > > - if (hv_get_bytes_to_write(rbi) < pending_sz) > > + if (curr_write_sz <=3D pending_sz) > > return; > > + > > + vmbus_setevent(channel); > > } > > > > - vmbus_setevent(channel); > > } > > EXPORT_SYMBOL_GPL(hv_pkt_iter_close); > > -- > > 1.8.3.1