Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1015793rdg; Fri, 11 Aug 2023 07:17:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE65vbG+IyJYVNhBLWzP8cMApUCh7whcfbSIxGcdwFZsBJoeG6wisD2VC8iHMIFe5LZbV83 X-Received: by 2002:a05:6a00:1a55:b0:687:2e0b:228 with SMTP id h21-20020a056a001a5500b006872e0b0228mr1811225pfv.11.1691763434746; Fri, 11 Aug 2023 07:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691763434; cv=none; d=google.com; s=arc-20160816; b=c0GQbcenxR7Lwrm7jZjuCIsYZpUKOJHRDtdOUh4ww1C4BolPDv2qIEMNUwsJfmoamI IyxmW/JckboE3+ePIohy8wk/mu1PAtFBDBuQuvhVBEIgNVxVnd+n3YWeG4ZNGZyzljt6 iFBLJsTsKurKOaIdsefE2wC5HviOdPuSTNRcCmZ7VefaDgXP7HSW7nCzwS/AgrzhNBgV OrPH9wmIbmTjGQVEE+Lh4gnm57MFsy4fSIoTEt+W6SQylzZWGWZxWXGeBVYwY3P4tsT5 iu3wGtYHXxckD7TrqgT2+yeImPD5RfUXr+Y8R3tTG+XHfC8iqfyY4q8ikmDlTFGgLCaH Ia0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=VEH21OcqCVys8+7F1Rm6UH2Q4A3skK06LdIgpPa6qFE=; fh=pAAvxXwL4kmtw0rVHEVlGH87z7KcefSmJB6En4gLWj8=; b=evAhk+awIUN21bsuk/9n2otGck5TXydaahNqad3wwZiimAD8tY1K6IJYohByxH2FgM ThmoJnH+sVqk0z+dyqZIHtm4KJLkC3pshbtaK49BTqKlUFSTB5IOIKTBYnZGYZs1HBYO 1JyMZX6Ztv2KETdeFwYoaevqyoyUcc3jBZLYaeO7Q4vUyIbkNPMeXfYpRo+XsFd8CFIk WufIKmZKioDCZUOPXomTl3Rwki6DWEqB1XBmN8IJpTGL0V72Cv8E9varYtxNY37qmxis XYNVwT2wPXWbQ8Or8RwKiVfyeexhDajWWomuunCCWXDax4UmcozyixyjqK2+SPzvhpDe nuGQ== 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=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a62ea03000000b006871d101748si3356991pfh.254.2023.08.11.07.17.02; Fri, 11 Aug 2023 07:17:14 -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=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233954AbjHKNZm (ORCPT + 99 others); Fri, 11 Aug 2023 09:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbjHKNZl (ORCPT ); Fri, 11 Aug 2023 09:25:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8978E90 for ; Fri, 11 Aug 2023 06:25:40 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 82E3F113E; Fri, 11 Aug 2023 06:26:22 -0700 (PDT) Received: from [10.57.1.174] (unknown [10.57.1.174]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6D4C23F6C4; Fri, 11 Aug 2023 06:25:38 -0700 (PDT) Message-ID: <3576aade-d13a-c887-d26b-fd157b82b9a5@arm.com> Date: Fri, 11 Aug 2023 14:25:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [RESEND PATCH 0/2] iommu/iova: optimize the iova rcache To: Zhang Zekun , joro@8bytes.org, will@kernel.org Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, baolu.lu@linux.intel.com, robh@kernel.org, nicolinc@nvidia.com, john.g.garry@oracle.com, kevin.tian@intel.com References: <20230811130246.42719-1-zhangzekun11@huawei.com> Content-Language: en-GB From: Robin Murphy In-Reply-To: <20230811130246.42719-1-zhangzekun11@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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 On 2023-08-11 14:02, Zhang Zekun wrote: > 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. Oh, that reminds me I had started working on this again just before I was off, only my plan was to get rid of the depot allocation altogether[1]. However I wanted to finish the second patch on that branch (to reclaim wasted memory from the depot if the workload changes) before posting anything - I was feeling really pleased that I'd made it work until I realised it was leaking all the actual IOVAs... :( Thanks, Robin. [1] https://gitlab.arm.com/linux-arm/linux-rm/-/commit/2f37ebe93eb282b534bf9e0fd4adc66cfe4b6693 > > 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(-) >