Received: by 10.223.164.202 with SMTP id h10csp60490wrb; Tue, 14 Nov 2017 11:06:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMY/lsfCJ0qRIjXJwLitZTOfM8fmlW/4je2Z9isRU6gqN6ot19jmgQUiM2DoMl2pR74VqUXk X-Received: by 10.84.238.140 with SMTP id v12mr7843415plk.356.1510686374532; Tue, 14 Nov 2017 11:06:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510686374; cv=none; d=google.com; s=arc-20160816; b=dOHQbYXK+lPLXlMIW3K63AonpbCTYoozYaruXWBG3bEET7qD5TgzB0DU7nnwQqvbqD 4WDOfvYekpbmwwDM0qjs9nzGf3XhA1X0dRGfGtYau0CBRC0UY2ttSt7pdFfyta2blCnd D63OVZ5LYjOEDIpGK+0t9sedwy9gkSKshEO39dAxo9GYvzR+he4L9MR4dDWawgpt05ua NpgyI6awZLpdviyEaflhqSPXHQAuKjk3kmMe7L5612o5CLYs/L2ntLL1a2HYrWWJ36Bz oOda+CCOBfVBBvnyzQZgYWvBdtsJoevlteqsTAwQ0QaNL0f/OWNs077fQsRf6d7tGxaU RKXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=tpK/SkbYpx/elDC7M0UEOr/ZxE7gaErMssSVJvxSaPc=; b=KMF6DXWRaLaB2QlG9jJ+OcaNDITXwcPFB6L226iOufNJ4RBLH7S2ZAb+dNfK2oIXgg r5usa+b8berWIQ6rURrOlzfaJ0KuebTFPBMSh6K0XU1O582Czt2bu7skCgq13iwbOvzl 97c1BlCLvQ1EhPY6hOJLKW9gnIfJREbNpT3759+f6wM7rsYKrMfnM0xd+7Z99W5nklUV IECT3/qUGgxYrIRxwafTNefwt/0JTg5WmRVMeXGAR+n+hp+tbYaNQEE+6ar/bGOpj2qt dJmzPi7cITeQsbmMQDQoX2Ydph5bXSqqFvBZI2TAlLR6wDEZj9t+Hz7g9D3KSkPNgT94 PKzQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si368634pll.349.2017.11.14.11.06.02; Tue, 14 Nov 2017 11:06:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755300AbdKNRxR (ORCPT + 88 others); Tue, 14 Nov 2017 12:53:17 -0500 Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:53028 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754062AbdKNRxL (ORCPT ); Tue, 14 Nov 2017 12:53:11 -0500 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id EfNZesEG2Kv33EfNZeSAyF; Tue, 14 Nov 2017 10:52:09 -0700 x-originating-ip: 107.180.71.197 Received: from kys by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1eEfNZ-0003dZ-IV; Tue, 14 Nov 2017 10:52:09 -0700 From: kys@exchange.microsoft.com To: 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, sthemmin@microsoft.com Cc: Stephen Hemminger , "K. Y. Srinivasan" Subject: [PATCH 2/2] vmbus: make hv_get_ringbuffer_availbytes local Date: Tue, 14 Nov 2017 10:52:08 -0700 Message-Id: <1510681928-13951-2-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1510681887-13846-1-git-send-email-kys@exchange.microsoft.com> References: <1510681887-13846-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfArS0VF2VwZnzSNqWGi1J3vieRtfagecT8AKAlpEjg/pz6hTUuPuGgOflFrLkkgjCDKyoKe+kNa3A7hiiEe2HDSkf7odEay6A++zkRVoNlfMSFfGpBaL X4NV03Zhb/CKbjjmOc1l5szQPXlBji5VaCL2aBDSWmcOyfCKbZzYl2kllxlvGzfzq6Vg0MeJ1+mvlgp9jJ8VdXSWtskpHO/EEW466SQZiU7v1ll/4qCG7Lry lHQ+IJ5fdAmvNY7H7Je3eU2plY8+11b3uv3LAd5KiFUIB+Dv99ICnirDStIxEQHdNUb6AxTu/x60gbw3l4ko6obUnH5yYujkuUi7Tb+eJA9HEGHQpxXdM5CS WaW529CzMDDg8FyYZIF+ctsEbhqxCKpgZMJB53Ps50unt5FV4z2Ml0aGLwtqq9RAqd7gpv7XseC6P1Rw/K2zsURjvKSfAMjYD28lINxhu+cbxUV4JqFEDFof MRTutw5Tf3J4ADRObEZDOynzk7SKAcl8lj9AsOsbaY4QFqlxLEWuHvCkzNJs47WEew+ciiD7u+I+W3bHvukv5l5Y5xmkWFFqVgIsHA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephen Hemminger hv_get_ringbuffer_availbytes is only used by the debug info routine so make it static. Also, add READ_ONCE() to avoid any possible issues with potentially volatile index values. Signed-off-by: Stephen Hemminger Signed-off-by: K. Y. Srinivasan --- drivers/hv/ring_buffer.c | 23 +++++++++++++++++++++++ include/linux/hyperv.h | 22 ---------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 12eb8ca..50e0714 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -140,6 +140,29 @@ static u32 hv_copyto_ringbuffer( return start_write_offset; } +/* + * + * hv_get_ringbuffer_availbytes() + * + * Get number of bytes available to read and to write to + * for the specified ring buffer + */ +static void +hv_get_ringbuffer_availbytes(const struct hv_ring_buffer_info *rbi, + u32 *read, u32 *write) +{ + u32 read_loc, write_loc, dsize; + + /* Capture the read/write indices before they changed */ + read_loc = READ_ONCE(rbi->ring_buffer->read_index); + write_loc = READ_ONCE(rbi->ring_buffer->write_index); + dsize = rbi->ring_datasize; + + *write = write_loc >= read_loc ? dsize - (write_loc - read_loc) : + read_loc - write_loc; + *read = dsize - *write; +} + /* Get various debug metrics for the specified ring buffer. */ void hv_ringbuffer_get_debuginfo(const struct hv_ring_buffer_info *ring_info, struct hv_ring_buffer_debug_info *debug_info) diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 6c93366..93bd6fc 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -127,28 +127,6 @@ struct hv_ring_buffer_info { u32 priv_read_index; }; -/* - * - * hv_get_ringbuffer_availbytes() - * - * Get number of bytes available to read and to write to - * for the specified ring buffer - */ -static inline void -hv_get_ringbuffer_availbytes(const struct hv_ring_buffer_info *rbi, - u32 *read, u32 *write) -{ - u32 read_loc, write_loc, dsize; - - /* Capture the read/write indices before they changed */ - read_loc = rbi->ring_buffer->read_index; - write_loc = rbi->ring_buffer->write_index; - dsize = rbi->ring_datasize; - - *write = write_loc >= read_loc ? dsize - (write_loc - read_loc) : - read_loc - write_loc; - *read = dsize - *write; -} static inline u32 hv_get_bytes_to_read(const struct hv_ring_buffer_info *rbi) { -- 1.7.1 From 1585423325947695625@xxx Wed Nov 29 17:45:06 +0000 2017 X-GM-THRID: 1585422115809200128 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread