From patchwork Tue Jul 11 02:54:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhangzekun (A)" X-Patchwork-Id: 11835 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp221668vqm; Mon, 10 Jul 2023 20:41:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlEY2zyuEWeNatQufI2/V4jNjZOQBIqb+TcGkHFvCqFYhJdAxSB/SqybqvK8s0gEkPYDT72r X-Received: by 2002:a17:90a:778c:b0:262:eb20:2dd8 with SMTP id v12-20020a17090a778c00b00262eb202dd8mr21150576pjk.20.1689046903422; Mon, 10 Jul 2023 20:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689046903; cv=none; d=google.com; s=arc-20160816; b=Q6Hdy/rHa7gTGqD8QIyvsF/IhR8XYCNM1HynfHuorPM3P7qhf1PW7xNlOxr8AFbRrB gHu4HlYKPfLThNRDkXkK00RnThLEKcvflZ0LodOhFY2fQqnn9bjtKPgMFiixEA61TFNZ EyVIRRmLp5DxO5cPNETu4d/gv2CYh9K0wVXg4f2JIDtOgdyOKP0WwQbfg2gBHQocjmrT sFAqTyKtJ9MGpJINNhE5wAsML4vR7n/X0/XRJJ6+VfZBsLrHwI+5Mq22IMA8wztU9XDV DYeCJEy3TcsdhtZpv6QVby0sejir8AKeAfb2nzHoNRXEKDMZX0BhP5LoWxl0IjwnuUtU zQUQ== 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=q2KC22qNyh+GNN8v6izMI8EQqXGaqX+O4ToAS73Ef7Q=; fh=iSjQBVrAVFI/9+Bb0JBpjDMqV7UrVmYB2fvUWhoGx5E=; b=dum+2S0Imx4SBbTCLXO/FMZubxYUc6o/LR39COp0HJpwIPw9hh81FQnmjgcVlncj9x jZOv/24iqrMMNYI2qHmSAsckmzrD2NBjnHyNF83nXfbxwxun1IRx7N//Q6LBGVsbb+Hf kfFGF56upikSVLc7Fcb6tkLf4O3zwD85Dlqqq64vcYw2eXX/qbWwGe2HqBPNQN4rbnJj oYxD8scbZ8jm1nGhXEckB6PNahvO8AkUguFZucGJlYQLrIyR1A297KDC5CIdFiFaohlu eO7NsFidXm5oNtu0+TJUZOKXLp2qPoO/RFW8ma9zOQbjOSbW4RWjPmH+uOlddczJfEcb j+kg== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt20-20020a17090afa5400b00263dcd605a0si8125156pjb.70.2023.07.10.20.41.30; Mon, 10 Jul 2023 20:41:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbjGKDF2 (ORCPT + 99 others); Mon, 10 Jul 2023 23:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbjGKDE7 (ORCPT ); Mon, 10 Jul 2023 23:04:59 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E59BE6C for ; Mon, 10 Jul 2023 20:03:45 -0700 (PDT) Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R0Qf01RnXzVhpV; Tue, 11 Jul 2023 11:02:32 +0800 (CST) Received: from huawei.com (10.175.112.208) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 11 Jul 2023 11:03:42 +0800 From: Zhang Zekun To: , , , , CC: , , , , Subject: [PATCH -next 0/2] iommu/iova: optimize the iova rcache Date: Tue, 11 Jul 2023 10:54:50 +0800 Message-ID: <20230711025452.35475-1-zhangzekun11@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500022.china.huawei.com (7.185.36.66) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771094045710962557 X-GMAIL-MSGID: 1771094045710962557 The struct of iova rcache has diffcult in dealing with machine with lots of cpus, because every cpu has a cpu_rcache and they need to exchange iova in a fixed length buffer rcache->depot, this buffer can sometimes become a bottle neck of allocating iova from iova_rcache. The number of iova_cpu_rcache can grow with the number of cpus in iova_rcache, but the size of rcache->depot will not. The deeper of rcache->depot can help iova_rcache cache more iovas, and can help iova_rcache better dealing with senarios in which drivers allocating and free iovas on different cpu cores. We only let the size of rcache->depot to grow with the number of cpus which is larger than 32 to avoid potential performance decrease on machines which don't have much cpus. Also, it is unsafe to directly free cpu rcache magazines in free_iova_rcaches, add check before freeing it. Zhang Zekun (2): iommu/iova: Add check for cpu_rcache in free_iova_rcaches iommu/iova: allocate iova_rcache->depot dynamicly drivers/iommu/iova.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)