From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7eEv-0008As-P1 for qemu-devel@nongnu.org; Fri, 18 Nov 2016 03:09:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7eEr-0004He-D0 for qemu-devel@nongnu.org; Fri, 18 Nov 2016 03:09:41 -0500 Received: from mx5-phx2.redhat.com ([209.132.183.37]:34313) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c7eEr-0004HK-3X for qemu-devel@nongnu.org; Fri, 18 Nov 2016 03:09:37 -0500 Date: Fri, 18 Nov 2016 03:09:34 -0500 (EST) From: Paolo Bonzini Message-ID: <2027176914.339716.1479456574297.JavaMail.zimbra@redhat.com> In-Reply-To: <20161118002751-mutt-send-email-mst@kernel.org> References: <20161116180551.9611-1-pbonzini@redhat.com> <20161116180551.9611-3-pbonzini@redhat.com> <20161117195511-mutt-send-email-mst@kernel.org> <28571590.170644.1479412198176.JavaMail.zimbra@redhat.com> <20161118002751-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/3] virtio: access ISR atomically List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, alex williamson , borntraeger@de.ibm.com, felipe@nutanix.com ----- Original Message ----- > From: "Michael S. Tsirkin" > To: "Paolo Bonzini" > Cc: qemu-devel@nongnu.org, "alex williamson" , borntraeger@de.ibm.com, felipe@nutanix.com > Sent: Thursday, November 17, 2016 11:33:24 PM > Subject: Re: [PATCH 2/3] virtio: access ISR atomically > > On Thu, Nov 17, 2016 at 02:49:58PM -0500, Paolo Bonzini wrote: > > > > > > ----- Original Message ----- > > > From: "Michael S. Tsirkin" > > > To: "Paolo Bonzini" > > > Cc: qemu-devel@nongnu.org, "alex williamson" > > > , borntraeger@de.ibm.com, felipe@nutanix.com > > > Sent: Thursday, November 17, 2016 6:55:50 PM > > > Subject: Re: [PATCH 2/3] virtio: access ISR atomically > > > > > > On Wed, Nov 16, 2016 at 07:05:50PM +0100, Paolo Bonzini wrote: > > > > @@ -1318,10 +1318,18 @@ void virtio_del_queue(VirtIODevice *vdev, int > > > > n) > > > > vdev->vq[n].vring.num_default = 0; > > > > } > > > > > > > > +static void virtio_set_isr(VirtIODevice *vdev, int value) > > > > +{ > > > > + uint8_t old = atomic_read(&vdev->isr); > > > > + if ((old & value) != value) { > > > > + atomic_or(&vdev->isr, value); > > > > + } > > > > +} > > > > + > > > > > > Paolo, can you pls comment on why is it done like this, > > > as opposed to a single atomic_or? > > > > To avoid cacheline bouncing in the common case where MSI is active > > but the host doesn't read ISR. > > You mean the guest does not read ISR? > And so this helps keep the field read-mostly for all CPUs, > sharing the cache line. OK but this is worth documenting. Yes, v3 on the way. Paolo