diff -uNr a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c --- a/xen/arch/x86/mm/shadow/common.c 2008-08-06 19:12:59.202454259 +0100 +++ b/xen/arch/x86/mm/shadow/common.c 2008-08-06 19:15:03.922454259 +0100 @@ -631,6 +631,8 @@ if ( mfn_x(oos_fixup[idx].smfn[next]) != INVALID_MFN ) { + TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_OOS_FIXUP_EVICT); + /* Reuse this slot and remove current writable mapping. */ sh_remove_write_access_from_sl1p(v, gmfn, oos_fixup[idx].smfn[next], @@ -646,6 +648,8 @@ oos_fixup[idx].smfn[next] = smfn; oos_fixup[idx].off[next] = off; oos_fixup[idx].next = (next + 1) % SHADOW_OOS_FIXUPS; + + TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_OOS_FIXUP_ADD); return; } } @@ -688,6 +692,16 @@ } +static inline void trace_resync(int event, mfn_t gmfn) +{ + if ( tb_init_done ) + { + /* Convert gmfn to gfn */ + unsigned long gfn = mfn_to_gfn(current->domain, gmfn); + __trace_var(event, 0/*!tsc*/, sizeof(gfn), (unsigned char*)&gfn); + } +} + /* Pull all the entries on an out-of-sync page back into sync. */ static void _sh_resync(struct vcpu *v, mfn_t gmfn, struct oos_fixup *fixup, mfn_t snp) @@ -720,6 +734,7 @@ /* Now we know all the entries are synced, and will stay that way */ pg->shadow_flags &= ~SHF_out_of_sync; perfc_incr(shadow_resync); + trace_resync(TRC_SHADOW_RESYNC_FULL, gmfn); } @@ -931,6 +946,7 @@ /* Update the shadows and leave the page OOS. */ if ( sh_skip_sync(v, oos[idx]) ) continue; + trace_resync(TRC_SHADOW_RESYNC_ONLY, oos[idx]); _sh_resync_l1(other, oos[idx], oos_snapshot[idx]); } else @@ -946,7 +962,8 @@ } } -/* Allow a shadowed page to go out of sync */ +/* Allow a shadowed page to go out of sync. Unsyncs are traced in + * multi.c:sh_page_fault() */ int sh_unsync(struct vcpu *v, mfn_t gmfn) { struct page_info *pg; @@ -971,6 +988,7 @@ pg->shadow_flags |= SHF_out_of_sync|SHF_oos_may_write; oos_hash_add(v, gmfn); perfc_incr(shadow_unsync); + TRACE_SHADOW_PATH_FLAG(TRCE_SFLAG_UNSYNC); return 1; } diff -uNr a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h --- a/xen/arch/x86/mm/shadow/private.h 2008-08-06 19:12:59.212454259 +0100 +++ b/xen/arch/x86/mm/shadow/private.h 2008-08-06 19:15:03.922454259 +0100 @@ -122,7 +122,10 @@ TRCE_SFLAG_EMULATION_2ND_PT_WRITTEN, TRCE_SFLAG_EMULATION_LAST_FAILED, TRCE_SFLAG_EMULATE_FULL_PT, - TRCE_SFLAG_PREALLOC_UNHOOK + TRCE_SFLAG_PREALLOC_UNHOOK, + TRCE_SFLAG_UNSYNC, + TRCE_SFLAG_OOS_FIXUP_ADD, + TRCE_SFLAG_OOS_FIXUP_EVICT, }; /****************************************************************************** diff -uNr a/xen/include/public/trace.h b/xen/include/public/trace.h --- a/xen/include/public/trace.h 2008-08-06 19:12:59.212454259 +0100 +++ b/xen/include/public/trace.h 2008-08-06 19:15:03.922454259 +0100 @@ -107,6 +107,8 @@ #define TRC_SHADOW_EMULATE_UNSHADOW_UNHANDLED (TRC_SHADOW + 11) #define TRC_SHADOW_WRMAP_BF (TRC_SHADOW + 12) #define TRC_SHADOW_PREALLOC_UNPIN (TRC_SHADOW + 13) +#define TRC_SHADOW_RESYNC_FULL (TRC_SHADOW + 14) +#define TRC_SHADOW_RESYNC_ONLY (TRC_SHADOW + 15) /* trace events per subclass */ #define TRC_HVM_VMENTRY (TRC_HVM_ENTRYEXIT + 0x01)