RE: [PATCH 2/2] vmbus: make hv_get_ringbuffer_availbytes local

2017-11-28 Thread Stephen Hemminger
This patch required a patch that is still going through net-next.


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 2/2] vmbus: make hv_get_ringbuffer_availbytes local

2017-11-28 Thread KY Srinivasan


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Tuesday, November 28, 2017 7:35 AM
> To: KY Srinivasan <k...@microsoft.com>
> Cc: linux-ker...@vger.kernel.org; de...@linuxdriverproject.org;
> o...@aepfle.de; a...@canonical.com; vkuzn...@redhat.com;
> jasow...@redhat.com; leann.ogasaw...@canonical.com;
> marcelo.ce...@canonical.com; Stephen Hemminger
> <sthem...@microsoft.com>; Stephen Hemminger
> <step...@networkplumber.org>
> Subject: Re: [PATCH 2/2] vmbus: make hv_get_ringbuffer_availbytes local
> 
> On Tue, Nov 14, 2017 at 10:52:08AM -0700, k...@exchange.microsoft.com
> wrote:
> > From: Stephen Hemminger <step...@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 <sthem...@microsoft.com>
> > Signed-off-by: K. Y. Srinivasan <k...@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...

Sorry about that. I did not have a build issue on the tree I tested. I will 
rebase and send.

K. Y
> 
> greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 2/2] vmbus: make hv_get_ringbuffer_availbytes local

2017-11-28 Thread Greg KH
On Tue, Nov 14, 2017 at 10:52:08AM -0700, k...@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
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel