Skip to content

Commit 693405c

Browse files
Petr TesarikChristoph Hellwig
authored andcommitted
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 <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent efa76af commit 693405c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

kernel/dma/swiotlb.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,15 @@ static int swiotlb_find_slots(struct device *dev, phys_addr_t orig_addr,
717717
return -1;
718718
}
719719

720+
#ifdef CONFIG_DEBUG_FS
721+
722+
static unsigned long mem_used(struct io_tlb_mem *mem)
723+
{
724+
return atomic_long_read(&mem->total_used);
725+
}
726+
727+
#else /* !CONFIG_DEBUG_FS */
728+
720729
static unsigned long mem_used(struct io_tlb_mem *mem)
721730
{
722731
int i;
@@ -727,6 +736,8 @@ static unsigned long mem_used(struct io_tlb_mem *mem)
727736
return used;
728737
}
729738

739+
#endif /* CONFIG_DEBUG_FS */
740+
730741
phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr,
731742
size_t mapping_size, size_t alloc_size,
732743
unsigned int alloc_align_mask, enum dma_data_direction dir,

0 commit comments

Comments
 (0)