Skip to content

Commit b4c9bf1

Browse files
ftang1joergroedel
authored andcommitted
iommu/iova: change IOVA_MAG_SIZE to 127 to save memory
kmalloc will round up the request size to power of 2, and current iova_magazine's size is 1032 (1024+8) bytes, so each instance allocated will get 2048 bytes from kmalloc, causing around 1KB waste. Change IOVA_MAG_SIZE from 128 to 127 to make size of 'iova_magazine' 1024 bytes so that no memory will be wasted. Signed-off-by: Feng Tang <feng.tang@intel.com> Acked-by: Robin Murphy <robin.murphy@arm.com> Link: https://lore.kernel.org/r/20220703114450.15184-1-feng.tang@intel.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 4d26ba6 commit b4c9bf1

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/iommu/iova.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,12 @@ EXPORT_SYMBOL_GPL(reserve_iova);
614614
* dynamic size tuning described in the paper.
615615
*/
616616

617-
#define IOVA_MAG_SIZE 128
617+
/*
618+
* As kmalloc's buffer size is fixed to power of 2, 127 is chosen to
619+
* assure size of 'iova_magazine' to be 1024 bytes, so that no memory
620+
* will be wasted.
621+
*/
622+
#define IOVA_MAG_SIZE 127
618623
#define MAX_GLOBAL_MAGS 32 /* magazines per bin */
619624

620625
struct iova_magazine {

0 commit comments

Comments
 (0)