All of lore.kernel.org
 help / color / mirror / Atom feed
* kvm-trace help
@ 2008-04-18 22:40 David S. Ahern
  2008-04-19  2:12 ` Liu, Eric E
  0 siblings, 1 reply; 5+ messages in thread
From: David S. Ahern @ 2008-04-18 22:40 UTC (permalink / raw)
  To: kvm-devel, eric.e.liu

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

I am trying to add a trace marker and the data is coming out all 0's. e.g.,

0 (+       0)  PTE_WRITE     vcpu = 0x00000001  pid = 0x0000240d [ gpa =
0x00000000 00000000 gpte = 0x00000000 00000000 ]

Patch is attached. I know the data is non-zero as I added an if check before
calling the trace to only do the trace if the data is non-zero. Anyone have
suggestions on what I am missing?

thanks,

david



[-- Attachment #2: kvm-trace.patch --]
[-- Type: text/x-patch, Size: 5339 bytes --]

diff -rb -U 10 kvm-66.orig/kernel/include/asm/kvm.h kvm-66/kernel/include/asm/kvm.h
--- kvm-66.orig/kernel/include/asm/kvm.h	2008-04-16 08:29:14.000000000 -0600
+++ kvm-66/kernel/include/asm/kvm.h	2008-04-18 12:41:07.000000000 -0600
@@ -221,12 +221,14 @@
 #define KVM_TRC_MSR_READ         (KVM_TRC_HANDLER + 0x0B)
 #define KVM_TRC_MSR_WRITE        (KVM_TRC_HANDLER + 0x0C)
 #define KVM_TRC_CPUID            (KVM_TRC_HANDLER + 0x0D)
 #define KVM_TRC_INTR             (KVM_TRC_HANDLER + 0x0E)
 #define KVM_TRC_NMI              (KVM_TRC_HANDLER + 0x0F)
 #define KVM_TRC_VMMCALL          (KVM_TRC_HANDLER + 0x10)
 #define KVM_TRC_HLT              (KVM_TRC_HANDLER + 0x11)
 #define KVM_TRC_CLTS             (KVM_TRC_HANDLER + 0x12)
 #define KVM_TRC_LMSW             (KVM_TRC_HANDLER + 0x13)
 #define KVM_TRC_APIC_ACCESS      (KVM_TRC_HANDLER + 0x14)
+#define KVM_TRC_PTE_WRITE        (KVM_TRC_HANDLER + 0x15)
+#define KVM_TRC_PTE_FLOODED      (KVM_TRC_HANDLER + 0x16)
 
 #endif
diff -rb -U 10 kvm-66.orig/kernel/include/asm-x86/kvm.h kvm-66/kernel/include/asm-x86/kvm.h
--- kvm-66.orig/kernel/include/asm-x86/kvm.h	2008-04-16 08:29:14.000000000 -0600
+++ kvm-66/kernel/include/asm-x86/kvm.h	2008-04-18 12:41:07.000000000 -0600
@@ -221,12 +221,14 @@
 #define KVM_TRC_MSR_READ         (KVM_TRC_HANDLER + 0x0B)
 #define KVM_TRC_MSR_WRITE        (KVM_TRC_HANDLER + 0x0C)
 #define KVM_TRC_CPUID            (KVM_TRC_HANDLER + 0x0D)
 #define KVM_TRC_INTR             (KVM_TRC_HANDLER + 0x0E)
 #define KVM_TRC_NMI              (KVM_TRC_HANDLER + 0x0F)
 #define KVM_TRC_VMMCALL          (KVM_TRC_HANDLER + 0x10)
 #define KVM_TRC_HLT              (KVM_TRC_HANDLER + 0x11)
 #define KVM_TRC_CLTS             (KVM_TRC_HANDLER + 0x12)
 #define KVM_TRC_LMSW             (KVM_TRC_HANDLER + 0x13)
 #define KVM_TRC_APIC_ACCESS      (KVM_TRC_HANDLER + 0x14)
+#define KVM_TRC_PTE_WRITE        (KVM_TRC_HANDLER + 0x15)
+#define KVM_TRC_PTE_FLOODED      (KVM_TRC_HANDLER + 0x16)
 
 #endif
diff -rb -U 10 kvm-66.orig/kernel/mmu.c kvm-66/kernel/mmu.c
--- kvm-66.orig/kernel/mmu.c	2008-04-16 08:29:14.000000000 -0600
+++ kvm-66/kernel/mmu.c	2008-04-18 11:50:16.000000000 -0600
@@ -1662,20 +1662,22 @@
 			if (r)
 				return;
 			memcpy((void *)&gpte + (gpa % 8), new, 4);
 		} else if ((bytes == 8) && (gpa % 8 == 0)) {
 			memcpy((void *)&gpte, new, 8);
 		}
 	} else {
 		if ((bytes == 4) && (gpa % 4 == 0))
 			memcpy((void *)&gpte, new, 4);
 	}
+	KVMTRACE_4D(PTE_WRITE, vcpu, (u32) gpa, (u32)(gpa>>32), 
+	            (u32) gpte, (u32)(gpte>>32), handler);
 	if (!is_present_pte(gpte))
 		return;
 	gfn = (gpte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
 
 	down_read(&current->mm->mmap_sem);
 	if (is_large_pte(gpte) && is_largepage_backed(vcpu, gfn)) {
 		gfn &= ~(KVM_PAGES_PER_HPAGE-1);
 		vcpu->arch.update_pte.largepage = 1;
 	}
 	pfn = gfn_to_pfn(vcpu->kvm, gfn);
@@ -1711,21 +1713,22 @@
 
 	pgprintk("%s: gpa %llx bytes %d\n", __func__, gpa, bytes);
 	mmu_guess_page_from_pte_write(vcpu, gpa, new, bytes);
 	spin_lock(&vcpu->kvm->mmu_lock);
 	kvm_mmu_free_some_pages(vcpu);
 	++vcpu->kvm->stat.mmu_pte_write;
 	kvm_mmu_audit(vcpu, "pre pte write");
 	if (gfn == vcpu->arch.last_pt_write_gfn
 	    && !last_updated_pte_accessed(vcpu)) {
 		++vcpu->arch.last_pt_write_count;
-		if (vcpu->arch.last_pt_write_count >= 3)
+		if (vcpu->arch.last_pt_write_count >= 4)
+			KVMTRACE_0D(PTE_FLOODED, vcpu, handler);
 			flooded = 1;
 	} else {
 		vcpu->arch.last_pt_write_gfn = gfn;
 		vcpu->arch.last_pt_write_count = 1;
 		vcpu->arch.last_pte_updated = NULL;
 	}
 	index = kvm_page_table_hashfn(gfn);
 	bucket = &vcpu->kvm->arch.mmu_page_hash[index];
 	hlist_for_each_entry_safe(sp, node, n, bucket, hash_link) {
 		if (sp->gfn != gfn || sp->role.metaphysical)
diff -rb -U 10 kvm-66.orig/user/formats kvm-66/user/formats
--- kvm-66.orig/user/formats	2008-04-15 07:35:58.000000000 -0600
+++ kvm-66/user/formats	2008-04-18 12:46:36.000000000 -0600
@@ -15,10 +15,12 @@
 0x0002000B  %(tsc)d (+%(reltsc)8d)  MSR_READ      vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x [ MSR# = 0x%(1)08x, data = 0x%(3)08x %(2)08x ]
 0x0002000C  %(tsc)d (+%(reltsc)8d)  MSR_WRITE     vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x [ MSR# = 0x%(1)08x, data = 0x%(3)08x %(2)08x ]
 0x0002000D  %(tsc)d (+%(reltsc)8d)  CPUID         vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x [ func = 0x%(1)08x, eax = 0x%(2)08x, ebx = 0x%(3)08x, ecx = 0x%(4)08x edx = 0x%(5)08x]
 0x0002000E  %(tsc)d (+%(reltsc)8d)  INTR          vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x [ vector = 0x%(1)02x ]
 0x0002000F  %(tsc)d (+%(reltsc)8d)  NMI           vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x
 0x00020010  %(tsc)d (+%(reltsc)8d)  VMMCALL       vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x [ func = 0x%(1)08x ]
 0x00020011  %(tsc)d (+%(reltsc)8d)  HLT           vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x
 0x00020012  %(tsc)d (+%(reltsc)8d)  CLTS          vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x
 0x00020013  %(tsc)d (+%(reltsc)8d)  LMSW          vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x [ value = 0x%(1)08x ]
 0x00020014  %(tsc)d (+%(reltsc)8d)  APIC_ACCESS   vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x [ offset = 0x%(1)08x ]
+0x00020015  %(tsc)d (+%(reltsc)8d)  PTE_FLOODED   vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x 
+0x00020016  %(tsc)d (+%(reltsc)8d)  PTE_WRITE     vcpu = 0x%(vcpu)08x  pid = 0x%(pid)08x [ gpa = 0x%(2)08x %(1)08x gpte = 0x%(4)08x %(3)08x ]

[-- Attachment #3: Type: text/plain, Size: 320 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

[-- Attachment #4: Type: text/plain, Size: 158 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kvm-trace help
  2008-04-18 22:40 kvm-trace help David S. Ahern
@ 2008-04-19  2:12 ` Liu, Eric E
  2008-04-19  3:53   ` David S. Ahern
  0 siblings, 1 reply; 5+ messages in thread
From: Liu, Eric E @ 2008-04-19  2:12 UTC (permalink / raw)
  To: David S. Ahern; +Cc: kvm-devel

David S. Ahern wrote:
> I am trying to add a trace marker and the data is coming out all 0's.
> e.g., 
> 
> 0 (+       0)  PTE_WRITE     vcpu = 0x00000001  pid = 0x0000240d [
> gpa = 0x00000000 00000000 gpte = 0x00000000 00000000 ]
> 
> Patch is attached. I know the data is non-zero as I added an if check
> before calling the trace to only do the trace if the data is
> non-zero. Anyone have suggestions on what I am missing?
> 
> thanks,
> 
> david
Hi, david
	I read your patch and find this:
		+#define KVM_TRC_PTE_WRITE        (KVM_TRC_HANDLER +
0x15)
  		+#define KVM_TRC_PTE_FLOODED      (KVM_TRC_HANDLER +
0x16)
           but in your formats file 
		+0x00020015  %(tsc)d (+%(reltsc)8d)  PTE_FLOODED   vcpu
= 0x%(vcpu)08x  pid = 0x%(pid)08x
		+0x00020016  %(tsc)d (+%(reltsc)8d)  PTE_WRITE     vcpu
= 0x%(vcpu)08x  pid = 0x%(pid)08x [ gpa = 0x%(2)08x %(1)08x gpte =
0x%(4)08x %(3)08x ]
	You mistake the value, right?

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kvm-trace help
  2008-04-19  2:12 ` Liu, Eric E
@ 2008-04-19  3:53   ` David S. Ahern
  2008-04-19  4:04     ` Liu, Eric E
  0 siblings, 1 reply; 5+ messages in thread
From: David S. Ahern @ 2008-04-19  3:53 UTC (permalink / raw)
  To: Liu, Eric E; +Cc: kvm-devel

inline.

Liu, Eric E wrote:
> David S. Ahern wrote:
>> I am trying to add a trace marker and the data is coming out all 0's.
>> e.g., 
>>
>> 0 (+       0)  PTE_WRITE     vcpu = 0x00000001  pid = 0x0000240d [
>> gpa = 0x00000000 00000000 gpte = 0x00000000 00000000 ]
>>
>> Patch is attached. I know the data is non-zero as I added an if check
>> before calling the trace to only do the trace if the data is
>> non-zero. Anyone have suggestions on what I am missing?
>>
>> thanks,
>>
>> david
> Hi, david
> 	I read your patch and find this:
> 		+#define KVM_TRC_PTE_WRITE        (KVM_TRC_HANDLER +
> 0x15)
>   		+#define KVM_TRC_PTE_FLOODED      (KVM_TRC_HANDLER +
> 0x16)
>            but in your formats file 
> 		+0x00020015  %(tsc)d (+%(reltsc)8d)  PTE_FLOODED   vcpu
> = 0x%(vcpu)08x  pid = 0x%(pid)08x
> 		+0x00020016  %(tsc)d (+%(reltsc)8d)  PTE_WRITE     vcpu
> = 0x%(vcpu)08x  pid = 0x%(pid)08x [ gpa = 0x%(2)08x %(1)08x gpte =
> 0x%(4)08x %(3)08x ]
> 	You mistake the value, right?
> 

Which value? Do you mean the 0x00020015 and0x00020016?

kvm.h shows KVM_TRC_APIC_ACCESS as KVM_TRC_HANDLER + 0x14. I added the PTE_WRITE
and PTE_FLOODED after that in kvm.h with the values 0x15 and 0x16. Then in the
formats file it shows APIC_ACCESS as 0x00020014, and I added the new PTE entries
after that as 20015 and 20016. The kvmtrace_format tool does show those lines in
its output which makes me believe these values are ok.

What has me puzzled is the 0 values for gpa and gpte. I believe they are not 0
because I added "if (gpa || gpte) before the KVMTRACE_4D(PTE_WRITE, ...) line
and the lines still show up in the trace output.

david

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kvm-trace help
  2008-04-19  3:53   ` David S. Ahern
@ 2008-04-19  4:04     ` Liu, Eric E
  2008-04-19 20:25       ` David S. Ahern
  0 siblings, 1 reply; 5+ messages in thread
From: Liu, Eric E @ 2008-04-19  4:04 UTC (permalink / raw)
  To: David S. Ahern; +Cc: kvm-devel

David S. Ahern wrote:
> inline.
> 
> Liu, Eric E wrote:
>> David S. Ahern wrote:
>>> I am trying to add a trace marker and the data is coming out all
>>> 0's. e.g., 
>>> 
>>> 0 (+       0)  PTE_WRITE     vcpu = 0x00000001  pid = 0x0000240d [
>>> gpa = 0x00000000 00000000 gpte = 0x00000000 00000000 ]
>>> 
>>> Patch is attached. I know the data is non-zero as I added an if
>>> check before calling the trace to only do the trace if the data is
>>> non-zero. Anyone have suggestions on what I am missing?
>>> 
>>> thanks,
>>> 
>>> david
>> Hi, david
>> 	I read your patch and find this:
>> 		+#define KVM_TRC_PTE_WRITE        (KVM_TRC_HANDLER +
0x15)
>>   		+#define KVM_TRC_PTE_FLOODED      (KVM_TRC_HANDLER +
0x16)
>>            but in your formats file
>> 		+0x00020015  %(tsc)d (+%(reltsc)8d)  PTE_FLOODED   vcpu
>> = 0x%(vcpu)08x  pid = 0x%(pid)08x
>> 		+0x00020016  %(tsc)d (+%(reltsc)8d)  PTE_WRITE     vcpu
>> = 0x%(vcpu)08x  pid = 0x%(pid)08x [ gpa = 0x%(2)08x %(1)08x gpte =
>> 	0x%(4)08x %(3)08x ] You mistake the value, right?
>> 
> 
> Which value? Do you mean the 0x00020015 and0x00020016?
> 
> kvm.h shows KVM_TRC_APIC_ACCESS as KVM_TRC_HANDLER + 0x14. I added
> the PTE_WRITE and PTE_FLOODED after that in kvm.h with the values
> 0x15 and 0x16. Then in the formats file it shows APIC_ACCESS as
> 0x00020014, and I added the new PTE entries after that as 20015 and
> 20016. The kvmtrace_format tool does show those lines in its output
> which makes me believe these values are ok. 
>
 
I mean the value of PTE_WRITE you write in the formats file ( 0x00020016
)should be same with KVM_TRC_PTE_WRITE you define in kvm.h,
but now it is  0x00020015. if not what you get in the text file will be
disordered. 
 
> What has me puzzled is the 0 values for gpa and gpte. I believe they
> are not 0 because I added "if (gpa || gpte) before the
> KVMTRACE_4D(PTE_WRITE, ...) line and the lines still show up in the
> trace output. 
> 
> david


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kvm-trace help
  2008-04-19  4:04     ` Liu, Eric E
@ 2008-04-19 20:25       ` David S. Ahern
  0 siblings, 0 replies; 5+ messages in thread
From: David S. Ahern @ 2008-04-19 20:25 UTC (permalink / raw)
  To: Liu, Eric E; +Cc: kvm-devel

DOH. I had the 2 new ones backwards in the formats file.

thanks for pointing that out,

david

Liu, Eric E wrote:
>  
> I mean the value of PTE_WRITE you write in the formats file ( 0x00020016
> )should be same with KVM_TRC_PTE_WRITE you define in kvm.h,
> but now it is  0x00020015. if not what you get in the text file will be
> disordered. 
> 

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-04-19 20:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-18 22:40 kvm-trace help David S. Ahern
2008-04-19  2:12 ` Liu, Eric E
2008-04-19  3:53   ` David S. Ahern
2008-04-19  4:04     ` Liu, Eric E
2008-04-19 20:25       ` David S. Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.