Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5998966pxb; Mon, 14 Feb 2022 12:46:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNgRM1xMZ747MvRTuGMGU55L+roiZx2hIe0TKeOm0H318sEedbv/pImkNJq2afEgrvr9U6 X-Received: by 2002:a62:a11a:: with SMTP id b26mr668895pff.19.1644871583746; Mon, 14 Feb 2022 12:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644871583; cv=none; d=google.com; s=arc-20160816; b=ujP6irjaU2FDf3bextUENeBd0NN6DjOx7lRJcDKpFxShiYm8vzaD1nwSDU8dKAxNKf MRJ8Tvduow8s0fJLjuNNvMgPbqk0ftI+ikki7QLfLPERV85NsffXOLVutj39QcYCpbjU jDU6Y4AS1OEJTp9/yH6FEuIBE2n8gWRsoTaiE38fHcTu0lC89DWmXi3IQ3q7YTfBpkyv CUYOYQ7s8+anSRbfcoPZOgjvlpijbVD04JXjxnTouvScZ8lSXyqr8OGW2eMBgY/NVBxf aZ9D+CWyMFFBeLEuZFkDKWigUFsRrE64zjY6+/5wF15evLn8rtf/m2ilp+rzPYRH8s/1 lobQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=kxP6j6iPaDkR7nZn/Msf3yw/mmkxNJuz44mRU44Y4KE=; b=OJHJnOklgTcemtNp4ygH/lkmESt5koyKYM5N4Iqk8vTB0RtZvlHnbEO93NIDk1vLui RmVvyEv+aVpbVtTiYS8t5AIHtxn0pBM330UHYbtbn2ZFzrW8Abro6G2KhxNyAivx4f2s tc3x6btGqratLP6pL61IROBkGVe8MCxjr7SsrLHfzpnpakqT1Jj8Si2yngIxX/50dIPv CYJOQFMFbf0qE4//SrHubBFUwjBPh3/xdBb9FdouLVCFspy2hFTa7yLi2mQsoxw8lnmL 5YHyh4q1qpsWaIaiJeq4oXiV7huRXR0jh7wUOTWrrVx2doswImsj5U4ABZ5vgEYPZNj6 XdOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nl3si287394pjb.5.2022.02.14.12.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:46:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2F351C0655; Mon, 14 Feb 2022 12:12:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357097AbiBNRfB (ORCPT + 99 others); Mon, 14 Feb 2022 12:35:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357103AbiBNRfA (ORCPT ); Mon, 14 Feb 2022 12:35:00 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD84965414 for ; Mon, 14 Feb 2022 09:34:50 -0800 (PST) Received: from fraeml701-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JyBDN5xhcz6H6jL; Tue, 15 Feb 2022 01:34:28 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml701-chm.china.huawei.com (10.206.15.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Mon, 14 Feb 2022 18:34:47 +0100 Received: from localhost.localdomain (10.69.192.58) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 14 Feb 2022 17:34:44 +0000 From: John Garry To: , , CC: , , , , , , , , , John Garry Subject: [PATCH v5 0/5] iommu: Allow IOVA rcache range be configured Date: Tue, 15 Feb 2022 01:29:01 +0800 Message-ID: <1644859746-20279-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For streaming DMA mappings involving an IOMMU and whose IOVA len regularly exceeds the IOVA rcache upper limit (meaning that they are not cached), performance can be reduced. This may be much more pronounced from commit 4e89dce72521 ("iommu/iova: Retry from last rb tree node if iova search fails"), as discussed at [0]. IOVAs which cannot be cached are highly involved in the IOVA ageing issue, as discussed at [1]. This series allows the IOVA rcache range be configured, so that we may cache all IOVAs per domain, thus improving performance. A new IOMMU group sysfs file is added - max_opt_dma_size - which is used indirectly to configure the IOVA rcache range: /sys/kernel/iommu_groups/X/max_opt_dma_size This file is updated same as how the IOMMU group default domain type is updated, i.e. must unbind the only device in the group first. The inspiration here comes from block layer request queue sysfs "optimal_io_size" file, in /sys/block/sdX/queue/optimal_io_size Some old figures* for storage scenario (when increasing IOVA rcache range to cover all DMA mapping sizes from the LLD): v5.13-rc1 baseline: 1200K IOPS With series: 1800K IOPS All above are for IOMMU strict mode. Non-strict mode gives ~1800K IOPS in all scenarios. Based on v5.17-rc4 + [2] * I lost my high data throughout test setup Differences to v4: https://lore.kernel.org/linux-iommu/1626259003-201303-1-git-send-email-john.garry@huawei.com/ - Major rebase - Change the "Refactor iommu_group_store_type()" to not use a callback and an op type enum instead - I didn't pick up Will's Ack as it has changed so much - Use a domain feature flag to keep same default group type - Add wrapper for default IOVA rcache range - Combine last 2x patches [0] https://lore.kernel.org/linux-iommu/20210129092120.1482-1-thunder.leizhen@huawei.com/ [1] https://lore.kernel.org/linux-iommu/1607538189-237944-1-git-send-email-john.garry@huawei.com/ [2] https://lore.kernel.org/linux-iommu/20220203063345-mutt-send-email-mst@kernel.org/T/#m5b2b59576d35cad544314470f32e5f40ac5d1fe9 John Garry (5): iommu: Refactor iommu_group_store_type() iova: Allow rcache range upper limit to be flexible iommu: Allow iommu_change_dev_def_domain() realloc same default domain type iommu: Allow max opt DMA len be set for a group via sysfs iova: Add iova_len argument to iova_domain_init_rcaches() .../ABI/testing/sysfs-kernel-iommu_groups | 16 ++ drivers/iommu/dma-iommu.c | 15 +- drivers/iommu/iommu.c | 202 +++++++++++++----- drivers/iommu/iova.c | 37 ++-- drivers/vdpa/vdpa_user/iova_domain.c | 4 +- include/linux/iommu.h | 7 + include/linux/iova.h | 6 +- 7 files changed, 212 insertions(+), 75 deletions(-) -- 2.26.2