[PATCH 2/3] KVM: Add trace_kvm_vm_set_mem_attributes()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a tracing function to display the attribules being set for
a range of guest memory.

Sample output:

   <...>-12693   [059] .....  1342.536361: kvm_vm_set_mem_attributes:  0x00000000000000 -- 0x00000000080000 [0x8]
qemu-kvm-12693   [187] .....  1342.747651: kvm_vm_set_mem_attributes:  . 0x00000010000000 -- 0x00000018000000 [0x8]
qemu-kvm-12693   [040] .N...  1366.473790: kvm_vm_set_mem_attributes:  . 0x00000018000000 -- 0x00000020000000 [0x8]
qemu-kvm-12693   [009] .N...  1390.350362: kvm_vm_set_mem_attributes:  . 0x00000020000000 -- 0x00000028000000 [0x8]
qemu-kvm-12693   [008] .N...  1414.154231: kvm_vm_set_mem_attributes:  0x00000028000000 -- 0x0000002da80000 [0x8]
qemu-kvm-12693   [136] .....  1430.988101: kvm_vm_set_mem_attributes:  0x000000000ffc00 -- 0x00000000100000 [0x8]
qemu-kvm-12693   [024] .....  1431.029798: kvm_vm_set_mem_attributes:  0x00000000000000 -- 0x000000000000c0 [0x8]

The '.' before the addresses above signifies that the initial request
was split into multiple operations. Originally it was requested to
set the attributes on 0x00000010000000 to 0x0000002da80000

Signed-off-by: Liam Merwick <liam.merwick@xxxxxxxxxx>
---
 include/trace/events/kvm.h | 33 +++++++++++++++++++++++++++++++++
 virt/kvm/kvm_main.c        |  4 ++++
 2 files changed, 37 insertions(+)

diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index fc7d0f8ff078..701bf1f88850 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -473,6 +473,39 @@ TRACE_EVENT(kvm_dirty_ring_exit,
 	TP_printk("vcpu %d", __entry->vcpu_id)
 );
 
+#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
+/*
+ * @start:	Starting address of guest memory range
+ * @end:	End address of guest memory range
+ * @attr:	The value of the attribute being set.
+ * @indent:	If true, indent output displayed (printing '.' is used to
+ *		indicate that the transaction was split into multiple
+ *		operations and more are to follow).
+ */
+TRACE_EVENT(kvm_vm_set_mem_attributes,
+	TP_PROTO(gfn_t start, gfn_t end, unsigned long attr, bool indent),
+	TP_ARGS(start, end, attr, indent),
+
+	TP_STRUCT__entry(
+		__field(gfn_t,		start)
+		__field(gfn_t,		end)
+		__field(unsigned long,	attr)
+		__field(bool,		indent)
+	),
+
+	TP_fast_assign(
+		__entry->start		= start;
+		__entry->end		= end;
+		__entry->attr		= attr;
+		__entry->indent		= indent;
+	),
+
+	TP_printk("%s %#016llx -- %#016llx [0x%lx]",
+		  __entry->indent ? " ." : "",
+		  __entry->start, __entry->end, __entry->attr)
+);
+#endif /* CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES */
+
 TRACE_EVENT(kvm_unmap_hva_range,
 	TP_PROTO(unsigned long start, unsigned long end),
 	TP_ARGS(start, end),
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 6e6d404a7d7a..464357ea638c 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2568,11 +2568,15 @@ static int kvm_vm_ioctl_set_mem_attributes(struct kvm *kvm,
 			size = SZ_512G;
 			size_remaining -= size;
 			section_end = section_start + (size >> PAGE_SHIFT);
+			trace_kvm_vm_set_mem_attributes(section_start, section_end,
+							attrs->attributes, true);
 		} else {
 			size = size_remaining;
 			size_remaining = 0;
 			section_end = end;
 			WARN_ON_ONCE(section_end != (section_start + (size >> PAGE_SHIFT)));
+			trace_kvm_vm_set_mem_attributes(section_start, section_end,
+							attrs->attributes, false);
 		}
 
 		ret = kvm_vm_set_mem_attributes(kvm, section_start, section_end, attrs->attributes);
-- 
2.47.1





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux