Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp36628lqe; Tue, 9 Apr 2024 13:39:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOx0SdAs78QoTwyPsWnNO/XVHTelnaJUP4ZLGpByspcHqNmVoA3ZXrgBc6+k8sYM1/SPZHubL4t3a3DUehVVOVMB515418Rswhy+ui8g== X-Google-Smtp-Source: AGHT+IEgIdsUMZb33ygu3F9vQrO0gUhUZ/CXdzRIO0WYL7ukuU1/NQ3tGez177tWMcaTLYEvgI+4 X-Received: by 2002:a17:903:1252:b0:1dd:7da:e0a9 with SMTP id u18-20020a170903125200b001dd07dae0a9mr1107376plh.69.1712695186760; Tue, 09 Apr 2024 13:39:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712695186; cv=pass; d=google.com; s=arc-20160816; b=EcD9kL56Fln9B1icUWCCu+Pru+EJkaWmCkPdEBxd5ARWm0jfgTg9IBj3Iwu30r+Nvv P/rL+017J+AK12imRkhj7wQetunPINQbuBox2vkvR4SQjCkMIAE2Ta+s2q9+FSvnYCre XsuDfpdMP0b+RYGO9MYJlIcacD89TQyHevPw9LjEjlOilipfPc+V0wZYkYwzvoF9i8Vt DFZ0tFfpQ86QF8owkpfQOJAQwfvZrn/sR2vsb+i7GO72KZBOeVu2tp3we5E85XNSmsHn pHFCdodNklmGa14zj8dHdksu7Ks7ReRN56HaLxGJZTRTurwR+NimUi1BhIS7555ISned iUVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from:subject :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:dkim-signature:message-id; bh=SVUiOM0QcRqoo/6o1IjJwVcyR3Qxex0Ao2MUyWJnXTc=; fh=t1qw6OE0U9pLC+acr83n1Ye3fO5XVb7d+VW/KSmdFtg=; b=JNbvtucJI6BetCq+pWRMsFeFHAl5xHvPWql4+vxHQVrRVBy7bZcOLpThrIUgM46CWS jX11TsHqKSEh6HS2E7rZeefj5kMzsyNoDB/n1cn0Ye5NUvxA1VdnY8ooQx3G0y6Rflni 3MsfVV6Ojy93cOJMN2b6gleci7msJ6uu/q0JfU+T0OGKbdlABLWWYPHsC/CLqdnWlg/P OqKbBibwD89k/GbxxRq6V9qzND4YKoh0YhkJo4wTxgOtafh/XhsEa3uaSh8ZRIahW7Be bnNdDPrfeP1RD5v++XKn10PjI1ZYIojQ0qvkplD+A9pRzhj7XkspQpPKJj1CAF4DXNu7 mymQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iexLxoS4; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-137605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a11-20020a170902eccb00b001e2a40a6e9csi9434769plh.548.2024.04.09.13.39.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 13:39:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iexLxoS4; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-137605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6488B284F69 for ; Tue, 9 Apr 2024 20:39:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54F42158878; Tue, 9 Apr 2024 20:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iexLxoS4" Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33B7F158843; Tue, 9 Apr 2024 20:39:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712695152; cv=none; b=DfEvV24GVlgh7hcVBo4qFDVjx64dxkDSX+wH2G2F2vo0/bgi/diDdYmGFyFA2aEZ/GxSJpCBLYBYNtPfvr8llHfNqxRkElrQyUwZOEbt2VsDWqs4mgIb3HR2SkcmZG34Z0RdJR1oY4tG35l9x9+2zo8xTvRLF87ds348UnMMGyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712695152; c=relaxed/simple; bh=8jbelJmjK60K89nVSGEJVZ1VFyu5tfUrVQ6MaclgRv8=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=LnmGfAlhzMOuXicm/F3+H7nKDlA4b/6FB4fgoxcBvq+qr8Rp+B4PbJ5vNLBWiqOw04eP2lh1mquqW04R9Yy3oSZP3vbdcj0Yt6htOZyjJNqy47rg5EmOG9pbdbujuY/v5fK6ElpIX9rcuNaZh9qNNbRvklRakkUhqoyWzMnqoD8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=iexLxoS4; arc=none smtp.client-ip=91.218.175.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712695148; 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=SVUiOM0QcRqoo/6o1IjJwVcyR3Qxex0Ao2MUyWJnXTc=; b=iexLxoS4HQYGzHW0qQNnXKyYF04/CU/9OoS0xvx8xGCO4Ix16ivK+y9+ymiwAOQEvR/M5J E7KmoPQbVNKAGeF/j1Zitj8/w+qiZ16xWP+z/osg4i8cW3jrYsKI/f8LAzcbFvhn/hf61S 3AMT3shrV2uY9XICbFQwXYTvBCoZNUE= Date: Tue, 9 Apr 2024 22:39:03 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [RFC RESEND 00/16] Split IOMMU DMA mapping operation to two steps X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zhu Yanjun To: Leon Romanovsky , Christoph Hellwig , Robin Murphy , Marek Szyprowski , Joerg Roedel , Will Deacon , Jason Gunthorpe , Chaitanya Kulkarni Cc: Jonathan Corbet , Jens Axboe , Keith Busch , Sagi Grimberg , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Andrew Morton , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, linux-nvme@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, Bart Van Assche , Damien Le Moal , Amir Goldstein , "josef@toxicpanda.com" , "Martin K. Petersen" , "daniel@iogearbox.net" , Dan Williams , "jack@suse.com" , Leon Romanovsky , Zhu Yanjun References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 在 2024/3/7 7:01, Zhu Yanjun 写道: > 在 2024/3/5 12:18, Leon Romanovsky 写道: >> This is complimentary part to the proposed LSF/MM topic. >> https://lore.kernel.org/linux-rdma/22df55f8-cf64-4aa8-8c0b-b556c867b926@linux.dev/T/#m85672c860539fdbbc8fe0f5ccabdc05b40269057 > > I am interested in this topic. Hope I can join the meeting to discuss > this topic. > With the same idea, in the IDPF driver, the function dma_alloc_coherent which is called in the IDPF driver can be devided into the following 2 functions: iommu_dma_alloc_pages and iommu_dma_map_page So the function iommu_dma_alloc_pages allocates pages, iommu_dma_map_page makes mapping between pages and IOVA. Now the above idea is implemented in the NIC driver. Currently it can work well. Next the above idea will be implemented in the block device. Hope this can increase the performance of the block device. Best Regards, Zhu Yanjun > Zhu Yanjun > >> >> This is posted as RFC to get a feedback on proposed split, but RDMA, >> VFIO and >> DMA patches are ready for review and inclusion, the NVMe patches are >> still in >> progress as they require agreement on API first. >> >> Thanks >> >> ------------------------------------------------------------------------------- >> The DMA mapping operation performs two steps at one same time: allocates >> IOVA space and actually maps DMA pages to that space. This one shot >> operation works perfectly for non-complex scenarios, where callers use >> that DMA API in control path when they setup hardware. >> >> However in more complex scenarios, when DMA mapping is needed in data >> path and especially when some sort of specific datatype is involved, >> such one shot approach has its drawbacks. >> >> That approach pushes developers to introduce new DMA APIs for specific >> datatype. For example existing scatter-gather mapping functions, or >> latest Chuck's RFC series to add biovec related DMA mapping [1] and >> probably struct folio will need it too. >> >> These advanced DMA mapping APIs are needed to calculate IOVA size to >> allocate it as one chunk and some sort of offset calculations to know >> which part of IOVA to map. >> >> Instead of teaching DMA to know these specific datatypes, let's separate >> existing DMA mapping routine to two steps and give an option to advanced >> callers (subsystems) perform all calculations internally in advance and >> map pages later when it is needed. >> >> In this series, three users are converted and each of such conversion >> presents different positive gain: >> 1. RDMA simplifies and speeds up its pagefault handling for >>     on-demand-paging (ODP) mode. >> 2. VFIO PCI live migration code saves huge chunk of memory. >> 3. NVMe PCI avoids intermediate SG table manipulation and operates >>     directly on BIOs. >> >> Thanks >> >> [1] >> https://lore.kernel.org/all/169772852492.5232.17148564580779995849.stgit@klimt.1015granger.net >> >> Chaitanya Kulkarni (2): >>    block: add dma_link_range() based API >>    nvme-pci: use blk_rq_dma_map() for NVMe SGL >> >> Leon Romanovsky (14): >>    mm/hmm: let users to tag specific PFNs >>    dma-mapping: provide an interface to allocate IOVA >>    dma-mapping: provide callbacks to link/unlink pages to specific IOVA >>    iommu/dma: Provide an interface to allow preallocate IOVA >>    iommu/dma: Prepare map/unmap page functions to receive IOVA >>    iommu/dma: Implement link/unlink page callbacks >>    RDMA/umem: Preallocate and cache IOVA for UMEM ODP >>    RDMA/umem: Store ODP access mask information in PFN >>    RDMA/core: Separate DMA mapping to caching IOVA and page linkage >>    RDMA/umem: Prevent UMEM ODP creation with SWIOTLB >>    vfio/mlx5: Explicitly use number of pages instead of allocated length >>    vfio/mlx5: Rewrite create mkey flow to allow better code reuse >>    vfio/mlx5: Explicitly store page list >>    vfio/mlx5: Convert vfio to use DMA link API >> >>   Documentation/core-api/dma-attributes.rst |   7 + >>   block/blk-merge.c                         | 156 ++++++++++++++ >>   drivers/infiniband/core/umem_odp.c        | 219 +++++++------------ >>   drivers/infiniband/hw/mlx5/mlx5_ib.h      |   1 + >>   drivers/infiniband/hw/mlx5/odp.c          |  59 +++-- >>   drivers/iommu/dma-iommu.c                 | 129 ++++++++--- >>   drivers/nvme/host/pci.c                   | 220 +++++-------------- >>   drivers/vfio/pci/mlx5/cmd.c               | 252 ++++++++++++---------- >>   drivers/vfio/pci/mlx5/cmd.h               |  22 +- >>   drivers/vfio/pci/mlx5/main.c              | 136 +++++------- >>   include/linux/blk-mq.h                    |   9 + >>   include/linux/dma-map-ops.h               |  13 ++ >>   include/linux/dma-mapping.h               |  39 ++++ >>   include/linux/hmm.h                       |   3 + >>   include/rdma/ib_umem_odp.h                |  22 +- >>   include/rdma/ib_verbs.h                   |  54 +++++ >>   kernel/dma/debug.h                        |   2 + >>   kernel/dma/direct.h                       |   7 +- >>   kernel/dma/mapping.c                      |  91 ++++++++ >>   mm/hmm.c                                  |  34 +-- >>   20 files changed, 870 insertions(+), 605 deletions(-) >> >