[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Minor shadow code improvements.
ChangeSet 1.1423.8.1, 2005/05/10 12:15:11+01:00, mafetter@xxxxxxxxxxxxxxxx Minor shadow code improvements. arch/x86/shadow.c | 43 +++++++++++++++++++------------------------ common/perfc.c | 1 + include/asm-x86/shadow.h | 22 +++++++++------------- 3 files changed, 29 insertions(+), 37 deletions(-) diff -Nru a/xen/arch/x86/shadow.c b/xen/arch/x86/shadow.c --- a/xen/arch/x86/shadow.c 2005-05-10 11:05:47 -04:00 +++ b/xen/arch/x86/shadow.c 2005-05-10 11:05:47 -04:00 @@ -1898,37 +1898,34 @@ * Returns 0 otherwise. */ static int snapshot_entry_matches( - struct exec_domain *ed, unsigned long gmfn, unsigned index) + struct domain *d, l1_pgentry_t *guest_pt, + unsigned long gpfn, unsigned index) { - unsigned long gpfn = __mfn_to_gpfn(ed->domain, gmfn); - unsigned long smfn = __shadow_status(ed->domain, gpfn, PGT_snapshot); - unsigned long *guest, *snapshot; - int compare; - - ASSERT( ! IS_INVALID_M2P_ENTRY(gpfn) ); + unsigned long smfn = __shadow_status(d, gpfn, PGT_snapshot); + l1_pgentry_t *snapshot; // could be L1s or L2s or ... + int entries_match; perfc_incrc(snapshot_entry_matches_calls); if ( !smfn ) return 0; - guest = map_domain_mem(gmfn << PAGE_SHIFT); snapshot = map_domain_mem(smfn << PAGE_SHIFT); // This could probably be smarter, but this is sufficent for // our current needs. // - compare = (guest[index] == snapshot[index]); + entries_match = !l1e_has_changed(&guest_pt[index], &snapshot[index], + PAGE_FLAG_MASK); - unmap_domain_mem(guest); unmap_domain_mem(snapshot); #ifdef PERF_COUNTERS - if ( compare ) + if ( entries_match ) perfc_incrc(snapshot_entry_matches_true); #endif - return compare; + return entries_match; } /* @@ -1939,37 +1936,35 @@ { struct domain *d = ed->domain; unsigned long l2mfn = pagetable_get_pfn(ed->arch.guest_table); + unsigned long l2pfn = __mfn_to_gpfn(d, l2mfn); l2_pgentry_t l2e; - unsigned long l1mfn; + unsigned long l1pfn, l1mfn; ASSERT(spin_is_locked(&d->arch.shadow_lock)); + ASSERT(VALID_M2P(l2pfn)); perfc_incrc(shadow_out_of_sync_calls); - // PERF BUG: snapshot_entry_matches will call map_domain_mem() on the l2 - // page, but it's already available at ed->arch.guest_vtable... - // Ditto for the sl2 page and ed->arch.shadow_vtable. - // if ( page_out_of_sync(&frame_table[l2mfn]) && - !snapshot_entry_matches(ed, l2mfn, l2_table_offset(va)) ) + !snapshot_entry_matches(d, (l1_pgentry_t *)ed->arch.guest_vtable, + l2pfn, l2_table_offset(va)) ) return 1; __guest_get_l2e(ed, va, &l2e); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) return 0; - l1mfn = __gpfn_to_mfn(d, l2e_get_pfn(l2e)); + l1pfn = l2e_get_pfn(l2e); + l1mfn = __gpfn_to_mfn(d, l1pfn); // If the l1 pfn is invalid, it can't be out of sync... if ( !VALID_MFN(l1mfn) ) return 0; - // PERF BUG: snapshot_entry_matches will call map_domain_mem() on the l1 - // page, but it's already available at linear_pg_table[l1_linear_offset()]. - // Ditto for the sl1 page and shadow_linear_pg_table[]... - // if ( page_out_of_sync(&frame_table[l1mfn]) && - !snapshot_entry_matches(ed, l1mfn, l1_table_offset(va)) ) + !snapshot_entry_matches( + d, &linear_pg_table[l1_linear_offset(va) & ~(L1_PAGETABLE_ENTRIES-1)], + l1pfn, l1_table_offset(va)) ) return 1; return 0; diff -Nru a/xen/common/perfc.c b/xen/common/perfc.c --- a/xen/common/perfc.c 2005-05-10 11:05:47 -04:00 +++ b/xen/common/perfc.c 2005-05-10 11:05:47 -04:00 @@ -4,6 +4,7 @@ #include <xen/time.h> #include <xen/perfc.h> #include <xen/keyhandler.h> +#include <xen/spinlock.h> #include <public/dom0_ops.h> #include <asm/uaccess.h> diff -Nru a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h --- a/xen/include/asm-x86/shadow.h 2005-05-10 11:05:47 -04:00 +++ b/xen/include/asm-x86/shadow.h 2005-05-10 11:05:47 -04:00 @@ -518,9 +518,9 @@ else new_hl2e = l1e_empty(); - // only do the ref counting if something important changed. + // only do the ref counting if something has changed. // - if ( (l1e_has_changed(&old_hl2e, &new_hl2e, _PAGE_PRESENT)) ) + if ( (l1e_has_changed(&old_hl2e, &new_hl2e, PAGE_FLAG_MASK)) ) { if ( (l1e_get_flags(new_hl2e) & _PAGE_PRESENT) && !shadow_get_page(ed->domain, pfn_to_page(l1e_get_pfn(new_hl2e)), @@ -531,14 +531,15 @@ shadow_put_page(ed->domain, pfn_to_page(l1e_get_pfn(old_hl2e))); need_flush = 1; } - } - ed->arch.hl2_vtable[l2_table_offset(va)] = new_hl2e; + ed->arch.hl2_vtable[l2_table_offset(va)] = new_hl2e; - if ( need_flush ) - { - perfc_incrc(update_hl2e_invlpg); - local_flush_tlb_one(&linear_pg_table[l1_linear_offset(va)]); + if ( need_flush ) + { + perfc_incrc(update_hl2e_invlpg); + // SMP BUG??? + local_flush_tlb_one(&linear_pg_table[l1_linear_offset(va)]); + } } } @@ -1500,11 +1501,6 @@ struct exec_domain *ed = current; struct domain *d = ed->domain; l2_pgentry_t sl2e; - -#if 0 - printk("shadow_set_l1e(va=%p, new_spte=%p, create=%d)\n", - va, l1e_get_value(new_spte), create_l1_shadow); -#endif __shadow_get_l2e(ed, va, &sl2e); if ( !(l2e_get_flags(sl2e) & _PAGE_PRESENT) ) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |