Received: from eggs.gnu.org ([2001:4830:134:3::10]:49398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc9Cb-0001fr-8r for qemu-devel@nongnu.org; Wed, 16 Sep 2015 05:40:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zc9CY-0001Fu-1z for qemu-devel@nongnu.org; Wed, 16 Sep 2015 05:40:33 -0400 Received: from mx3-phx2.redhat.com ([209.132.183.24]:45383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zc9CX-0001Fq-Qx for qemu-devel@nongnu.org; Wed, 16 Sep 2015 05:40:29 -0400 Date: Wed, 16 Sep 2015 05:40:25 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <1086841673.12515070.1442396425169.JavaMail.zimbra@redhat.com> In-Reply-To: <55F938B6.1060008@huawei.com> References: <1442333283-13119-1-git-send-email-marcandre.lureau@redhat.com> <1442333283-13119-17-git-send-email-marcandre.lureau@redhat.com> <55F938B6.1060008@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 16/46] ivshmem: remove max_peer field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Claudio Fontana Cc: marcandre lureau , drjones@redhat.com, cam@cs.ualberta.ca, qemu-devel@nongnu.org, stefanha@redhat.com Hi ----- Original Message ----- > On 15.09.2015 18:07, marcandre.lureau@redhat.com wrote: > > From: Marc-Andr=C3=A9 Lureau > >=20 > > max_peer isn't really useful, it tracks the maximum received VM id, but > > that quickly matches nb_peers, the size of the peers array. Since VM > > come and go, there might be sparse peers so it doesn't help much in > > general to have this value around. >=20 > Does this max_peer provide any value if VMs _don't_ come and go? > Not that I see any. I don't see any either. >=20 > >=20 > > Signed-off-by: Marc-Andr=C3=A9 Lureau > > --- > > hw/misc/ivshmem.c | 10 +--------- > > 1 file changed, 1 insertion(+), 9 deletions(-) > >=20 > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > > index 07f2182..cda7dce 100644 > > --- a/hw/misc/ivshmem.c > > +++ b/hw/misc/ivshmem.c > > @@ -90,7 +90,6 @@ typedef struct IVShmemState { > > =20 > > Peer *peers; > > int nb_peers; /* how many guests we have space for */ > > - int max_peer; /* maximum numbered peer */ > > =20 > > int vm_id; > > uint32_t vectors; > > @@ -200,7 +199,7 @@ static void ivshmem_io_write(void *opaque, hwaddr a= ddr, > > =20 > > case DOORBELL: > > /* check that dest VM ID is reasonable */ > > - if (dest > s->max_peer) { > > + if (dest >=3D s->nb_peers) { > > IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", de= st); > > break; > > } > > @@ -574,11 +573,6 @@ static void ivshmem_read(void *opaque, const uint8= _t > > *buf, int size) > > /* increment count for particular guest */ > > s->peers[incoming_posn].nb_eventfds++; > > =20 > > - /* keep track of the maximum VM ID */ > > - if (incoming_posn > s->max_peer) { > > - s->max_peer =3D incoming_posn; > > - } > > - > > if (incoming_posn =3D=3D s->vm_id) { > > s->eventfd_chr[guest_max_eventfd] =3D create_eventfd_chr_devic= e(s, > > &s->peers[s->vm_id].eventfds[guest_max_eventfd], > > @@ -721,8 +715,6 @@ static void pci_ivshmem_realize(PCIDevice *dev, Err= or > > **errp) > > PCI_BASE_ADDRESS_MEM_PREFETCH;; > > Error *local_err =3D NULL; > > =20 > > - s->max_peer =3D -1; > > - > > if (s->sizearg =3D=3D NULL) { > > s->ivshmem_size =3D 4 << 20; /* 4 MB default */ > > } else { > >=20 >=20 >=20