From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CD6BC433DF for ; Tue, 20 Oct 2020 08:01:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F6CB222E8 for ; Tue, 20 Oct 2020 08:01:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Pxawn+wT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F6CB222E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B967C6B005C; Tue, 20 Oct 2020 04:01:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B486A6B0062; Tue, 20 Oct 2020 04:01:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A37086B0068; Tue, 20 Oct 2020 04:01:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 73C2C6B005C for ; Tue, 20 Oct 2020 04:01:45 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0A628181AEF1A for ; Tue, 20 Oct 2020 08:01:45 +0000 (UTC) X-FDA: 77391559770.06.rod16_45106682723e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id C1BF510269E8E for ; Tue, 20 Oct 2020 08:01:44 +0000 (UTC) X-HE-Tag: rod16_45106682723e X-Filterd-Recvd-Size: 9098 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 08:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603180903; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nQarwNjEMfQ1ltnkQfUYDu0cq5r+xzk15cAJFI+bn8k=; b=Pxawn+wTm1EQl+jceYhfR85WffI+U2ftRnWB5YlVeCzV/JMQQ63PUDNDt8U0f6hZb0dSWL foZKyjSPLcbFe16eGwQRpneAENDb4aMHvH4Vc4HfJlB+jYPRGXZbxBpfVLERuKwryz1Rhh O7tMkuTVB8UfPHoQsi8PK0UyrKiWzFA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-UPC5wQf2NsOazfw1-K5r4A-1; Tue, 20 Oct 2020 04:01:41 -0400 X-MC-Unique: UPC5wQf2NsOazfw1-K5r4A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 222261868420; Tue, 20 Oct 2020 08:01:40 +0000 (UTC) Received: from [10.72.13.171] (ovpn-13-171.pek2.redhat.com [10.72.13.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEC7A5D9D2; Tue, 20 Oct 2020 08:01:34 +0000 (UTC) Subject: Re: [External] Re: [RFC 0/4] Introduce VDUSE - vDPA Device in Userspace To: Yongji Xie Cc: "Michael S. Tsirkin" , akpm@linux-foundation.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org References: <20201019145623.671-1-xieyongji@bytedance.com> From: Jason Wang Message-ID: Date: Tue, 20 Oct 2020 16:01:32 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2020/10/20 =E4=B8=8B=E5=8D=883:39, Yongji Xie wrote: > > > On Tue, Oct 20, 2020 at 11:20 AM Jason Wang > wrote: > > > On 2020/10/19 =E4=B8=8B=E5=8D=8810:56, Xie Yongji wrote: > > This series introduces a framework, which can be used to implemen= t > > vDPA Devices in a userspace program. To implement it, the work > > consist of two parts: control path emulating and data path > offloading. > > > > In the control path, the VDUSE driver will make use of message > > mechnism to forward the actions (get/set features, get/st status, > > get/set config space and set virtqueue states) from virtio-vdpa > > driver to userspace. Userspace can use read()/write() to > > receive/reply to those control messages. > > > > In the data path, the VDUSE driver implements a MMU-based > > on-chip IOMMU driver which supports both direct mapping and > > indirect mapping with bounce buffer. Then userspace can access > > those iova space via mmap(). Besides, eventfd mechnism is used to > > trigger interrupts and forward virtqueue kicks. > > > This is pretty interesting! > > For vhost-vdpa, it should work, but for virtio-vdpa, I think we > should > carefully deal with the IOMMU/DMA ops stuffs. > > > I notice that neither dma_map nor set_map is implemented in > vduse_vdpa_config_ops, this means you want to let vhost-vDPA to dea= l > with IOMMU domains stuffs.=C2=A0 Any reason for doing that? > > Actually, this series only focus on virtio-vdpa case now. To support=20 > vhost-vdpa,=C2=A0 as you said, we need to implement dma_map/dma_unmap. = But=20 > there is a limit that vm's memory can't be anonymous pages which are=20 > forbidden in vm_insert_page(). Maybe we need to add some limits on=20 > vhost-vdpa? I'm not sure I get this, any reason that you want to use=20 vm_insert_page() to VM's memory. Or do you mean you want to implement=20 some kind of zero-copy? I guess from the software device implemention in user space it only need=20 to receive IOVA ranges and map them in its own address space. > The reason for the questions are: > > 1) You've implemented a on-chip IOMMU driver but don't expose it to > generic IOMMU layer (or generic IOMMU layer may need some > extension to > support this) > 2) We will probably remove the IOMMU domain management in vhost-vDP= A, > and move it to the device(parent). > > So if it's possible, please implement either set_map() or > dma_map()/dma_unmap(), this may align with our future goal and may > speed > up the development. > > Btw, it would be helpful to give even more details on how the on-ch= ip > IOMMU driver in implemented. > > > The basic idea is treating MMU (VA->PA) as IOMMU (IOVA->PA). And using=20 > vm_insert_page()/zap_page_range() to do address mapping/unmapping. And=20 > the address mapping will be done in page fault handler because=20 > vm_insert_page() can't be called in atomic_context such=20 > as=C2=A0dma_map_ops->map_page(). Ok, please add it in the cover letter or patch 2 in the next version. > > > > > The details and our user case is shown below: > > > > ------------------------ > =C2=A0----------------------------------------------------------- > > |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 A= PP |=C2=A0 =C2=A0 =C2=A0| QEMU=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| > > |=C2=A0 =C2=A0 =C2=A0 =C2=A0---------=C2=A0 =C2=A0 =C2=A0 |=C2=A0= =C2=A0 =C2=A0| -------------------- > -------------------+<-->+------ | > > |=C2=A0 =C2=A0 =C2=A0 =C2=A0|dev/vdx|=C2=A0 =C2=A0 =C2=A0 |=C2=A0= =C2=A0 =C2=A0| | device emulation | | virtio > dataplane |=C2=A0 =C2=A0 | BDS | | > > ------------+----------- > =C2=A0-----------+-----------------------+-----------------+----- > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0| =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0| > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0| emulating =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| > offloading=C2=A0 =C2=A0 =C2=A0 | > > > ------------+---------------------------+-----------------------+--= ---------------+------ > > |=C2=A0 =C2=A0 | block device |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0|=C2=A0 vduse driver | =C2=A0 |=C2=A0 vdpa > device |=C2=A0 =C2=A0 | TCP/IP | | > > |=C2=A0 =C2=A0 -------+--------=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0--------+-------- =C2=A0 > +------+-------=C2=A0 =C2=A0 =C2=A0-----+---- | > > |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= | =C2=A0 |=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0| > > |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= | =C2=A0 |=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0| > > | ----------+----------=C2=A0 =C2=A0 =C2=A0 =C2=A0----------+----= ------- =C2=A0|=C2=A0 =C2=A0 =C2=A0 |=C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0= =C2=A0| > > | | virtio-blk driver |=C2=A0 =C2=A0 =C2=A0 =C2=A0| virtio-vdpa d= river | =C2=A0|=C2=A0 =C2=A0 =C2=A0 |=C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0= =C2=A0| > > | ----------+----------=C2=A0 =C2=A0 =C2=A0 =C2=A0----------+----= ------- =C2=A0|=C2=A0 =C2=A0 =C2=A0 |=C2=A0 > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0= =C2=A0| > > |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= | =C2=A0 |=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0| > > |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0---------------= ---=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0|=C2=A0 =C2=A0 =C2=A0| > > | =C2=A0----------------------------------------------------- =C2= =A0 =C2=A0 =C2=A0 =C2=A0 > ---+---=C2=A0 | > > > -------------------------------------------------------------------= ----------- > | NIC |--- > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0---+--- > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0---------+--------- > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0| Remote Storages | > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0------------------- > > > The figure is not very clear to me in the following points: > > 1) if the device emulation and virtio dataplane is all implemented = in > QEMU, what's the point of doing this? I thought the device should > be a > remove process? > > 2) it would be better to draw a vDPA bus somewhere to help people t= o > understand the architecture > 3) for the "offloading" I guess it should be done virtio > vhost-vDPA, so > it's better to draw a vhost-vDPA block there > > > This figure only shows virtio-vdpa case, I will take vhost-vdpa case=20 > into consideration=C2=A0in next version. Please do that, otherwise this proposal is incomplete. Thanks > > Thanks, > Yongji