From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 558382BF7 for ; Fri, 14 Oct 2016 09:24:20 +0200 (CEST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 870276647; Fri, 14 Oct 2016 07:24:19 +0000 (UTC) Received: from [10.36.7.225] (vpn1-7-225.ams2.redhat.com [10.36.7.225]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9E7OGdO020930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Oct 2016 03:24:17 -0400 To: Yuanhan Liu References: <1475773241-5714-1-git-send-email-maxime.coquelin@redhat.com> <1476171927-10134-1-git-send-email-maxime.coquelin@redhat.com> <20161011090146.GP1597@yliu-dev.sh.intel.com> Cc: dev@dpdk.org, mst@redhat.com, jianfeng.tan@intel.com, olivier.matz@6wind.com, stephen@networkplumber.org From: Maxime Coquelin Message-ID: <22713706-48a4-803e-aed9-811248bae699@redhat.com> Date: Fri, 14 Oct 2016 09:24:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20161011090146.GP1597@yliu-dev.sh.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 14 Oct 2016 07:24:19 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH v2] vhost: Only access header if offloading is supported in dequeue path 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: Fri, 14 Oct 2016 07:24:20 -0000 On 10/11/2016 11:01 AM, Yuanhan Liu wrote: > On Tue, Oct 11, 2016 at 09:45:27AM +0200, Maxime Coquelin wrote: >> @@ -684,12 +699,12 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vring_desc *descs, >> struct rte_mempool *mbuf_pool) >> { >> struct vring_desc *desc; >> - uint64_t desc_addr; >> + uint64_t desc_addr = 0; >> uint32_t desc_avail, desc_offset; >> uint32_t mbuf_avail, mbuf_offset; >> uint32_t cpy_len; >> struct rte_mbuf *cur = m, *prev = m; >> - struct virtio_net_hdr *hdr; >> + struct virtio_net_hdr *hdr = NULL; >> /* A counter to avoid desc dead loop chain */ >> uint32_t nr_desc = 1; >> >> @@ -698,12 +713,14 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vring_desc *descs, >> (desc->flags & VRING_DESC_F_INDIRECT)) >> return -1; >> >> - desc_addr = gpa_to_vva(dev, desc->addr); >> - if (unlikely(!desc_addr)) >> - return -1; >> + if (virtio_net_with_host_offload(dev)) { >> + desc_addr = gpa_to_vva(dev, desc->addr); >> + if (unlikely(!desc_addr)) >> + return -1; >> >> - hdr = (struct virtio_net_hdr *)((uintptr_t)desc_addr); >> - rte_prefetch0(hdr); >> + hdr = (struct virtio_net_hdr *)((uintptr_t)desc_addr); >> + rte_prefetch0(hdr); >> + } >> >> /* >> * A virtio driver normally uses at least 2 desc buffers >> @@ -720,18 +737,24 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vring_desc *descs, >> if (unlikely(!desc_addr)) >> return -1; >> >> - rte_prefetch0((void *)(uintptr_t)desc_addr); >> - >> desc_offset = 0; >> desc_avail = desc->len; >> nr_desc += 1; >> - >> - PRINT_PACKET(dev, (uintptr_t)desc_addr, desc->len, 0); >> } else { >> + if (!desc_addr) { >> + desc_addr = gpa_to_vva(dev, desc->addr); >> + if (unlikely(!desc_addr)) >> + return -1; >> + } >> + > > I think this piece of code make things a bit complex. I think what you > want to achieve is, besides saving hdr prefetch, to save one call to > gpa_to_vva() for the non-ANY_LAYOUT case. Does that matter too much? > > How about just saving the hdr prefetch? > > if (virtio_net_with_host_offload(dev)) { > hdr = (struct virtio_net_hdr *)((uintptr_t)desc_addr); > rte_prefetch0(hdr); > } Oops, you reply slipped through the cracks... You're right, it doesn't matter too much, the thing to avoid id definitely the hdr prefetch and access. I'm sending a v3 now. Thanks, Maxime