From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Wang, Zhihong" Subject: Re: [PATCH v5 5/6] vhost: batch update used ring Date: Sun, 18 Sep 2016 02:57:40 +0000 Message-ID: <8F6C2BD409508844A0EFC19955BE09414E79A025@SHSMSX103.ccr.corp.intel.com> References: <1471319402-112998-1-git-send-email-zhihong.wang@intel.com> <1473392368-84903-1-git-send-email-zhihong.wang@intel.com> <1473392368-84903-6-git-send-email-zhihong.wang@intel.com> <473ef253-86bf-9a7a-d028-21c27690a421@redhat.com> <8F6C2BD409508844A0EFC19955BE09414E70FB6A@SHSMSX103.ccr.corp.intel.com> <52dba6dc-ca0d-1aeb-cf18-89470450a183@redhat.com> <20160918025542.GC23158@yliu-dev.sh.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , "thomas.monjalon@6wind.com" To: Yuanhan Liu , Maxime Coquelin Return-path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 540F62BA9 for ; Sun, 18 Sep 2016 04:57:45 +0200 (CEST) In-Reply-To: <20160918025542.GC23158@yliu-dev.sh.intel.com> Content-Language: en-US List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] > Sent: Sunday, September 18, 2016 10:56 AM > To: Maxime Coquelin > Cc: Wang, Zhihong ; dev@dpdk.org; > thomas.monjalon@6wind.com > Subject: Re: [PATCH v5 5/6] vhost: batch update used ring >=20 > On Thu, Sep 15, 2016 at 06:38:06PM +0200, Maxime Coquelin wrote: > > >>>+static inline void __attribute__((always_inline)) > > >>>+flush_used_ring(struct virtio_net *dev, struct vhost_virtqueue *vq, > > >>>+ uint32_t used_idx_start) > > >>>+{ > > >>>+ if (used_idx_start + vq->shadow_used_idx < vq->size) { > > >>>+ rte_memcpy(&vq->used->ring[used_idx_start], > > >>>+ &vq->shadow_used_ring[0], > > >>>+ vq->shadow_used_idx * > > >>>+ sizeof(struct vring_used_elem)); > > >>>+ vhost_log_used_vring(dev, vq, > > >>>+ offsetof(struct vring_used, > > >>>+ ring[used_idx_start]), > > >>>+ vq->shadow_used_idx * > > >>>+ sizeof(struct vring_used_elem)); > > >>>+ } else { > > >>>+ uint32_t part_1 =3D vq->size - used_idx_start; > > >>>+ uint32_t part_2 =3D vq->shadow_used_idx - part_1; > > >>>+ > > >>>+ rte_memcpy(&vq->used->ring[used_idx_start], > > >>>+ &vq->shadow_used_ring[0], > > >>>+ part_1 * > > >>>+ sizeof(struct vring_used_elem)); > > >>>+ vhost_log_used_vring(dev, vq, > > >>>+ offsetof(struct vring_used, > > >>>+ ring[used_idx_start]), > > >>>+ part_1 * > > >>>+ sizeof(struct vring_used_elem)); > > >>>+ rte_memcpy(&vq->used->ring[0], > > >>>+ &vq->shadow_used_ring[part_1], > > >>>+ part_2 * > > >>>+ sizeof(struct vring_used_elem)); > > >>>+ vhost_log_used_vring(dev, vq, > > >>>+ offsetof(struct vring_used, > > >>>+ ring[0]), > > >>>+ part_2 * > > >>>+ sizeof(struct vring_used_elem)); > > >>>+ } > > >>> } > > >>Is expanding the code done for performance purpose? > > > > > >Hi Maxime, > > > > > >Yes theoretically this has the least branch number. > > >And I think the logic is simpler this way. > > Ok, in that case, maybe you could create a function to > > do the rte_memcpy and the vhost_log_used on a given range. >=20 > Agreed, that will be better; it could avoid repeating similar code > block 3 times. Okay. Thanks for the suggestion, Maxime and Yuanhan. >=20 > > I don't have a strong opinion on this, if Yuanhan is fine > > with current code, that's ok for me. >=20 > From what I know, that's kind of DPDK prefered way, to expand code > when necessary. For example, 9ec201f5d6e7 ("mbuf: provide bulk > allocation"). >=20 > So I'm fine with it. >=20 > --yliu