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 7AF3C1BE6F for ; Wed, 4 Jul 2018 08:51:47 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2018 23:51:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="64289409" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.228]) by orsmga003.jf.intel.com with ESMTP; 03 Jul 2018 23:51:35 -0700 Date: Wed, 4 Jul 2018 14:51:36 +0800 From: Tiwei Bie To: Maxime Coquelin Cc: zhihong.wang@intel.com, jfreimann@redhat.com, dev@dpdk.org, mst@redhat.com, jasowang@redhat.com, wexu@redhat.com Message-ID: <20180704065136.GA617@debian> References: <20180702081629.29258-1-maxime.coquelin@redhat.com> <20180702081629.29258-8-maxime.coquelin@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180702081629.29258-8-maxime.coquelin@redhat.com> User-Agent: Mutt/1.9.5 (2018-04-13) Subject: Re: [dpdk-dev] [PATCH v6 07/15] vhost: extract split ring handling from Rx and Tx functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2018 06:51:47 -0000 On Mon, Jul 02, 2018 at 10:16:21AM +0200, Maxime Coquelin wrote: [...] > + > + if (unlikely(vq->access_ok == 0)) > + if (unlikely(vring_translate(dev, vq) < 0)) > + goto out; > + > + Please just keep one blank line. > + /* > + * Construct a RARP broadcast packet, and inject it to the "pkts" > + * array, to looks like that guest actually send such packet. > + * > + * Check user_send_rarp() for more information. > + * > + * broadcast_rarp shares a cacheline in the virtio_net structure > + * with some fields that are accessed during enqueue and > + * rte_atomic16_cmpset() causes a write if using cmpxchg. This could > + * result in false sharing between enqueue and dequeue. > + * > + * Prevent unnecessary false sharing by reading broadcast_rarp first > + * and only performing cmpset if the read indicates it is likely to > + * be set. > + */ > + Please remove above blank line. > + if (unlikely(rte_atomic16_read(&dev->broadcast_rarp) && > + rte_atomic16_cmpset((volatile uint16_t *) > + &dev->broadcast_rarp.cnt, 1, 0))) { > + > + rarp_mbuf = rte_net_make_rarp_packet(mbuf_pool, &dev->mac); > + if (rarp_mbuf == NULL) { > + RTE_LOG(ERR, VHOST_DATA, > + "Failed to make RARP packet.\n"); > + return 0; > + } > + count -= 1; > + } > + > + count = virtio_dev_tx_split(dev, vq, mbuf_pool, pkts, count); > + > out: > if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > vhost_user_iotlb_rd_unlock(vq); > @@ -1200,10 +1222,10 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, > * Inject it to the head of "pkts" array, so that switch's mac > * learning table will get updated first. > */ > - memmove(&pkts[1], pkts, i * sizeof(struct rte_mbuf *)); > + memmove(&pkts[1], pkts, count * sizeof(struct rte_mbuf *)); > pkts[0] = rarp_mbuf; > - i += 1; > + count += 1; > } > > - return i; > + return count; > } > -- > 2.14.4 >