Skip to content

Commit a84c690

Browse files
jpemartinsjgunthorpe
authored andcommitted
iommufd/iova_bitmap: Cache mapped length in iova_bitmap_map struct
The amount of IOVA mapped will be used more often in iova_bitmap_set() in preparation to dynamically iterate the bitmap. Cache said length to avoid having to calculate it all the time. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joao Martins <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Tested-by: Matt Ochs <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 7925836 commit a84c690

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/iommu/iommufd/iova_bitmap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ struct iova_bitmap_map {
3535
/* base IOVA representing bit 0 of the first page */
3636
unsigned long iova;
3737

38+
/* mapped length */
39+
unsigned long length;
40+
3841
/* page size order that each bit granules to */
3942
unsigned long pgshift;
4043

@@ -156,6 +159,8 @@ static unsigned long iova_bitmap_mapped_iova(struct iova_bitmap *bitmap)
156159
return bitmap->iova + iova_bitmap_index_to_offset(bitmap, skip);
157160
}
158161

162+
static unsigned long iova_bitmap_mapped_length(struct iova_bitmap *bitmap);
163+
159164
/*
160165
* Pins the bitmap user pages for the current range window.
161166
* This is internal to IOVA bitmap and called when advancing the
@@ -206,6 +211,7 @@ static int iova_bitmap_get(struct iova_bitmap *bitmap)
206211
* aligned.
207212
*/
208213
mapped->pgoff = offset_in_page(addr);
214+
mapped->length = iova_bitmap_mapped_length(bitmap);
209215
return 0;
210216
}
211217

0 commit comments

Comments
 (0)