[RFC][PATCH] iommu/dma: Do not call swiotlb tracepoint when not defined

From: Steven Rostedt
Date: Tue Jun 10 2025 - 20:23:42 EST



I'm working on code that will warn when a tracepoint is defined but not
used. As the TRACE_EVENT() logic still creates all the code regardless if
something calls the trace_<event>() function. It wastes around 5K per trace
event (less for tracepoints).

But it seems that the code in drivers/iommu/dma-iommu.c does the opposite.
It calls the trace_swiotlb_bounced() tracepoint without it being defined.
The tracepoint is defined in kernel/dma/swiotlb.c when CONFIG_SWIOTLB is
defined, but this code exists when that config is not defined.

This now fails with my work because I have all the callers reference the
tracepoint that they will call.

Thanks to the kernel test robot, it found this:

https://lore.kernel.org/all/202506091015.7zd87kI7-lkp@xxxxxxxxx/

Currently, I made this patch and it makes it build. But I don't like the
patch. It's in the middle of a function that has a lot of things called
swiotlb which seems like the #ifdef should be around much more than the
tracepoint hook that has no tracepoint attached to it.

Hopefully someone else can make a proper patch. I will be pushing my work
to linux-next during this cycle.

Not-signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index ea2ef53bd4fe..7c0ada27e66f 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -1153,8 +1153,9 @@ static phys_addr_t iommu_dma_map_swiotlb(struct device *dev, phys_addr_t phys,
return (phys_addr_t)DMA_MAPPING_ERROR;
}

+#ifdef CONFIG_SWIOTLB
trace_swiotlb_bounced(dev, phys, size);
-
+#endif
phys = swiotlb_tbl_map_single(dev, phys, size, iova_mask(iovad), dir,
attrs);