From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id CCA671BF1E for ; Wed, 4 Jul 2018 23:04:25 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 152A0402242D; Wed, 4 Jul 2018 21:04:25 +0000 (UTC) Received: from [10.36.112.34] (ovpn-112-34.ams2.redhat.com [10.36.112.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D4887C4C; Wed, 4 Jul 2018 21:04:19 +0000 (UTC) To: Tiwei Bie Cc: zhihong.wang@intel.com, jfreimann@redhat.com, dev@dpdk.org, mst@redhat.com, jasowang@redhat.com, wexu@redhat.com References: <20180702081629.29258-1-maxime.coquelin@redhat.com> <20180702081629.29258-8-maxime.coquelin@redhat.com> <20180704065136.GA617@debian> From: Maxime Coquelin Message-ID: Date: Wed, 4 Jul 2018 23:04:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180704065136.GA617@debian> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 04 Jul 2018 21:04:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 04 Jul 2018 21:04:25 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' 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 21:04:26 -0000 On 07/04/2018 08:51 AM, Tiwei Bie wrote: > 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 >> Done, Thanks, Maxime