Add tracing for GPA mapping hypercalls to aid in debugging memory
management issues in child partitions. The tracepoint captures both
successful and failed mapping attempts, including the number of pages
successfully mapped before any failure occurred.

Signed-off-by: Stanislav Kinsburskii <[email protected]>
---
 drivers/hv/mshv_root_hv_call.c |    3 +++
 drivers/hv/mshv_trace.h        |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/hv/mshv_root_hv_call.c b/drivers/hv/mshv_root_hv_call.c
index 00d37c39cbf26..ccf297fbfae3a 100644
--- a/drivers/hv/mshv_root_hv_call.c
+++ b/drivers/hv/mshv_root_hv_call.c
@@ -250,6 +250,9 @@ static int hv_do_map_pfns(u64 partition_id, u64 gfn, u64 
pfns_count,
                }
        }
 
+       trace_mshv_map_pfns(partition_id, gfn, pfns_count, page_count,
+                           flags, mmio_spa, done, ret);
+
        if (ret && done) {
                u32 unmap_flags = 0;
 
diff --git a/drivers/hv/mshv_trace.h b/drivers/hv/mshv_trace.h
index e7280c47e579a..619c4563d4211 100644
--- a/drivers/hv/mshv_trace.h
+++ b/drivers/hv/mshv_trace.h
@@ -538,6 +538,42 @@ TRACE_EVENT(mshv_handle_gpa_intercept,
            )
 );
 
+TRACE_EVENT(mshv_map_pfns,
+           TP_PROTO(u64 partition_id, u64 gfn, u64 pfn_count, u64 page_count, 
u32 flags,
+                    u64 mmio_spa, u64 done, int ret),
+           TP_ARGS(partition_id, gfn, pfn_count, page_count, flags, mmio_spa, 
done, ret),
+           TP_STRUCT__entry(
+                   __field(u64, partition_id)
+                   __field(u64, gfn)
+                   __field(u64, pfn_count)
+                   __field(u64, page_count)
+                   __field(u32, flags)
+                   __field(u64, mmio_spa)
+                   __field(u64, done)
+                   __field(int, ret)
+           ),
+           TP_fast_assign(
+                   __entry->partition_id = partition_id;
+                   __entry->gfn = gfn;
+                   __entry->pfn_count = pfn_count;
+                   __entry->page_count = page_count;
+                   __entry->flags = flags;
+                   __entry->mmio_spa = mmio_spa;
+                   __entry->done = done;
+                   __entry->ret = ret;
+           ),
+           TP_printk("partition_id=%llu gfn=0x%llx pfn_count=%llu 
page_count=%llu flags=0x%x mmio_spa=0x%llx done=%llu ret=%d",
+                   __entry->partition_id,
+                   __entry->gfn,
+                   __entry->pfn_count,
+                   __entry->page_count,
+                   __entry->flags,
+                   __entry->mmio_spa,
+                   __entry->done,
+                   __entry->ret
+           )
+);
+
 #endif /* _MSHV_TRACE_H_ */
 
 /* This part must be outside protection */



Reply via email to