Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1041227pxb; Thu, 9 Sep 2021 18:48:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbTEV5beIcLhU/AzaXvAqIRIpW6vS6e/hSqWOAtCFjaopI5IxZbht8tYgqQNDRr9I5Ef9Z X-Received: by 2002:a05:6638:2728:: with SMTP id m40mr2380293jav.141.1631238520592; Thu, 09 Sep 2021 18:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631238520; cv=none; d=google.com; s=arc-20160816; b=wWY7jXB69Z7ol+diVYD5IqSx7ZK29zGsiZV7lMABlpCjmcj0VKAwVlJinksLvVMADc /dkSUSViswuZ8JpbM/nUDyYa3py27P0vgSIDssWSrMgATTaezic+NKV0utHW3k5Uua74 ctnBzoX6PB6QItGqkdEsRmYC+x97ure4tPQgJ0RcXJGoZoluKphxSr4CQLdnFBmhqdig YL8iT6hXNKr1IwjqL7spPx/ACknE3DfUhA3QIBd67sw8O+knLzqDSn01eJFYFjYp6HqB ob/Kj8CoJIpXBhOnLmMzUECvCKzYkIdemsI2U1NwZPEo8cJq8BOvuZauiOWJJaxvLJfY zfSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oI/LTBnGx8tsMH92BXl9TylxJCNSHKhi0QiJerVLXGo=; b=y28+Gk4qr9UGq53pMQ6tbcGsmG4Rn6IHms284Rbny+6HZXI7wA8m9cCDx2IIk5R4nR BQc9m28kfIwfblLTWbzEuAfM0yie1fJkkbcTJeLxRyKTslmJvH3uLng8zA/7oViCRbU7 O3oMouHMhiTe2EnoXezpmyD0tYXWhehCtS9xGZ0nPDzjmYmMHbzSaOOQnz1zGz0HIpsu PSc2C0OtXEYGd2M9qwC7s3tIml9pS/NSANdXHUGe6IJX8yA5k1agvuSH8D1/ev9CwHAQ 6+RwUVwE+5TJi8mmijQjBEqEaN+gUhyKuK2LBQaMT5rkwLON6Ok5dsUse3+4MJAXkaMF oIXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20150623.gappssmtp.com header.s=20150623 header.b=sXsCND7E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si3889219jat.54.2021.09.09.18.48.29; Thu, 09 Sep 2021 18:48:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@igel-co-jp.20150623.gappssmtp.com header.s=20150623 header.b=sXsCND7E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229538AbhIJBrl (ORCPT + 99 others); Thu, 9 Sep 2021 21:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbhIJBrk (ORCPT ); Thu, 9 Sep 2021 21:47:40 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C44C061575 for ; Thu, 9 Sep 2021 18:46:30 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id f18so753365lfk.12 for ; Thu, 09 Sep 2021 18:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=oI/LTBnGx8tsMH92BXl9TylxJCNSHKhi0QiJerVLXGo=; b=sXsCND7EDImjW5ay/AxrcG6JlKNdyzLJuZwVRKq9BSVweWds9UvhXX2cxxA6kHdqvp rvIrL75fRp7S65LlOLpYuAV3A+4XK0cGkKfnDK3fdmK7+9LrYBsMU5/WG3qQlipl/JHD EBmpCHISNVj+keaUstyu/nJcrz06FdMeKmL1VYQxCwUigGK1OuSfvmCxtD+MtkKkYEhF I/7xIaxoY7rLUXecG3amxOoxaLeir7kME+KiQKSW5ruG9d3R1XJRc3R9lOnioUtoxeQE fDGHrjY/GfPwnsGC1p9iUryioErkLFiyM5GzFmimU+wPYpMwg0S8FafaqMETXrfahT9g 2gpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oI/LTBnGx8tsMH92BXl9TylxJCNSHKhi0QiJerVLXGo=; b=fTGoiran4bVD/31Q94DUYXhP5Px9atRyVkfFB/IrJGp4wfR9YKuNVHvFTqLqj41ZqH fqvl7ll5bQChHs9wodcVD7KicaNgLnsvEKS8k328cIwUXuZ3Z+lzxFRR9O7JCPUaZHol mEWOBhAfqbs2Uc7ilj0HxUFtzjXeR4LHqbeLCXtivTZj8aBViICtt+bcs0stiEtU9S22 4MG3RN8IKBpTKCNLNXi1b1R53L04sBxGChY5+C59rg8JEesJKSUU2wPM4N0ALALK1ScT JkdFbH6YCA+9Id5zoliat6TydsJdLJHfYvPrTKieSHyXu57T2wUJ9rMIdewkpwO1C9pT wc5w== X-Gm-Message-State: AOAM531UTgohl0HfUm3M0VE2zoO93Gl7aczNYopQOao0wm15AGPqxwfq olGQcNBGZsAlbM9HlgSQzOfiDOyBcDxf5BqdLR1lN0qvlec8Hi3W X-Received: by 2002:a05:6512:139c:: with SMTP id p28mr1883625lfa.523.1631238386987; Thu, 09 Sep 2021 18:46:26 -0700 (PDT) MIME-Version: 1.0 References: <20210908061611.69823-1-mie@igel.co.jp> <20210908061611.69823-2-mie@igel.co.jp> <20210908111804.GX1200268@ziepe.ca> <1c0356f5-19cf-e883-3d96-82a87d0cffcb@amd.com> <20210908233354.GB3544071@ziepe.ca> In-Reply-To: From: Shunsuke Mie Date: Fri, 10 Sep 2021 10:46:15 +0900 Message-ID: Subject: Re: [RFC PATCH 1/3] RDMA/umem: Change for rdma devices has not dma device To: Daniel Vetter Cc: Jason Gunthorpe , =?UTF-8?Q?Christian_K=C3=B6nig?= , Christoph Hellwig , Zhu Yanjun , Alex Deucher , Doug Ledford , Jianxin Xiong , Leon Romanovsky , Linux Kernel Mailing List , linux-rdma , Damian Hobson-Garcia , Takanari Hayama , Tomohito Esaki Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2021=E5=B9=B49=E6=9C=889=E6=97=A5(=E6=9C=A8) 18:26 Daniel Vetter : > > On Thu, Sep 9, 2021 at 1:33 AM Jason Gunthorpe wrote: > > On Wed, Sep 08, 2021 at 09:22:37PM +0200, Daniel Vetter wrote: > > > On Wed, Sep 8, 2021 at 3:33 PM Christian K=C3=B6nig wrote: > > > > Am 08.09.21 um 13:18 schrieb Jason Gunthorpe: > > > > > On Wed, Sep 08, 2021 at 05:41:39PM +0900, Shunsuke Mie wrote: > > > > >> 2021=E5=B9=B49=E6=9C=888=E6=97=A5(=E6=B0=B4) 16:20 Christoph Hel= lwig : > > > > >>> On Wed, Sep 08, 2021 at 04:01:14PM +0900, Shunsuke Mie wrote: > > > > >>>> Thank you for your comment. > > > > >>>>> On Wed, Sep 08, 2021 at 03:16:09PM +0900, Shunsuke Mie wrote: > > > > >>>>>> To share memory space using dma-buf, a API of the dma-buf re= quires dma > > > > >>>>>> device, but devices such as rxe do not have a dma device. Fo= r those case, > > > > >>>>>> change to specify a device of struct ib instead of the dma d= evice. > > > > >>>>> So if dma-buf doesn't actually need a device to dma map why d= o we ever > > > > >>>>> pass the dma_device here? Something does not add up. > > > > >>>> As described in the dma-buf api guide [1], the dma_device is u= sed by dma-buf > > > > >>>> exporter to know the device buffer constraints of importer. > > > > >>>> [1] https://nam11.safelinks.protection.outlook.com/?url=3Dhttp= s%3A%2F%2Flwn.net%2FArticles%2F489703%2F&data=3D04%7C01%7Cchristian.koe= nig%40amd.com%7C4d18470a94df4ed24c8108d972ba5591%7C3dd8961fe4884e608e11a82d= 994e183d%7C0%7C0%7C637666967356417448%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wL= jAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=3DAR= wQyo%2BCjMohaNbyREofToHIj2bndL5L0HaU9cOrYq4%3D&reserved=3D0 > > > > >>> Which means for rxe you'd also have to pass the one for the und= erlying > > > > >>> net device. > > > > >> I thought of that way too. In that case, the memory region is co= nstrained by the > > > > >> net device, but rxe driver copies data using CPU. To avoid the c= onstraints, I > > > > >> decided to use the ib device. > > > > > Well, that is the whole problem. > > > > > > > > > > We can't mix the dmabuf stuff people are doing that doesn't fill = in > > > > > the CPU pages in the SGL with RXE - it is simply impossible as th= ings > > > > > currently are for RXE to acess this non-struct page memory. > > > > > > > > Yeah, agree that doesn't make much sense. > > > > > > > > When you want to access the data with the CPU then why do you want = to > > > > use DMA-buf in the first place? > > > > > > > > Please keep in mind that there is work ongoing to replace the sg ta= ble > > > > with an DMA address array and so make the underlying struct page > > > > inaccessible for importers. > > > > > > Also if you do have a dma-buf, you can just dma_buf_vmap() the buffer > > > for cpu access. Which intentionally does not require any device. No > > > idea why there's a dma_buf_attach involved. Now not all exporters > > > support this, but that's fixable, and you must call > > > dma_buf_begin/end_cpu_access for cache management if the allocation > > > isn't cpu coherent. But it's all there, no need to apply hacks of > > > allowing a wrong device or other fun things. > > > > Can rxe leave the vmap in place potentially forever? > > Yeah, it's like perma-pinning the buffer into system memory for > non-p2p dma-buf sharing. We just squint and pretend that can't be > abused too badly :-) On 32bit you'll run out of vmap space rather > quickly, but that's not something anyone cares about here either. We > have a bunch of more sw modesetting drivers in drm which use > dma_buf_vmap() like this, so it's all fine. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch Thanks for your comments. In the first place, the CMA region cannot be used for RDMA because the region has no struct page. In addition, some GPU drivers use CMA and share the region as dma-buf. As a result, RDMA cannot transfer for the region. To solve this problem, rxe dma-buf support is better I thought. I'll consider and redesign the rxe dma-buf support using the dma_buf_vmap() instead of the dma_buf_dynamic_attach(). Regards, Shunsuke