qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH v5 02/26] vhost: Fix last queue index of devices with no


From: Eugenio Perez Martin
Subject: Re: [RFC PATCH v5 02/26] vhost: Fix last queue index of devices with no cvq
Date: Tue, 2 Nov 2021 09:34:05 +0100

On Tue, Nov 2, 2021 at 8:25 AM Juan Quintela <quintela@redhat.com> wrote:
>
> Eugenio Pérez <eperezma@redhat.com> wrote:
> > The -1 assumes that all devices with no cvq have an spare vq allocated
> > for them, but with no offer of VIRTIO_NET_F_CTRL_VQ. This may not be the
> > case, and the device may have a pair number of queues.
>                                   ^^^^
> even
>
> I know, I know, I am Spanish myself O:-)
>

Ouch! Good catch! :).

> > To fix this, just resort to the lower even number of queues.
>
> I don't understand what you try to achieve here.
>
> > Fixes: 049eb15b5fc9 ("vhost: record the last virtqueue index for the
> > virtio device")
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> >  hw/net/vhost_net.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > index 0d888f29a6..edf56a597f 100644
> > --- a/hw/net/vhost_net.c
> > +++ b/hw/net/vhost_net.c
> > @@ -330,7 +330,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState 
> > *ncs,
> >      NetClientState *peer;
> >
> >      if (!cvq) {
> > -        last_index -= 1;
> > +        last_index &= ~1ULL;
> >      }
>
> As far as I can see, that is a nop. last_index is defined as an int.
>
> $ cat kk.c
> #include <stdio.h>
>
> int main(void)
> {
>         int i = 7;
>         i &= -1ULL;
>         printf("%d\n", i);
>         i = 8;
>         i &= -1ULL;
>         printf("%d\n", i);
>         i = 0;
>         i &= -1ULL;
>         printf("%d\n", i);
>         i = -2;
>         i &= -1ULL;
>         printf("%d\n", i);
>         return 0;
> }
> $ ./kk
> 7
> 8
> 0
> -2
>

(Already answered by MST in another thread, but to be consistent here)
it's actually a ~1ULL :).

I will rewrite the patch message,

Thanks!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]