diff options
author | Michael Kelley <mikelley@microsoft.com> | 2023-04-13 10:57:37 -0700 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2023-04-16 08:25:29 +0200 |
commit | 8b0977ecc8b30a30966e76fcb64cef5041626b02 (patch) | |
tree | 03dd9c0b0e6db4deb953e00c97b0a8c617264866 /include/linux/swiotlb.h | |
parent | 5499d01c029069044a3b3e50501c77b474c96178 (diff) |
swiotlb: track and report io_tlb_used high water marks in debugfs
swiotlb currently reports the total number of slabs and the instantaneous
in-use slabs in debugfs. But with increased usage of swiotlb for all I/O
in Confidential Computing (coco) VMs, it has become difficult to know
how much memory to allocate for swiotlb bounce buffers, either via the
automatic algorithm in the kernel or by specifying a value on the
kernel boot line. The current automatic algorithm generously allocates
swiotlb bounce buffer memory, and may be wasting significant memory in
many use cases.
To support better understanding of swiotlb usage, add tracking of the
the high water mark for usage of the default swiotlb bounce buffer memory
pool and any reserved memory pools. Report these high water marks in
debugfs along with the other swiotlb pool metrics. Allow the high water
marks to be reset to zero at runtime by writing to them.
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/linux/swiotlb.h')
-rw-r--r-- | include/linux/swiotlb.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index bcef10e20ea4..6dc4598d2260 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h @@ -87,6 +87,11 @@ dma_addr_t swiotlb_map(struct device *dev, phys_addr_t phys, * @for_alloc: %true if the pool is used for memory allocation * @nareas: The area number in the pool. * @area_nslabs: The slot number in the area. + * @total_used: The total number of slots in the pool that are currently used + * across all areas. Used only for calculating used_hiwater in + * debugfs. + * @used_hiwater: The high water mark for total_used. Used only for reporting + * in debugfs. */ struct io_tlb_mem { phys_addr_t start; @@ -102,6 +107,8 @@ struct io_tlb_mem { unsigned int area_nslabs; struct io_tlb_area *areas; struct io_tlb_slot *slots; + atomic_long_t total_used; + atomic_long_t used_hiwater; }; extern struct io_tlb_mem io_tlb_default_mem; |