Skip to content

Commit

Permalink
swiotlb: Add tracepoint swiotlb_unbounced
Browse files Browse the repository at this point in the history
Add a new tracepoint swiotlb_unbounced to facilitate statistics of
swiotlb buffer usage.

Signed-off-by: GuoRui.Yu <GuoRui.Yu@linux.alibaba.com>
  • Loading branch information
GuoRui.Yu authored and intel-lab-lkp committed Jan 28, 2023
1 parent 9345d2c commit 761de34
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions include/trace/events/swiotlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions kernel/dma/common-swiotlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 761de34

Please sign in to comment.