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=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 6604BC433E7 for ; Tue, 20 Oct 2020 03:20:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C42A6222E9 for ; Tue, 20 Oct 2020 03:20:32 +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="ZVZ8ZUb7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C42A6222E9 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 C55B46B005C; Mon, 19 Oct 2020 23:20:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C05226B0062; Mon, 19 Oct 2020 23:20:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA62A6B0068; Mon, 19 Oct 2020 23:20:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id 7E5126B005C for ; Mon, 19 Oct 2020 23:20:31 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 178D73628 for ; Tue, 20 Oct 2020 03:20:31 +0000 (UTC) X-FDA: 77390851062.28.top43_19094642723c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id EC1AB6C05 for ; Tue, 20 Oct 2020 03:20:30 +0000 (UTC) X-HE-Tag: top43_19094642723c X-Filterd-Recvd-Size: 9427 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 20 Oct 2020 03:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603164029; 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=CsiSwlL+2IJN50SI6/sDS8MhJBfF627jTovfY55lB2o=; b=ZVZ8ZUb7FYEHnPBl1iHvb0m7ez5vBLCML7adKeiZilwyuZAkCnbKDngl1zcmmlDs797qej OC58tczIprIcJjBZY5IKEQjP30/2+52yVC6czG0gAUJpFr5YMbdnjRYkLo2FAZK5/FGBod Sijt7cERFVBO+4Fq5t9JHS4+l3pmxbs= 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-380-w2ydexCkNFab3rOppZKOhQ-1; Mon, 19 Oct 2020 23:20:26 -0400 X-MC-Unique: w2ydexCkNFab3rOppZKOhQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD37F10066FB; Tue, 20 Oct 2020 03:20:24 +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 2864355775; Tue, 20 Oct 2020 03:20:18 +0000 (UTC) Subject: Re: [RFC 0/4] Introduce VDUSE - vDPA Device in Userspace To: Xie Yongji , mst@redhat.com, akpm@linux-foundation.org Cc: 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 11:20:17 +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: <20201019145623.671-1-xieyongji@bytedance.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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/19 =E4=B8=8B=E5=8D=8810:56, Xie Yongji wrote: > This series introduces a framework, which can be used to implement > 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=20 carefully deal with the IOMMU/DMA ops stuffs. I notice that neither dma_map nor set_map is implemented in=20 vduse_vdpa_config_ops, this means you want to let vhost-vDPA to deal=20 with IOMMU domains stuffs.=C2=A0 Any reason for doing that? The reason for the questions are: 1) You've implemented a on-chip IOMMU driver but don't expose it to=20 generic IOMMU layer (or generic IOMMU layer may need some extension to=20 support this) 2) We will probably remove the IOMMU domain management in vhost-vDPA,=20 and move it to the device(parent). So if it's possible, please implement either set_map() or=20 dma_map()/dma_unmap(), this may align with our future goal and may speed=20 up the development. Btw, it would be helpful to give even more details on how the on-chip=20 IOMMU driver in implemented. > > The details and our user case is shown below: > > ------------------------ ------------------------------------------= ----------------- > | APP | | QEMU = | > | --------- | | -------------------- ----------------= ---+<-->+------ | > | |dev/vdx| | | | device emulation | | virtio datapla= ne | | BDS | | > ------------+----------- -----------+-----------------------+------= -----------+----- > | | | = | > | | emulating | offl= oading | > ------------+---------------------------+-----------------------+------= -----------+------ > | | block device | | vduse driver | | vdpa device= | | TCP/IP | | > | -------+-------- --------+-------- +------+------= - -----+---- | > | | | | | = | | > | | | | | = | | > | ----------+---------- ----------+----------- | | = | | > | | virtio-blk driver | | virtio-vdpa driver | | | = | | > | ----------+---------- ----------+----------- | | = | | > | | | | | = | | > | | ------------------ | = | | > | ----------------------------------------------------- = ---+--- | > -----------------------------------------------------------------------= ------- | NIC |--- > = ---+--- > = | > = ---------+--------- > = | Remote Storages | > = ------------------- The figure is not very clear to me in the following points: 1) if the device emulation and virtio dataplane is all implemented in=20 QEMU, what's the point of doing this? I thought the device should be a=20 remove process? 2) it would be better to draw a vDPA bus somewhere to help people to=20 understand the architecture 3) for the "offloading" I guess it should be done virtio vhost-vDPA, so=20 it's better to draw a vhost-vDPA block there > We make use of it to implement a block device connecting to > our distributed storage, which can be used in containers and > bare metal. Compared with qemu-nbd solution, this solution has > higher performance, and we can have an unified technology stack > in VM and containers for remote storages. > > To test it with a host disk (e.g. /dev/sdx): > > $ qemu-storage-daemon \ > --chardev socket,id=3Dcharmonitor,path=3D/tmp/qmp.sock,server,no= wait \ > --monitor chardev=3Dcharmonitor \ > --blockdev driver=3Dhost_device,cache.direct=3Don,aio=3Dnative,f= ilename=3D/dev/sdx,node-name=3Ddisk0 \ > --export vduse-blk,id=3Dtest,node-name=3Ddisk0,writable=3Don,vdu= se-id=3D1,num-queues=3D16,queue-size=3D128 > > The qemu-storage-daemon can be found at https://github.com/bytedance/qe= mu/tree/vduse > > Future work: > - Improve performance (e.g. zero copy implementation in datapath) > - Config interrupt support > - Userspace library (find a way to reuse device emulation code in qe= mu/rust-vmm) Right, a library will be very useful. Thanks > > Xie Yongji (4): > mm: export zap_page_range() for driver use > vduse: Introduce VDUSE - vDPA Device in Userspace > vduse: grab the module's references until there is no vduse device > vduse: Add memory shrinker to reclaim bounce pages > > drivers/vdpa/Kconfig | 8 + > drivers/vdpa/Makefile | 1 + > drivers/vdpa/vdpa_user/Makefile | 5 + > drivers/vdpa/vdpa_user/eventfd.c | 221 ++++++ > drivers/vdpa/vdpa_user/eventfd.h | 48 ++ > drivers/vdpa/vdpa_user/iova_domain.c | 488 ++++++++++++ > drivers/vdpa/vdpa_user/iova_domain.h | 104 +++ > drivers/vdpa/vdpa_user/vduse.h | 66 ++ > drivers/vdpa/vdpa_user/vduse_dev.c | 1081 +++++++++++++++++++++++++= + > include/uapi/linux/vduse.h | 85 ++ > mm/memory.c | 1 + > 11 files changed, 2108 insertions(+) > create mode 100644 drivers/vdpa/vdpa_user/Makefile > create mode 100644 drivers/vdpa/vdpa_user/eventfd.c > create mode 100644 drivers/vdpa/vdpa_user/eventfd.h > create mode 100644 drivers/vdpa/vdpa_user/iova_domain.c > create mode 100644 drivers/vdpa/vdpa_user/iova_domain.h > create mode 100644 drivers/vdpa/vdpa_user/vduse.h > create mode 100644 drivers/vdpa/vdpa_user/vduse_dev.c > create mode 100644 include/uapi/linux/vduse.h >