From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f46.google.com (mail-vk0-f46.google.com [209.85.213.46]) by dpdk.org (Postfix) with ESMTP id 0FE93293B for ; Tue, 5 Apr 2016 00:57:12 +0200 (CEST) Received: by mail-vk0-f46.google.com with SMTP id c4so74602080vkb.3 for ; Mon, 04 Apr 2016 15:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bigswitch-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=d7eEUz1vxrifbWkYTfKgVA38tvnEjElGgBe1PaQ5qKg=; b=wbWS6ptqE3hU8Z3qQ+MOYjOB6jqpYFJvfIC3a/+NFB6zyofDqtLrymspuhyC5AMe06 vjib1mT3ZpoLH46FMhzQunoh7raDh9k6J5iuJqF1Ov7jYoxCkCZ3s2pKLgZYZGwiHwgE t0vy8tSdSA7HmLlL5GilmZfAbujH6QdkClxDLnGjOG4lCd7DtWpIWO1zGuCR/SyHD3L4 uAYTO+y9kMy04VLNYIqcIkk8pIXCatziMwJKQ4/wHiWgZlxb/LnpWuqrQEnizBoxa9on 0roT3mRivD3ckgafJB3JHvTYHrk3++T9o13XpS/hsHj3dednaCDrfz9GYj3lXtcZl3j/ Rlyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=d7eEUz1vxrifbWkYTfKgVA38tvnEjElGgBe1PaQ5qKg=; b=G/hHSs66KUwAwoxcuZAnLKBHiAFj3frRXSwMDWwyrIpeutJtrOmZVPRIRnQ0CGD8AO +7v8beV6Di+pEJyAKH1KhoqzZQcXqTcv4DP3wzpa13g8CNtvZCT6JW+bqf+GqDdhjT0o PlPvlzbO3nFsv8H8xu2gagNEeLr2wsND4S8JsbCkwPjUnkGdELrPqtjL77NnWGk1ngvn nGhY1RgpYVyTseAOTFlfRvapwyBNu0llR6I9U6jc7DjWODe0DQrgV6fvCFOcWCpHvrNg OEoHU3dT0IX8/FU8qJ6cKDCODd12zYn3RZkmD/uCcjlUbFPwNLm7yenqRbB06Bgkblol 1+qA== X-Gm-Message-State: AD7BkJLJf4j93luUkzJ178koBelrynSOdyUDsnnOBy5G/9Ze/Ib/uac+6MHP305TWh7Ul2stE68CqOB7JWBaK+3J MIME-Version: 1.0 X-Received: by 10.159.36.114 with SMTP id 105mr4238242uaq.30.1459810631475; Mon, 04 Apr 2016 15:57:11 -0700 (PDT) Received: by 10.31.221.194 with HTTP; Mon, 4 Apr 2016 15:57:11 -0700 (PDT) In-Reply-To: <20160404200538.GK3080@yliu-dev.sh.intel.com> References: <1459454476-6029-1-git-send-email-rlane@bigswitch.com> <2344074.HmCM8hzj4i@xps13> <20160404200538.GK3080@yliu-dev.sh.intel.com> Date: Mon, 4 Apr 2016 15:57:11 -0700 Message-ID: From: Rich Lane To: Yuanhan Liu Cc: Thomas Monjalon , "Xie, Huawei" , dev@dpdk.org, stephen@networkplumber.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] virtio: use zeroed memory for simple TX header 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: Mon, 04 Apr 2016 22:57:12 -0000 On Mon, Apr 4, 2016 at 1:05 PM, Yuanhan Liu wrote: > On Mon, Apr 04, 2016 at 03:13:37PM +0200, Thomas Monjalon wrote: > > Huawei, Yuanhan, any comment? > > > > 2016-03-31 13:01, Rich Lane: > > > vq->vq_ring.desc[i + mid_idx].next = i; > > > vq->vq_ring.desc[i + mid_idx].addr = > > > - vq->virtio_net_hdr_mem + > > > - i * vq->hw->vtnet_hdr_size; > > > + vq->virtio_net_hdr_mem; > > I could be wrong, but this looks like a special case when i == 0, > which is by no way that zeroed memory is guaranteed? Huawei, do > you have time to check this patch? This bug exists because the type of the objects pointed to by virtio_net_hdr_mem changed in 6dc5de3a (virtio: use indirect ring elements), but because it isn't a C pointer the compiler didn't catch the type mismatch. We could also fix it with: vq->virtio_net_hdr_mem + i * sizeof(struct virtio_tx_region) + offsetof(struct virtio_tx_region, tx_hdr) Given that tx_hdr is the first member in struct virtio_tx_region, and using a single header optimizes cache use, that simplifies to the code in my patch. The virtio-net header is never written to by simple TX so it remains zeroed. I can respin the patch using offsetof if that's preferred. Note that right now virtio simple TX is broken with DPDK vhost due to the flood of error messages.