Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2317594imm; Tue, 10 Jul 2018 18:10:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfju3DdJzIgQBV1C10gfmb3HMI9uKjGYdRXzRwlKd8toF8Q+KhJVWBIC0rh2YCUhDGQcmch X-Received: by 2002:a63:ac57:: with SMTP id z23-v6mr18155822pgn.74.1531271418930; Tue, 10 Jul 2018 18:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531271418; cv=none; d=google.com; s=arc-20160816; b=YjezD2vJFsVeQxsu0Vs76Le6RQy1LaSfaVz+Yy7USJPl6Y+j1iERxPT0245Ot1CH9O JJmlQ49nUc0570fE420Bj85ukxI9X0JFgx8Lz+65vVMaztm5ZyrVTZY1V4cao2G2nAlu K+TwBwGKroeisYdBJMZaxKeePX96g26NW3xmBoQMOTym/AvDyuq9Ta+CbODCL2LrAsdO Ongo4yeF6lG9s8RnzvJPmBVyOChaFCkNZHlBDA4oFf09yBWv6axlsorwFbhM3V6byRAD kBBSOJbrLhEjC7CIy2sbb2+ExXj1iI2o7acw6KQq8FpAqgkN0t+WAhpdARIlgFK414Uw na2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=en3cDuyP9LR8Su2V028OhoOEm9+vh8ta6U5FREFZNsU=; b=QuOGUsgjXLsGnxuA9C+YInd1N7jtIHVaWrh2MYy91PVqX+xnlzkLA2iQW7gmJ2K/AX t+C19YKEVd+n7+a8pEFyUOZkQfMjT71T6JCOV47H639caooOvzF+Jj8HScwqOMpYaYXM Iu1dnL0Y4v+uch9HpIqtrYq93N6JR/HnmgcxJ0217S93WqBi0R+73EOWSJTgrlU4CDMd inrMVbSqyvUdU3r8/Erh9k12d9+Sg9/KKvVMpYHUQi/DYWd6iPMb95GxBsgSJWZr0rnI +y6Fn/s09qsXn+/62hqp8My1U+pchH9TTaBFojw9iixYeskyayIZjqyIdDtDrKL8tGJC GQfA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d23-v6si19048618pfl.122.2018.07.10.18.10.03; Tue, 10 Jul 2018 18:10:18 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732397AbeGKBLC (ORCPT + 99 others); Tue, 10 Jul 2018 21:11:02 -0400 Received: from mga04.intel.com ([192.55.52.120]:44237 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732278AbeGKBLC (ORCPT ); Tue, 10 Jul 2018 21:11:02 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 18:09:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,336,1526367600"; d="scan'208";a="215011065" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.228]) by orsmga004.jf.intel.com with ESMTP; 10 Jul 2018 18:09:18 -0700 Date: Wed, 11 Jul 2018 09:09:05 +0800 From: Tiwei Bie To: Jason Wang Cc: mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, virtio-dev@lists.oasis-open.org, wexu@redhat.com, jfreimann@redhat.com Subject: Re: [virtio-dev] Re: [PATCH net-next v1 4/5] virtio_ring: add event idx support in packed ring Message-ID: <20180711010905.GB28235@debian> References: <20180709072241.8886-1-tiwei.bie@intel.com> <20180709072241.8886-5-tiwei.bie@intel.com> <9ee31221-9f4a-f1c5-0f0b-8d178bb536e9@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9ee31221-9f4a-f1c5-0f0b-8d178bb536e9@redhat.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 10, 2018 at 01:50:03PM +0800, Jason Wang wrote: > 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. I'll do it. Thanks! Best regards, Tiwei Bie > > > + 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 >