summaryrefslogtreecommitdiffstats
path: root/kernel/dma
diff options
context:
space:
mode:
authorPetr Tesarik <petr.tesarik.ext@huawei.com>2023-06-07 11:04:18 +0200
committerChristoph Hellwig <hch@lst.de>2023-06-07 15:06:40 +0200
commit693405cf11357017ea29764e3bd9488a2d292d8f (patch)
tree92e8af68663f2ae5f32e36cdba73cc679873168c /kernel/dma
parentefa76afdde16f195f8faff0e8dbe58ec18aad70c (diff)
downloadlinux-stable-693405cf11357017ea29764e3bd9488a2d292d8f.tar.gz
linux-stable-693405cf11357017ea29764e3bd9488a2d292d8f.tar.bz2
linux-stable-693405cf11357017ea29764e3bd9488a2d292d8f.zip
swiotlb: use the atomic counter of total used slabs if available
If DEBUG_FS is enabled, the cost of keeping an exact number of total used slabs is already paid. In this case, there is no reason to use an inexact number for statistics and kernel messages. Signed-off-by: Petr Tesarik <petr.tesarik.ext@huawei.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'kernel/dma')
-rw-r--r--kernel/dma/swiotlb.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index af2e304c672c..775f7bb10ab1 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -717,6 +717,15 @@ static int swiotlb_find_slots(struct device *dev, phys_addr_t orig_addr,
return -1;
}
+#ifdef CONFIG_DEBUG_FS
+
+static unsigned long mem_used(struct io_tlb_mem *mem)
+{
+ return atomic_long_read(&mem->total_used);
+}
+
+#else /* !CONFIG_DEBUG_FS */
+
static unsigned long mem_used(struct io_tlb_mem *mem)
{
int i;
@@ -727,6 +736,8 @@ static unsigned long mem_used(struct io_tlb_mem *mem)
return used;
}
+#endif /* CONFIG_DEBUG_FS */
+
phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr,
size_t mapping_size, size_t alloc_size,
unsigned int alloc_align_mask, enum dma_data_direction dir,