From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 4D8FB6707 for ; Tue, 27 Jan 2015 17:16:54 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 27 Jan 2015 08:10:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,475,1418112000"; d="scan'208";a="518412110" Received: from pgsmsx103.gar.corp.intel.com ([10.221.44.82]) by orsmga003.jf.intel.com with ESMTP; 27 Jan 2015 08:09:12 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX103.gar.corp.intel.com (10.221.44.82) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 28 Jan 2015 00:16:12 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.64]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.129]) with mapi id 14.03.0195.001; Wed, 28 Jan 2015 00:16:11 +0800 From: "Xie, Huawei" To: Stephen Hemminger Thread-Topic: [dpdk-dev] [PATCH v2 02/24] virtio: Use weaker barriers Thread-Index: AQHQOdplIBvPxnxbzU2OvnOFGg/hwpzTiENA//+tiICAAO6Z8A== Date: Tue, 27 Jan 2015 16:16:10 +0000 Message-ID: References: <1421298930-15210-1-git-send-email-changchun.ouyang@intel.com> <1422326164-13697-1-git-send-email-changchun.ouyang@intel.com> <1422326164-13697-3-git-send-email-changchun.ouyang@intel.com> <20150127095831.1572b67a@uryu.home.lan> In-Reply-To: <20150127095831.1572b67a@uryu.home.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v2 02/24] virtio: Use weaker barriers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2015 16:16:54 -0000 > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Tuesday, January 27, 2015 5:59 PM > To: Xie, Huawei > Cc: Ouyang, Changchun; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v2 02/24] virtio: Use weaker barriers >=20 >=20 > > I recall our original code is virtio_wmb(). > > Use store fence to ensure all updates to entries before updating the in= dex. > > Why do we need virtio_rmb() here and add virtio_wmb after > vq_update_avail_idx()? >=20 > Store fence is unnecessary, Intel CPU's are cache coherent, please read > the virtio Linux ring header file for explanation. A full fence WMB > is more expensive and causes CPU stall >=20 I mean virtio_wmb rather than virtio_rmb should be used here,=20 and both of them are defined as compiler barrier. The following code is linux virtio driver for adding buffer to vring. /* Put entry in available array (but don't update avail->idx until they * do sync). */ avail =3D (vq->vring.avail->idx & (vq->vring.num-1)); vq->vring.avail->ring[avail] =3D head; /* Descriptors and available array need to be set before we expose the * new available array entries. */ virtio_wmb(vq->weak_barriers); vq->vring.avail->idx++; > > > vq->vq_ring.avail->idx =3D vq->vq_avail_idx; > > > } > > > > > > @@ -255,7 +264,7 @@ static inline void > > > virtqueue_notify(struct virtqueue *vq) > > > { > > > /* > > > - * Ensure updated avail->idx is visible to host. mb() necessary? > > > + * Ensure updated avail->idx is visible to host. > > > * For virtio on IA, the notificaiton is through io port operation > > > * which is a serialization instruction itself. > > > */ > > > -- > > > 1.8.4.2 > >