Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4194194pxu; Wed, 9 Dec 2020 10:34:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9J5gTGaFAZKMFiFC0xTKAaro2ePIVY3UgCAfeFAdLPyKmqvOY2M0reaVKXC56vBUwjUrL X-Received: by 2002:a05:6402:5:: with SMTP id d5mr3266912edu.77.1607538849445; Wed, 09 Dec 2020 10:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607538849; cv=none; d=google.com; s=arc-20160816; b=zJX3BvxylcRQIeG5SXUpYpmbJdy+qEkWiIJSkI4kxxXF5y9k3QPfCW2f1Q7Dz3Rxbg p4Ju6dKtrhTgHhSg7fL4S2qBIxBWpNrM818jOmP4BJUPHz9neHuthOr/nKtPoL8chxdd obKU/5L2c+FRvYsyiodCaua7F1QsokRO2amBzL0sExYVeUirNKObt2kRPcVaRTtYRHBU RzkVYH25ju/Lqcj43KiFE72VTUSkyh0QvT/H4RqiMmlzXJz1+5Y5CPnPIHHF/f+wJ+9a YHD7x9EmxMz1dOEfAS1EjbP1rRsa94cwzsc7sit3K45BAPdtkrgwv6HDw6v1ALeQ+xdX /fEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=+Zt0m2Y2xQTEncmlqiZIUO4JnNmDx5fvZTLtX5rcUxY=; b=wVeH08VpB079IayUKNoPCtlrmDjHYWlaKnrBHyuD13GTOBq3Wwjry/sT6r4iXv2t7P qQlyLPnDtTJKx9DyL9B2itE3Qbaii/dIMrkh4rNNLj0hw3HwWmhl6VM5TTgvGRzzJWaF /RQe+lnE7mZUIDF8mmek9lWDUETeblvHvi5oV+Ici0nyriIzJKnR2Pdv15NIvuwgw42k H++oO5pvV0iKEFFo3szHoU64MzFNdQnnQfoAiKd9Oto9x0VNWbZXrsku7pkTa8t11fde +GJlktc5BPraSGwpZvJoH0jlDcP7Heiedf83rNimWo2xkZNuQ1i8S1UiSrUyVU7Myuln 6w6Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si1217216edu.211.2020.12.09.10.33.46; Wed, 09 Dec 2020 10:34:09 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733041AbgLIS1z (ORCPT + 99 others); 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