Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3240997pxy; Sun, 25 Apr 2021 18:43:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPT/sHXp8r1iYZvVIuE9/iKVP6TPOutr/HWDXkA7RYGrGvRSGIsnBLvqgvmM01StURiLUD X-Received: by 2002:a50:9e4f:: with SMTP id z73mr17937770ede.338.1619401411733; Sun, 25 Apr 2021 18:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619401411; cv=none; d=google.com; s=arc-20160816; b=ebKsMoiRPsG22VDtGInBg6RSwXuOA6/YbXo2KZ5PVI52GjsRwN4+A6dSQOtimcn30L 9RVMofIM1it4LX7UnJhaMq65ckDmyuX7Ejpd+W9IuG0hm0WOELqajuTSn2vQRgw9BXid 7br6rT9y3BjdPtK4bm02riFgvaMF/ZNyAYjPUnIlE6QEXGHGzAntW8+S6NaLO1JacAK+ QUOqSbVoQSX0h+lmKwj2I3sxzY3FQC323CQfo3a0TAv7lL6A46vjB+TGSwKWdvSF+A0v U6j6hLY4aOQE+b1cw7tj3oJdEj/tbpPHSzkZrCc3mv6Qs47gindghs98JwTqhvpX6Syj 96hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=vjeiNYkpQ3avDV6YUNW1mDQCKgGD8S7L6nXnhodrS3E=; b=WrIqeTLvtSVfUXDvQrUuIsuq/8WCgkW2JURVPmTM+WI0a4LhRS4ywxDu4aEGChMoI9 kfyaI4FA9axLY6+UiZ3II+g54w/AKFjjTQSQwbLf31iOErwqnZ+ZXb0dOdPGEh3obbeZ ff9nt1B18uXvpW2cT1qsZKAOA1W5RJme+SYZSJcQr7ToJrzGVrcLrI6xnTyuS2Fi4S0z taqPtSTO8Eja32vvpvzWH1FpZsCk6ZnhgJMcVvvOnazxWS4wsYtGFe1NfWKFYIAJ1D6H tWssCsHjx9qeqGRIi2oc+Q92Mqfj3oOnqw8IivPmzn9XMIr0tTr+RxptlMB6+hnFw6yF /ErQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds2si12046058ejc.749.2021.04.25.18.43.08; Sun, 25 Apr 2021 18:43:31 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231679AbhDZBm0 (ORCPT + 99 others); Sun, 25 Apr 2021 21:42:26 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:17055 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbhDZBm0 (ORCPT ); Sun, 25 Apr 2021 21:42:26 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FT6xw6kFtz17RvH; Mon, 26 Apr 2021 09:39:16 +0800 (CST) Received: from [10.174.184.135] (10.174.184.135) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Mon, 26 Apr 2021 09:41:34 +0800 Subject: Re: [RFC PATCH v3 0/8] Add IOPF support for VFIO passthrough To: Alex Williamson , Cornelia Huck , Will Deacon , Robin Murphy , Joerg Roedel , Jean-Philippe Brucker , Eric Auger , , , , , CC: Kevin Tian , Lu Baolu , , Christoph Hellwig , Jonathan Cameron , Barry Song , , References: <20210409034420.1799-1-lushenming@huawei.com> From: Shenming Lu Message-ID: Date: Mon, 26 Apr 2021 09:41:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: <20210409034420.1799-1-lushenming@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.184.135] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/9 11:44, Shenming Lu wrote: > Hi, > > Requesting for your comments and suggestions. :-) Kind ping... > > The static pinning and mapping problem in VFIO and possible solutions > have been discussed a lot [1, 2]. One of the solutions is to add I/O > Page Fault support for VFIO devices. Different from those relatively > complicated software approaches such as presenting a vIOMMU that provides > the DMA buffer information (might include para-virtualized optimizations), > IOPF mainly depends on the hardware faulting capability, such as the PCIe > PRI extension or Arm SMMU stall model. What's more, the IOPF support in > the IOMMU driver has already been implemented in SVA [3]. So we add IOPF > support for VFIO passthrough based on the IOPF part of SVA in this series. > > We have measured its performance with UADK [4] (passthrough an accelerator > to a VM(1U16G)) on Hisilicon Kunpeng920 board (and compared with host SVA): > > Run hisi_sec_test... > - with varying sending times and message lengths > - with/without IOPF enabled (speed slowdown) > > when msg_len = 1MB (and PREMAP_LEN (in Patch 4) = 1): > slowdown (num of faults) > times VFIO IOPF host SVA > 1 63.4% (518) 82.8% (512) > 100 22.9% (1058) 47.9% (1024) > 1000 2.6% (1071) 8.5% (1024) > > when msg_len = 10MB (and PREMAP_LEN = 512): > slowdown (num of faults) > times VFIO IOPF > 1 32.6% (13) > 100 3.5% (26) > 1000 1.6% (26) > > History: > > v2 -> v3 > - Nit fixes. > - No reason to disable reporting the unrecoverable faults. (baolu) > - Maintain a global IOPF enabled group list. > - Split the pre-mapping optimization to be a separate patch. > - Add selective faulting support (use vfio_pin_pages to indicate the > non-faultable scope and add a new struct vfio_range to record it, > untested). (Kevin) > > v1 -> v2 > - Numerous improvements following the suggestions. Thanks a lot to all > of you. > > Note that PRI is not supported at the moment since there is no hardware. > > Links: > [1] Lesokhin I, et al. Page Fault Support for Network Controllers. In ASPLOS, > 2016. > [2] Tian K, et al. coIOMMU: A Virtual IOMMU with Cooperative DMA Buffer Tracking > for Efficient Memory Management in Direct I/O. In USENIX ATC, 2020. > [3] https://patchwork.kernel.org/project/linux-arm-kernel/cover/20210401154718.307519-1-jean-philippe@linaro.org/ > [4] https://github.com/Linaro/uadk > > Thanks, > Shenming > > > Shenming Lu (8): > iommu: Evolve the device fault reporting framework > vfio/type1: Add a page fault handler > vfio/type1: Add an MMU notifier to avoid pinning > vfio/type1: Pre-map more pages than requested in the IOPF handling > vfio/type1: VFIO_IOMMU_ENABLE_IOPF > vfio/type1: No need to statically pin and map if IOPF enabled > vfio/type1: Add selective DMA faulting support > vfio: Add nested IOPF support > > .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 3 +- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 18 +- > drivers/iommu/iommu.c | 56 +- > drivers/vfio/vfio.c | 85 +- > drivers/vfio/vfio_iommu_type1.c | 1000 ++++++++++++++++- > include/linux/iommu.h | 19 +- > include/linux/vfio.h | 13 + > include/uapi/linux/iommu.h | 4 + > include/uapi/linux/vfio.h | 6 + > 9 files changed, 1181 insertions(+), 23 deletions(-) >