Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3538928pxb; Mon, 4 Apr 2022 20:27:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyA+Tn6XmMkubqX984sWt6V0Pc+jkwFzFk6jUJSdcPX/59d7fGP6po4B2ZKoZVD1jIBXlff X-Received: by 2002:a17:902:7e0e:b0:156:498d:437 with SMTP id b14-20020a1709027e0e00b00156498d0437mr1442786plm.44.1649129255987; Mon, 04 Apr 2022 20:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649129255; cv=none; d=google.com; s=arc-20160816; b=W66edAN61yQejRtjEo9FMFwJAgp9eqthNpBxfiNrOj7WaH/xfMWC5CYnjuaX+EpvJ7 Xw30ElbHwrc1sq0X7soKROOdNQ93C7pG7TPLL17eWPl3hFkKysSLNQOHlJYj7jkFU1PF k/bKBXAETRRxO7n/Y35YJPJ5z15REvs4ty7+Sk87j0HSBBHMzxLtkejOFDx20BhOfg7O JUE3zaqSuwlD7bis/Xipn4LQ5lLZfjHDok0o1X2/PjWyX+E/ccZIm5P3TTBJ4bnHzTP5 RwudvqK+M7RvNw9dSXwv9r6Es1Kd2m9TtBvspJsqu2FSnkOGoT0kIw8SN6yGTJWTL5Ee kTog== 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=G6HzkbyLIX4QIs3WzANXvruodmZEj6VQLtc2m5VgnAY=; b=CZXlh7IB8ypfRB/sMEEmQBpjpn5OZNqV7UYhRIS7d51kgyjHMzVglC6ri9frLMd3e4 vYNPdWZ52tbrul/FRKrm1T4vjjp94rQ/gbA/JYavix41uX3JtbxQNuVho3OGCSHXXbt6 fyyKVWThZ6ctI9+x/D5nqQ/+uwA96NIA/vqg2mlRvxaZpDYyVi+q4WBQQjHDRRMOXZCk VHqSGyBrQaGxpUP7UDi5traTL5B3gBaQxL1WQ9wFFxAe2hBXk1F8ymvfxnEnff1kgvs7 Pr/BO6GvibUPTacTSh3qOL6jldGw8Y4nbamUkdQhAOd/sAa4A4tLnx+j//NJUVILD4oV 5dNg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id b7-20020a6567c7000000b003816043efa9si12041269pgs.414.2022.04.04.20.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:27:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 6F24B316293; Mon, 4 Apr 2022 18:27:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359458AbiDDLe6 (ORCPT + 99 others); Mon, 4 Apr 2022 07:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349295AbiDDLe5 (ORCPT ); Mon, 4 Apr 2022 07:34:57 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89E063C739 for ; Mon, 4 Apr 2022 04:33:01 -0700 (PDT) Received: from fraeml705-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4KX7rM1QGyz67Lnh; Mon, 4 Apr 2022 19:30:59 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml705-chm.china.huawei.com (10.206.15.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.24; Mon, 4 Apr 2022 13:32:58 +0200 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.2375.24; Mon, 4 Apr 2022 12:32:55 +0100 From: John Garry To: , , CC: , , , , , , , , , John Garry Subject: [PATCH RESEND v5 0/5] iommu: Allow IOVA rcache range be configured Date: Mon, 4 Apr 2022 19:27:09 +0800 Message-ID: <1649071634-188535-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: dggems705-chm.china.huawei.com (10.3.19.182) 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.18-rc1 * 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/ 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