Skip to content

Commit 5d62bac

Browse files
Zhen Leijoergroedel
authored andcommitted
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@arm.com> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Link: https://lore.kernel.org/r/20230421072422.869-1-thunder.leizhen@huawei.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 44c026a commit 5d62bac

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

drivers/iommu/iova.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,13 @@ struct iova_rcache {
647647

648648
static struct iova_magazine *iova_magazine_alloc(gfp_t flags)
649649
{
650-
return kzalloc(sizeof(struct iova_magazine), flags);
650+
struct iova_magazine *mag;
651+
652+
mag = kmalloc(sizeof(*mag), flags);
653+
if (mag)
654+
mag->size = 0;
655+
656+
return mag;
651657
}
652658

653659
static void iova_magazine_free(struct iova_magazine *mag)

0 commit comments

Comments
 (0)