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 E63C7C77B72 for ; Thu, 20 Apr 2023 10:41:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234965AbjDTKlD (ORCPT ); Thu, 20 Apr 2023 06:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234867AbjDTKkl (ORCPT ); Thu, 20 Apr 2023 06:40:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8F4993C32 for ; Thu, 20 Apr 2023 03:39:13 -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 2A6401480; Thu, 20 Apr 2023 03:39:57 -0700 (PDT) Received: from [10.57.22.118] (unknown [10.57.22.118]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 860623F587; Thu, 20 Apr 2023 03:39:12 -0700 (PDT) Message-ID: Date: Thu, 20 Apr 2023 11:38:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] iommu/iova: Optimize iova_magazine_alloc() Content-Language: en-GB To: Zhen Lei , Joerg Roedel , Will Deacon , iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20230418062518.852-1-thunder.leizhen@huawei.com> From: Robin Murphy In-Reply-To: <20230418062518.852-1-thunder.leizhen@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-04-18 07:25, Zhen Lei wrote: > 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. Makes sense to me. Acked-by: Robin Murphy > Signed-off-by: Zhen Lei > --- > 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 { > > static struct iova_magazine *iova_magazine_alloc(gfp_t flags) > { > - return kzalloc(sizeof(struct iova_magazine), flags); > + struct iova_magazine *mag; > + > + mag = kmalloc(sizeof(struct iova_magazine), flags); Nit: maybe sizeof(*mag) is preferable? > + if (mag) > + mag->size = 0; > + > + return mag; > } > > static void iova_magazine_free(struct iova_magazine *mag)