Re: [PATCH 2/6] uio_hv_generic: Query the ringbuffer size for device

From: Saurabh Singh Sengar
Date: Mon Feb 19 2024 - 04:40:34 EST


On Mon, Feb 19, 2024 at 09:50:54AM +0100, Greg KH wrote:
> On Sat, Feb 17, 2024 at 10:03:36AM -0800, Saurabh Sengar wrote:
> > Query the ring buffer size from pre defined table per device.
> > Keep the size as is if the device doesn't have any preferred
> > ring size.
>
> What is the "as is" size?

I will elaborate more here.

>
> >
> > Signed-off-by: Saurabh Sengar <ssengar@xxxxxxxxxxxxxxxxxxx>
> > ---
> > drivers/uio/uio_hv_generic.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
> > index 20d9762331bd..4bda6b52e49e 100644
> > --- a/drivers/uio/uio_hv_generic.c
> > +++ b/drivers/uio/uio_hv_generic.c
> > @@ -238,6 +238,7 @@ hv_uio_probe(struct hv_device *dev,
> > struct hv_uio_private_data *pdata;
> > void *ring_buffer;
> > int ret;
> > + size_t ring_size = hv_dev_ring_size(channel);
> >
> > /* Communicating with host has to be via shared memory not hypercall */
> > if (!channel->offermsg.monitor_allocated) {
> > @@ -245,12 +246,14 @@ hv_uio_probe(struct hv_device *dev,
> > return -ENOTSUPP;
> > }
> >
> > + if (!ring_size)
> > + ring_size = HV_RING_SIZE * PAGE_SIZE;
>
> Why the magic * PAGE_SIZE here?
>
> Where is it documented that ring_size is in pages?
>
> And what happens when PAGE_SIZE is changed? Why are you relying on that
> arbritrary value to dictate your buffer sizes to a device that has
> no relationship with PAGE_SIZE?
>
> Yes, I know you are copying what was there today, but you have the
> chance to rethink and most importantly, DOCUMENT this decision properly
> now.

I agree PAGE_SIZE is not accurate here and we should use HV_HYP_PAGE_SIZE.
This can be further improved by using VMBUS_RING_SIZE macro.

However, I propose addressing this improvement in a separate patch, given
the are significant changes already present in this series.

- Saurabh


>
> thanks,
>
> greg k-h