From nobody Wed Dec 17 19:04:11 2025 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 66933C77B75 for ; Tue, 18 Apr 2023 06:27:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbjDRG1P (ORCPT ); Tue, 18 Apr 2023 02:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjDRG1M (ORCPT ); Tue, 18 Apr 2023 02:27:12 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DA6455B9 for ; Mon, 17 Apr 2023 23:26:32 -0700 (PDT) Received: from dggpemm500006.china.huawei.com (unknown [7.185.36.236]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Q0v3L71zVzSsW8; Tue, 18 Apr 2023 14:22:22 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 18 Apr 2023 14:26:27 +0800 From: Zhen Lei To: Robin Murphy , Joerg Roedel , Will Deacon , , CC: Zhen Lei Subject: [PATCH] iommu/iova: Optimize iova_magazine_alloc() Date: Tue, 18 Apr 2023 14:25:18 +0800 Message-ID: <20230418062518.852-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500006.china.huawei.com (7.185.36.236) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Only the member 'size' needs to be initialized to 0. Clearing the array pfns[], which is about 1 KiB in size, not only wastes time, but also causes cache pollution. Signed-off-by: Zhen Lei Acked-by: Robin Murphy --- drivers/iommu/iova.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index fe452ce466429a7..c970b9a2819d7bb 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -647,7 +647,13 @@ struct iova_rcache { =20 static struct iova_magazine *iova_magazine_alloc(gfp_t flags) { - return kzalloc(sizeof(struct iova_magazine), flags); + struct iova_magazine *mag; + + mag =3D kmalloc(sizeof(struct iova_magazine), flags); + if (mag) + mag->size =3D 0; + + return mag; } =20 static void iova_magazine_free(struct iova_magazine *mag) --=20 2.25.1