From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753716AbdK1Pek (ORCPT ); Tue, 28 Nov 2017 10:34:40 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40440 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbdK1Pei (ORCPT ); Tue, 28 Nov 2017 10:34:38 -0500 Date: Tue, 28 Nov 2017 16:34:41 +0100 From: Greg KH To: kys@microsoft.com Cc: 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, Stephen Hemminger Subject: Re: [PATCH 2/2] vmbus: make hv_get_ringbuffer_availbytes local Message-ID: <20171128153441.GA24659@kroah.com> References: <1510681887-13846-1-git-send-email-kys@exchange.microsoft.com> <1510681928-13951-2-git-send-email-kys@exchange.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1510681928-13951-2-git-send-email-kys@exchange.microsoft.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 14, 2017 at 10:52:08AM -0700, kys@exchange.microsoft.com wrote: > 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 This breaks the build. Please be more careful... greg k-h