Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4507464imm; Fri, 18 May 2018 06:19:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpXCtf6avAJHf9ulW0kVRlubZrtyvmhzGPSHQF9wK+1sve6QIfY0ShhfzmWZYOSq+X4ci5Q X-Received: by 2002:a17:902:b68f:: with SMTP id c15-v6mr9494836pls.201.1526649579185; Fri, 18 May 2018 06:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526649579; cv=none; d=google.com; s=arc-20160816; b=09BoV18adn2LU0LGEBjKEDabpJfJG20BmT7grV9BHCUJiUQdD0D6eSQT40akZRqHPF +8kprsyBjzhv8sk+3OAuXBs1XIRYuAsDl0/MCFh1HFrtKlO5U+mtU61jiAEA8NC1FqBp oh0iKPMuqWb9m0Mk03wZ59E/hPwrydTWRCmvq9WneJid7rcerXuMBkYzCQ9dmpANPkft FyDe0xPagmZ6PI7t7VL0bZqGth95Ria7ge3k6q3tFxNmPPnXeCerKLcxwr2FvjLfUZeH B//sMUAB7tsCq6zDEhP35dEC39NB1D/8azm53Z0xsLqMm8Wjjkh4pUwUTep7DSY3nMXW WDLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=/ZBzVll+RXmaRKqcL15owc2nU0Mhzzjqn0uOakxL/CQ=; b=1Be9ME2XCHTSLBevCak4KhxZBYnS3NvtcNMm2rwWiVNAjmGVKJlV3eACQGhlIWzP3S fBpEe1N9hatxfoMVXH9126zbehytu01aSOx9NCpxQkpEM9/OmLatQLULL/JZNlKLCmsO uPHVNPDS3ryJLEu0Hk6B856h+EFKjsrnlCsk+OwyZgtkZJPalOdEdAJAx6DuYpBf1gP7 IkXzLnXAgAxFyH3Pn1f6ArcwIGf+iu11jROy6bDUAgfyyVnLH5btYi2aPJMDEJaO8nMc nISXFd3+8kRbjTUW4pZfcHr4oYzjF1jpOwE/ps3ZQHkWxaX7zvi1AFtq4mJwB1GfzSsl UwZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4-v6si7091348plt.430.2018.05.18.06.19.23; Fri, 18 May 2018 06:19:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752277AbeERNRS (ORCPT + 99 others); Fri, 18 May 2018 09:17:18 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33128 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751496AbeERNRR (ORCPT ); Fri, 18 May 2018 09:17:17 -0400 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 D60B4402290A; Fri, 18 May 2018 13:17:16 +0000 (UTC) Received: from [10.72.12.69] (ovpn-12-69.pek2.redhat.com [10.72.12.69]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4E0983B89; Fri, 18 May 2018 13:17:08 +0000 (UTC) Subject: Re: [RFC v4 3/5] virtio_ring: add packed ring support To: Tiwei Bie Cc: mst@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, wexu@redhat.com, jfreimann@redhat.com References: <20180516083737.26504-1-tiwei.bie@intel.com> <20180516083737.26504-4-tiwei.bie@intel.com> <2000f635-bc34-71ff-ff51-a711c2e9726d@redhat.com> <20180516123909.GB986@debian> <20180516134550.GB4171@debian> <20180516143332.GA1957@debian> <20180518112950.GA28224@debian> From: Jason Wang Message-ID: Date: Fri, 18 May 2018 21:17:05 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180518112950.GA28224@debian> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US 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]); Fri, 18 May 2018 13:17:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 18 May 2018 13:17:16 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jasowang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018年05月18日 19:29, Tiwei Bie wrote: > On Thu, May 17, 2018 at 08:01:52PM +0800, Jason Wang wrote: >> On 2018年05月16日 22:33, Tiwei Bie wrote: >>> On Wed, May 16, 2018 at 10:05:44PM +0800, Jason Wang wrote: >>>> On 2018年05月16日 21:45, Tiwei Bie wrote: >>>>> On Wed, May 16, 2018 at 08:51:43PM +0800, Jason Wang wrote: >>>>>> On 2018年05月16日 20:39, Tiwei Bie wrote: >>>>>>> On Wed, May 16, 2018 at 07:50:16PM +0800, Jason Wang wrote: >>>>>>>> On 2018年05月16日 16:37, Tiwei Bie wrote: >>> [...] >>>>>>>>> +static void detach_buf_packed(struct vring_virtqueue *vq, unsigned int head, >>>>>>>>> + unsigned int id, void **ctx) >>>>>>>>> +{ >>>>>>>>> + struct vring_packed_desc *desc; >>>>>>>>> + unsigned int i, j; >>>>>>>>> + >>>>>>>>> + /* Clear data ptr. */ >>>>>>>>> + vq->desc_state[id].data = NULL; >>>>>>>>> + >>>>>>>>> + i = head; >>>>>>>>> + >>>>>>>>> + for (j = 0; j < vq->desc_state[id].num; j++) { >>>>>>>>> + desc = &vq->vring_packed.desc[i]; >>>>>>>>> + vring_unmap_one_packed(vq, desc); >>>>>>>> As mentioned in previous discussion, this probably won't work for the case >>>>>>>> of out of order completion since it depends on the information in the >>>>>>>> descriptor ring. We probably need to extend ctx to record such information. >>>>>>> Above code doesn't depend on the information in the descriptor >>>>>>> ring. The vq->desc_state[] is the extended ctx. >>>>>>> >>>>>>> Best regards, >>>>>>> Tiwei Bie >>>>>> Yes, but desc is a pointer to descriptor ring I think so >>>>>> vring_unmap_one_packed() still depends on the content of descriptor ring? >>>>>> >>>>> I got your point now. I think it makes sense to reserve >>>>> the bits of the addr field. Driver shouldn't try to get >>>>> addrs from the descriptors when cleanup the descriptors >>>>> no matter whether we support out-of-order or not. >>>> Maybe I was wrong, but I remember spec mentioned something like this. >>> You're right. Spec mentioned this. I was just repeating >>> the spec to emphasize that it does make sense. :) >>> >>>>> But combining it with the out-of-order support, it will >>>>> mean that the driver still needs to maintain a desc/ctx >>>>> list that is very similar to the desc ring in the split >>>>> ring. I'm not quite sure whether it's something we want. >>>>> If it is true, I'll do it. So do you think we also want >>>>> to maintain such a desc/ctx list for packed ring? >>>> To make it work for OOO backends I think we need something like this >>>> (hardware NIC drivers are usually have something like this). >>> Which hardware NIC drivers have this? >> It's quite common I think, e.g driver track e.g dma addr and page frag >> somewhere. e.g the ring->rx_info in mlx4 driver. > It seems that I had a misunderstanding on your > previous comments. I know it's quite common for > drivers to track e.g. DMA addrs somewhere (and > I think one reason behind this is that they want > to reuse the bits of addr field). Yes, we may want this for virtio-net as well in the future. > But tracking > addrs somewhere doesn't means supporting OOO. > I thought you were saying it's quite common for > hardware NIC drivers to support OOO (i.e. NICs > will return the descriptors OOO): > > I'm not familiar with mlx4, maybe I'm wrong. > I just had a quick glance. And I found below > comments in mlx4_en_process_rx_cq(): > > ``` > /* We assume a 1:1 mapping between CQEs and Rx descriptors, so Rx > * descriptor offset can be deduced from the CQE index instead of > * reading 'cqe->index' */ > index = cq->mcq.cons_index & ring->size_mask; > cqe = mlx4_en_get_cqe(cq->buf, index, priv->cqe_size) + factor; > ``` > > It seems that although they have a completion > queue, they are still using the ring in order. I guess so (at least from the above bits). Git grep -i "out of order" in drivers/net gives some hints. Looks like there're few deivces do this. > I guess maybe storage device may want OOO. Right, some iSCSI did. But tracking them elsewhere is not only for OOO. Spec said: for element address " In a used descriptor, Element Address is unused. " for Next flag: " For example, if descriptors are used in the same order in which they are made available, this will result in the used descriptor overwriting the first available descriptor in the list, the used descriptor for the next list overwriting the first available descriptor in the next list, etc. " for in order completion: " This will result in the used descriptor overwriting the first available descriptor in the batch, the used descriptor for the next batch overwriting the first available descriptor in the next batch, etc. " So: - It's an alignment to the spec - device may (or should) overwrite the descriptor make also make address field useless. Thanks > > Best regards, > Tiwei Bie > >> Thanks >> >>>> Not for the patch, but it looks like having a OUT_OF_ORDER feature bit is >>>> much more simpler to be started with. >>> +1 >>> >>> Best regards, >>> Tiwei Bie