[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230421072422.869-1-thunder.leizhen@huawei.com>
Date: Fri, 21 Apr 2023 15:24:21 +0800
From: Zhen Lei <thunder.leizhen@...wei.com>
To: Robin Murphy <robin.murphy@....com>,
Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
<iommu@...ts.linux.dev>, <linux-kernel@...r.kernel.org>
CC: Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH v2] iommu/iova: Optimize iova_magazine_alloc()
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.
Acked-by: Robin Murphy <robin.murphy@....com>
Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
drivers/iommu/iova.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
v1 --> v2:
Change sizeof(struct iova_magazine) to sizeof(*mag).
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
index fe452ce466429a7..10b964600948c7f 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(*mag), flags);
+ if (mag)
+ mag->size = 0;
+
+ return mag;
}
static void iova_magazine_free(struct iova_magazine *mag)
--
2.25.1
Powered by blists - more mailing lists