From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkEHJ-0001yY-BN for qemu-devel@nongnu.org; Fri, 31 Oct 2014 11:39:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjstN-0001Pu-Du for qemu-devel@nongnu.org; Thu, 30 Oct 2014 12:48:15 -0400 Received: from mail-la0-x236.google.com ([2a00:1450:4010:c03::236]:49342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjstN-0001Pf-2r for qemu-devel@nongnu.org; Thu, 30 Oct 2014 12:48:09 -0400 Received: by mail-la0-f54.google.com with SMTP id gm9so4820616lab.13 for ; Thu, 30 Oct 2014 09:48:07 -0700 (PDT) Date: Thu, 30 Oct 2014 16:48:03 +0000 From: Stefan Hajnoczi Message-ID: <20141030164803.GB32387@stefanha-thinkpad.redhat.com> References: <1414462382-24264-1-git-send-email-wu.wubin@huawei.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="61jdw2sOBCFtR2d/" Content-Disposition: inline In-Reply-To: <1414462382-24264-1-git-send-email-wu.wubin@huawei.com> Subject: Re: [Qemu-devel] [PATCH] hw/virtio/virtio.c: fix the vring_avail_event error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bin Wu Cc: pbonzini@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, mst@redhat.com --61jdw2sOBCFtR2d/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 28, 2014 at 02:13:02AM +0000, Bin Wu wrote: > The event idx in virtio is an effective way to reduce the number of > interrupts and exits of the guest. When the guest puts an request > into the virtio ring, it doesn't exit immediately to inform the > backend. Instead, the guest checks the "avail" event idx to determine > the notification. >=20 > In virtqueue_pop, when a request is poped, the current avail event > idx should be set to the number of vq->last_avail_idx. >=20 > Signed-off-by: Bin Wu > --- > hw/virtio/virtio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index 2c236bf..013979a 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -469,7 +469,7 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *el= em) > =20 > i =3D head =3D virtqueue_get_head(vq, vq->last_avail_idx++); > if (vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) { > - vring_avail_event(vq, vring_avail_idx(vq)); > + vring_avail_event(vq, vq->last_avail_idx); > } hw/virtio/dataplane/vring.c: if (vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) { vring_avail_event(&vring->vr) =3D vring->vr.avail->idx; } This is equivalent to the virtio.c code you are replacing, so it should be updated too. Stefan --61jdw2sOBCFtR2d/ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUUmvDAAoJEJykq7OBq3PIhJIIAKyqQQaUaTz+6wotdLlnY67I P/BHjCvUelKK+kpWE4yjNyl7lsiO5NqfrMMF2qmsiFWpAYHScbps1kLScAegXr9N croNWQX23Cp1czsyW/ih50Dmb7+W3SFx+c64wNFsfiE69akZXQH6b+5+DsIfRvYv EoIO28AHgHGvPzhb970oXBJceAD5XRE7VLwNIWVRo5KoyNYs+V1syVCGjG4A3lT8 jkCI867zngTDFKHQoLm8MEuB+4QC4p+JlQSqBqZbGxVck7GyuzoGYOdesKhW75nB tHG/WfnzNY5p4iSNVpG9p9N8F/MiLvTvQoV4h6UCIcZJByRVhyC0h5u1+zjaEvY= =DjHS -----END PGP SIGNATURE----- --61jdw2sOBCFtR2d/--