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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B754FEB64D9 for ; Tue, 11 Jul 2023 03:05:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231398AbjGKDF3 (ORCPT ); Mon, 10 Jul 2023 23:05:29 -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 Content-Type: text/plain 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.17.1