Skip to contentSkip to conversation

KVM: VMX: add tracepoint for vpids

PATCH In review Davidlohr Bueso 2 participants 6 messages Mar 11, 2012 – Mar 13, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: VMX: add tracepoint for vpids

From: Davidlohr Bueso <[email protected]>

Add a new tracepoint for vpid allocation and freeing associated to all vCPUs.

---
 arch/x86/kvm/trace.h |   23 +++++++++++++++++++++++
 arch/x86/kvm/vmx.c   |    5 ++++-
 arch/x86/kvm/x86.c   |    1 +
 3 files changed, 28 insertions(+), 1 deletions(-)
arch/x86/kvm/trace.h +23 -0
index 911d264..2106a37 100644
@@ -27,6 +27,29 @@ TRACE_EVENT(kvm_entry,
 );
 
 /*
+ * Tracepoint for VMX vpid management
+ */
+TRACE_EVENT(kvm_vpid,
+	TP_PROTO(int vpid, bool allocate),
+	TP_ARGS(vpid, allocate),
+
+	TP_STRUCT__entry(
+		__field(         int,	vpid		        )
+		__field(         bool,	allocate       	        )
+	),
+
+	TP_fast_assign(
+		__entry->vpid	  = vpid;
+		__entry->allocate = allocate;
+	),
+
+	TP_printk("%s vpid %d",  __entry->allocate ? 
+		  "allocate" : "free", __entry->vpid)
+);
+#define trace_kvm_free_vpid(vpid)	trace_kvm_vpid(vpid, 0)
+#define trace_kvm_alloc_vpid(vpid)	trace_kvm_vpid(vpid, 1)
+
+/*
  * Tracepoint for hypercall.
  */
 TRACE_EVENT(kvm_hypercall,
arch/x86/kvm/vmx.c +4 -1
index 2c22fc7..5647805 100644
@@ -3571,6 +3571,7 @@ static void allocate_vpid(struct vcpu_vmx *vmx)
 		vmx->vpid = vpid;
 		__set_bit(vpid, vmx_vpid_bitmap);
 	}
+	trace_kvm_alloc_vpid(vpid);
 	spin_unlock(&vmx_vpid_lock);
 }
 
@@ -3579,8 +3580,10 @@ static void free_vpid(struct vcpu_vmx *vmx)
 	if (!enable_vpid)
 		return;
 	spin_lock(&vmx_vpid_lock);
-	if (vmx->vpid != 0)
+	if (vmx->vpid != 0) {
+		trace_kvm_free_vpid(vmx->vpid);
 		__clear_bit(vmx->vpid, vmx_vpid_bitmap);
+	}
 	spin_unlock(&vmx_vpid_lock);
 }
 
arch/x86/kvm/x86.c +1 -0
index 7ce5878..8a20512 100644
@@ -6606,3 +6606,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_nested_intr_vmexit);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_invlpga);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_skinit);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_nested_intercepts);
+EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vpid);
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 4 lines · Davidlohr Bueso

From: Davidlohr Bueso <[email protected]>

Add a new tracepoint for vpid allocation and freeing associated to all vCPUs.

Why?

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#2 lore raw
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Davidlohr Bueso

From: Davidlohr Bueso <[email protected]>

Add a new tracepoint for vpid allocation and freeing associated to all vCPUs.

Why?

We have been using this tracepoint for some time now to help debug vpids and simulating tagged TLB behavior and performance. This gets to be non trivial when working with large amounts of guests and vCPUs.

Thanks,
Davidlohr

#3 lore raw
Quoted 7 lines · Davidlohr Bueso
Quoted 6 lines · Avi Kivity
Quoted 4 lines · Davidlohr Bueso

From: Davidlohr Bueso <[email protected]>

Add a new tracepoint for vpid allocation and freeing associated to all vCPUs.

Quoted 6 lines
Quoted 2 lines

Why?

We have been using this tracepoint for some time now to help debug vpids and simulating tagged TLB behavior and performance. This gets to be non trivial when working with large amounts of guests and vCPUs.

I don't follow. Can you give an example of when this tracepoint would be useful?

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw
Quoted 11 lines · Avi Kivity
Quoted 10 lines · Davidlohr Bueso
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Davidlohr Bueso

From: Davidlohr Bueso <[email protected]>

Add a new tracepoint for vpid allocation and freeing associated to all vCPUs.

Why?

Quoted 7 lines
Quoted 3 lines

We have been using this tracepoint for some time now to help debug vpids and simulating tagged TLB behavior and performance. This gets to be non trivial when working with large amounts of guests and vCPUs.

I don't follow. Can you give an example of when this tracepoint would be useful?

For example when running lots of guests with many different hardware configurations (ept on/off, vpid on/off) I trace what vcpu has or doesn't have a corresponding vpid associated. Perhaps this is more useful for experimental things than actual KVM development.

#5 lore raw
Quoted 16 lines · Davidlohr Bueso
Quoted 15 lines · Avi Kivity
Quoted 13 lines · Davidlohr Bueso
Quoted 8 lines · Avi Kivity
Quoted 4 lines · Davidlohr Bueso

From: Davidlohr Bueso <[email protected]>

Add a new tracepoint for vpid allocation and freeing associated to all vCPUs.

Why?

We have been using this tracepoint for some time now to help debug vpids and simulating tagged TLB behavior and performance. This gets to be non trivial when working with large amounts of guests and vCPUs.

Quoted 8 lines
Quoted 3 lines

I don't follow. Can you give an example of when this tracepoint would be useful?

For example when running lots of guests with many different hardware configurations (ept on/off, vpid on/off) I trace what vcpu has or doesn't have a corresponding vpid associated. Perhaps this is more useful for experimental things than actual KVM development.

So it seems. Tracepoints should be useful for production deployments, not development.

Signature · 1 line
error compiling committee.c: too many arguments to function