From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Wang Subject: Re: [PATCH net-next v1 4/5] virtio_ring: add event idx support in packed ring Date: Tue, 10 Jul 2018 13:50:03 +0800 Message-ID: <9ee31221-9f4a-f1c5-0f0b-8d178bb536e9@redhat.com> References: <20180709072241.8886-1-tiwei.bie@intel.com> <20180709072241.8886-5-tiwei.bie@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: wexu@redhat.com, jfreimann@redhat.com To: Tiwei Bie , mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, virtio-dev@lists.oasis-open.org Return-path: Sender: List-Post: List-Help: List-Unsubscribe: List-Subscribe: In-Reply-To: <20180709072241.8886-5-tiwei.bie@intel.com> Content-Language: en-US List-Id: netdev.vger.kernel.org On 2018年07月09日 15:22, Tiwei Bie wrote: > @@ -1059,9 +1059,19 @@ static bool virtqueue_kick_prepare_packed(struct virtqueue *_vq) > * suppressions. */ > virtio_mb(vq->weak_barriers); > > + old = vq->next_avail_idx - vq->num_added; > + new = vq->next_avail_idx; > + vq->num_added = 0; > + > snapshot = *(u32 *)vq->vring_packed.device; I think we should use READ_ONCE() to prevent compiler from re-reading. > + off_wrap = virtio16_to_cpu(_vq->vdev, (__virtio16)(snapshot & 0xffff)); > flags = virtio16_to_cpu(_vq->vdev, (__virtio16)(snapshot >> 16)) & 0x3; > > + wrap_counter = off_wrap >> 15; > + event_idx = off_wrap & ~(1 << 15); > + if (wrap_counter != vq->avail_wrap_counter) > + event_idx -= vq->vring_packed.num; Thanks