* [PATCH v1 1/1] swiotlb: use the atomic counter of total used slabs if available
@ 2023-06-07 9:04 Petr Tesarik
2023-06-07 13:07 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Petr Tesarik @ 2023-06-07 9:04 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
open list:DMA MAPPING HELPERS, open list
Cc: Roberto Sassu, Kefeng Wang, petr
From: Petr Tesarik <petr.tesarik.ext@huawei.com>
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>
---
kernel/dma/swiotlb.c | 11 +++++++++++
1 file changed, 11 insertions(+)
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,
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1 1/1] swiotlb: use the atomic counter of total used slabs if available
2023-06-07 9:04 [PATCH v1 1/1] swiotlb: use the atomic counter of total used slabs if available Petr Tesarik
@ 2023-06-07 13:07 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2023-06-07 13:07 UTC (permalink / raw)
To: Petr Tesarik
Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
open list:DMA MAPPING HELPERS, open list, Roberto Sassu,
Kefeng Wang, petr
Thanks,
applied to for-next.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-07 13:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07 9:04 [PATCH v1 1/1] swiotlb: use the atomic counter of total used slabs if available Petr Tesarik
2023-06-07 13:07 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox