lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230128083254.86012-4-GuoRui.Yu@linux.alibaba.com>
Date:   Sat, 28 Jan 2023 16:32:53 +0800
From:   "GuoRui.Yu" <GuoRui.Yu@...ux.alibaba.com>
To:     linux-kernel@...r.kernel.org, iommu@...ts.linux-foundation.org,
        konrad.wilk@...cle.com, linux-coco@...ts.linux.dev
Cc:     GuoRui.Yu@...ux.alibaba.com, robin.murphy@....com
Subject: [PATCH 3/4] swiotlb: Add tracepoint swiotlb_unbounced

Add a new tracepoint swiotlb_unbounced to facilitate statistics of
swiotlb buffer usage.

Signed-off-by: GuoRui.Yu <GuoRui.Yu@...ux.alibaba.com>
---
 include/trace/events/swiotlb.h | 28 ++++++++++++++++++++++++++++
 kernel/dma/common-swiotlb.c    |  1 +
 2 files changed, 29 insertions(+)

diff --git a/include/trace/events/swiotlb.h b/include/trace/events/swiotlb.h
index da05c9ebd224..0707adc34df5 100644
--- a/include/trace/events/swiotlb.h
+++ b/include/trace/events/swiotlb.h
@@ -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 */
diff --git a/kernel/dma/common-swiotlb.c b/kernel/dma/common-swiotlb.c
index 553325d5c9cd..e3676a8358f2 100644
--- a/kernel/dma/common-swiotlb.c
+++ b/kernel/dma/common-swiotlb.c
@@ -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
 	 */
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ