Juan Quintela
2021-Nov-02 07:25 UTC
[RFC PATCH v5 02/26] vhost: Fix last queue index of devices with no cvq
Eugenio P?rez <eperezma at 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:-)> 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 at 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
Michael S. Tsirkin
2021-Nov-02 07:32 UTC
[RFC PATCH v5 02/26] vhost: Fix last queue index of devices with no cvq
On Tue, Nov 02, 2021 at 08:25:27AM +0100, Juan Quintela wrote:> Eugenio P?rez <eperezma at 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:-)Nobody expects the Spanish ;)> > 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 at 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;Stefano's patch has ~1ULL , not -1ULL here.> 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