Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1312301imm; Mon, 9 Jul 2018 22:51:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfwp4V+I0WJFnE/HnOth460B4d+FLumlKBtqOW3W84C8E+An4uKaHxu6wiKy/Z1kt9JCpkB X-Received: by 2002:a17:902:8f86:: with SMTP id z6-v6mr23255883plo.38.1531201865832; Mon, 09 Jul 2018 22:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531201865; cv=none; d=google.com; s=arc-20160816; b=WiZSR3d2mB+zIPB6h7LsGhPvfpXTFRmje0niD/uxn7JXhO+dk6iKWdgsrzgI6pzz5+ gA1QxgMb2vBckCNN6yR+0AzFTA4i6yBycQ5hRKG4jgzwIp4UDI2ZTlKslduZbdsh56hB ZMrWk/PlRS564X4DffS/zXOG3b/PbiE3s3jmCA8U1jA3G5sUTVwicXRYzOqf1tr8oN5o D6fysUbfnWt1k3YUkkZ1PeXdrja+hxp4Tupu0Gxc4NvxwICCoayDLVBnyKtVD8WfisUa 6ToDCkqGsNTsu9NtaddEIjbraNgS02iG/sqI2BqNffgTvZC96YfEDbeKDIB3kUBdSWQN T8CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=3VvaikqEZOO7pdwV20phpqHYAahHrcZS+/pK0N8/PQk=; b=bf99ZTv6OpZXDyUQ8RuDuXQfdpArCMB84um+lngWsBnF0zLRtY8Ir20+jtMInfV/VR /y6b1UlMWNuvUtmAtZ3wNTVerK6x2HfG7i2VI//joiMdn7x0/v/dwhDo4eJBODtdKHHU 0wk1EvN3krQ81cz8vVKYut7IMNO5soSCIrnpgm4ijhBxEtZBdgqljL1gGFA0ir1nDxA9 QIC+fVkDoFbWp8m80Skj9fRtazoPpQzMQFkVavctZ1FzaAy0IiqWBBJkbJoTGokZtw2w tQkFRYLc8nXRl8CwqA6hwmeqNhaKLbVEQcbGg54FRN1yo3WUSY2VqqPYsM543jeDgD5s LNcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q65-v6si15556409pga.283.2018.07.09.22.50.50; Mon, 09 Jul 2018 22:51:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751235AbeGJFuN (ORCPT + 99 others); Tue, 10 Jul 2018 01:50:13 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39444 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751005AbeGJFuL (ORCPT ); Tue, 10 Jul 2018 01:50:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 170C3402312B; Tue, 10 Jul 2018 05:50:11 +0000 (UTC) Received: from [10.72.12.151] (ovpn-12-151.pek2.redhat.com [10.72.12.151]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 676612026D6B; Tue, 10 Jul 2018 05:50:06 +0000 (UTC) Subject: Re: [PATCH net-next v1 4/5] virtio_ring: add event idx support in packed ring 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 Cc: wexu@redhat.com, jfreimann@redhat.com References: <20180709072241.8886-1-tiwei.bie@intel.com> <20180709072241.8886-5-tiwei.bie@intel.com> From: Jason Wang Message-ID: <9ee31221-9f4a-f1c5-0f0b-8d178bb536e9@redhat.com> Date: Tue, 10 Jul 2018 13:50:03 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180709072241.8886-5-tiwei.bie@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 10 Jul 2018 05:50:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 10 Jul 2018 05:50:11 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jasowang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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