From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id E475D2BB5 for ; Sun, 18 Sep 2016 04:55:16 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 17 Sep 2016 19:55:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,354,1470726000"; d="scan'208";a="10436097" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by orsmga005.jf.intel.com with ESMTP; 17 Sep 2016 19:55:14 -0700 Date: Sun, 18 Sep 2016 10:55:42 +0800 From: Yuanhan Liu To: Maxime Coquelin Cc: "Wang, Zhihong" , "dev@dpdk.org" , "thomas.monjalon@6wind.com" Message-ID: <20160918025542.GC23158@yliu-dev.sh.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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52dba6dc-ca0d-1aeb-cf18-89470450a183@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v5 5/6] vhost: batch update used ring 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: Sun, 18 Sep 2016 02:55:17 -0000 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 = vq->size - used_idx_start; > >>>+ uint32_t part_2 = 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. Agreed, that will be better; it could avoid repeating similar code block 3 times. > I don't have a strong opinion on this, if Yuanhan is fine > with current code, that's ok for me. >>From what I know, that's kind of DPDK prefered way, to expand code when necessary. For example, 9ec201f5d6e7 ("mbuf: provide bulk allocation"). So I'm fine with it. --yliu