Skip to content

Commit

Permalink
iommu/iova: Optimize iova_magazine_alloc()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zhen Lei authored and Joerg Roedel committed May 22, 2023
1 parent 44c026a commit 5d62bac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/iommu/iova.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5d62bac

Please sign in to comment.