[3/4] swiotlb: Add tracepoint swiotlb_unbounced
Commit Message
Add a new tracepoint swiotlb_unbounced to facilitate statistics of
swiotlb buffer usage.
Signed-off-by: GuoRui.Yu <GuoRui.Yu@linux.alibaba.com>
---
include/trace/events/swiotlb.h | 28 ++++++++++++++++++++++++++++
kernel/dma/common-swiotlb.c | 1 +
2 files changed, 29 insertions(+)
@@ -35,6 +35,34 @@ TRACE_EVENT(swiotlb_bounced,
__entry->force ? "FORCE" : "NORMAL")
);
+TRACE_EVENT(swiotlb_unbounced,
+ TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size),
+ TP_ARGS(dev, dev_addr, size),
+
+ TP_STRUCT__entry(
+ __string(dev_name, dev_name(dev))
+ __field(u64, dma_mask)
+ __field(dma_addr_t, dev_addr)
+ __field(size_t, size)
+ __field(bool, force)
+ ),
+
+ TP_fast_assign(
+ __assign_str(dev_name, dev_name(dev));
+ __entry->dma_mask = (dev->dma_mask ? *dev->dma_mask : 0);
+ __entry->dev_addr = dev_addr;
+ __entry->size = size;
+ __entry->force = is_swiotlb_force_bounce(dev);
+ ),
+
+ TP_printk("dev_name: %s dma_mask=%llx dev_addr=%llx size=%zu %s",
+ __get_str(dev_name),
+ __entry->dma_mask,
+ (unsigned long long)__entry->dev_addr,
+ __entry->size,
+ __entry->force ? "FORCE" : "NORMAL")
+);
+
#endif /* _TRACE_SWIOTLB_H */
/* This part must be outside protection */
@@ -46,6 +46,7 @@ void swiotlb_tbl_unmap_single(struct device *dev, phys_addr_t tlb_addr,
size_t mapping_size, enum dma_data_direction dir,
unsigned long attrs)
{
+ trace_swiotlb_unbounced(dev, phys_to_dma(dev, tlb_addr), mapping_size);
/*
* First, sync the memory before unmapping the entry
*/