All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
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 <stephen@networkplumber.org>
Subject: Re: [PATCH 2/2] vmbus: make hv_get_ringbuffer_availbytes local
Date: Tue, 28 Nov 2017 16:34:41 +0100	[thread overview]
Message-ID: <20171128153441.GA24659@kroah.com> (raw)
In-Reply-To: <1510681928-13951-2-git-send-email-kys@exchange.microsoft.com>

On Tue, Nov 14, 2017 at 10:52:08AM -0700, kys@exchange.microsoft.com wrote:
> From: Stephen Hemminger <stephen@networkplumber.org>
> 
> 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 <sthemmin@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
>  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

  reply	other threads:[~2017-11-28 15:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 17:51 [PATCH 0/2] Drivers: hv: vmbbus: Miscellaneous cleanup kys
2017-11-14 17:52 ` [PATCH 1/2] Drivers: hv: vmbus: Remove x86-isms from arch independent drivers kys
2017-11-28 15:33   ` Greg KH
2017-11-14 17:52 ` [PATCH 2/2] vmbus: make hv_get_ringbuffer_availbytes local kys
2017-11-28 15:34   ` Greg KH [this message]
2017-11-28 15:58     ` KY Srinivasan
2017-11-28 16:32       ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171128153441.GA24659@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=apw@canonical.com \
    --cc=devel@linuxdriverproject.org \
    --cc=jasowang@redhat.com \
    --cc=kys@microsoft.com \
    --cc=leann.ogasawara@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.cerri@canonical.com \
    --cc=olaf@aepfle.de \
    --cc=stephen@networkplumber.org \
    --cc=sthemmin@microsoft.com \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.