From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B61BAC4361B for ; Wed, 9 Dec 2020 18:27:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7588B23BC6 for ; Wed, 9 Dec 2020 18:27:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733045AbgLIS1z (ORCPT ); Wed, 9 Dec 2020 13:27:55 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:9413 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732904AbgLIS1z (ORCPT ); Wed, 9 Dec 2020 13:27:55 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Crlr054H7z7Byc; Thu, 10 Dec 2020 02:26:40 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Thu, 10 Dec 2020 02:27:03 +0800 From: John Garry To: , CC: , , , , , John Garry Subject: [PATCH v4 1/3] iommu/iova: Add free_all_cpu_cached_iovas() Date: Thu, 10 Dec 2020 02:23:07 +0800 Message-ID: <1607538189-237944-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1607538189-237944-1-git-send-email-john.garry@huawei.com> References: <1607538189-237944-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper function to free the CPU rcache for all online CPUs. There also exists a function of the same name in drivers/iommu/intel/iommu.c, but the parameters are different, and there should be no conflict. Signed-off-by: John Garry Tested-by: Xiang Chen Reviewed-by: Zhen Lei --- drivers/iommu/iova.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index f9c35852018d..cf1aacda2fe4 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -238,6 +238,14 @@ static int __alloc_and_insert_iova_range(struct iova_domain *iovad, return -ENOMEM; } +static void free_all_cpu_cached_iovas(struct iova_domain *iovad) +{ + unsigned int cpu; + + for_each_online_cpu(cpu) + free_cpu_cached_iovas(cpu, iovad); +} + static struct kmem_cache *iova_cache; static unsigned int iova_cache_users; static DEFINE_MUTEX(iova_cache_mutex); @@ -435,15 +443,12 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long size, retry: new_iova = alloc_iova(iovad, size, limit_pfn, true); if (!new_iova) { - unsigned int cpu; - if (!flush_rcache) return 0; /* Try replenishing IOVAs by flushing rcache. */ flush_rcache = false; - for_each_online_cpu(cpu) - free_cpu_cached_iovas(cpu, iovad); + free_all_cpu_cached_iovas(iovad); free_global_cached_iovas(iovad); goto retry; } -- 2.26.2