From 63c60c630f4a770a5380bee8df85daab20ef984d Mon Sep 17 00:00:00 2001 From: "mafetter@fleming.research" Date: Tue, 10 May 2005 11:15:11 +0000 Subject: [PATCH 1/6] bitkeeper revision 1.1389.13.1 (428097bfFCQnxc6PG1CYe-6KhZD8kA) Minor shadow code improvements. --- xen/arch/x86/shadow.c | 43 ++++++++++++++++-------------------- xen/common/perfc.c | 1 + xen/include/asm-x86/shadow.h | 22 ++++++++---------- 3 files changed, 29 insertions(+), 37 deletions(-) diff --git a/xen/arch/x86/shadow.c b/xen/arch/x86/shadow.c index 5e06fd1464..9769e060c1 100644 --- a/xen/arch/x86/shadow.c +++ b/xen/arch/x86/shadow.c @@ -1898,37 +1898,34 @@ void shadow_mark_va_out_of_sync( * 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 @@ int __shadow_out_of_sync(struct exec_domain *ed, unsigned long va) { 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 --git a/xen/common/perfc.c b/xen/common/perfc.c index 14ac09af41..f98910c91c 100644 --- a/xen/common/perfc.c +++ b/xen/common/perfc.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index 3871cca08d..d991a51f93 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -518,9 +518,9 @@ update_hl2e(struct exec_domain *ed, unsigned long va) 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 @@ update_hl2e(struct exec_domain *ed, unsigned long va) 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)]); + } } } @@ -1501,11 +1502,6 @@ shadow_set_l1e(unsigned long va, l1_pgentry_t new_spte, int create_l1_shadow) 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) ) { From de17f86b3ba78f3e69a88501de448fbfbbaeedf1 Mon Sep 17 00:00:00 2001 From: "mafetter@fleming.research" Date: Tue, 10 May 2005 11:32:50 +0000 Subject: [PATCH 2/6] bitkeeper revision 1.1389.5.48 (42809be2MsF_yD6mn_kF4ZL-8OJjkA) Fix ASSERT() caused by cleanup to map_domain_mem_with_cache() changes. --- xen/arch/x86/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index f62ab9c91d..d355b7e9af 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1992,7 +1992,7 @@ int do_mmu_update( printk("privileged guest dom%d requests pfn=%lx to map mfn=%lx for dom%d\n", d->id, gpfn, mfn, FOREIGNDOM->id); set_machinetophys(mfn, gpfn); - set_p2m_entry(FOREIGNDOM, gpfn, mfn, NULL, NULL); + set_p2m_entry(FOREIGNDOM, gpfn, mfn, &sh_mapcache, &mapcache); okay = 1; shadow_unlock(FOREIGNDOM); break; From 46d5b271ad939669420098821b4b38e5b8d858b6 Mon Sep 17 00:00:00 2001 From: "mafetter@fleming.research" Date: Tue, 10 May 2005 12:41:09 +0000 Subject: [PATCH 3/6] bitkeeper revision 1.1389.5.49 (4280abe5EW2fJtuPr5_E283AlKrziQ) Added back the printing of perfc arrays & histograms, under compile-time control in xen/Rules.mk --- xen/Rules.mk | 4 ++++ xen/common/perfc.c | 8 ++++++++ xen/include/xen/perfc.h | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/xen/Rules.mk b/xen/Rules.mk index 1fb12e8479..1db12a3d0d 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -2,6 +2,7 @@ verbose ?= n debug ?= n perfc ?= n +perfc_arrays?= n trace ?= n optimize ?= y domu_debug ?= n @@ -54,6 +55,9 @@ endif ifeq ($(perfc),y) CFLAGS += -DPERF_COUNTERS +ifeq ($(perfc_arrays),y) +CFLAGS += -DPERF_ARRAYS +endif endif ifeq ($(trace),y) diff --git a/xen/common/perfc.c b/xen/common/perfc.c index f98910c91c..157d49ffc8 100644 --- a/xen/common/perfc.c +++ b/xen/common/perfc.c @@ -67,6 +67,14 @@ void perfc_printall(unsigned char key) for ( j = sum = 0; j < perfc_info[i].nr_elements; j++ ) sum += atomic_read(&counters[j]); printk("TOTAL[%10d] ", sum); +#ifdef PERF_ARRAYS + for ( j = 0; j < perfc_info[i].nr_elements; j++ ) + { + if ( (j != 0) && ((j % 4) == 0) ) + printk("\n "); + printk("ARR%02d[%10d] ", j, atomic_read(&counters[j])); + } +#endif counters += j; break; } diff --git a/xen/include/xen/perfc.h b/xen/include/xen/perfc.h index 6d758497b1..48c7e90fb4 100644 --- a/xen/include/xen/perfc.h +++ b/xen/include/xen/perfc.h @@ -87,6 +87,7 @@ extern struct perfcounter perfcounters; * Histogram: special treatment for 0 and 1 count. After that equally spaced * with last bucket taking the rest. */ +#ifdef PERFC_ARRAYS #define perfc_incr_histo(_x,_v,_n) \ do { \ if ( (_v) == 0 ) \ @@ -99,6 +100,9 @@ extern struct perfcounter perfcounters; else \ perfc_incra(_x, PERFC_MAX_ ## _n - 1); \ } while ( 0 ) +#else +#define perfc_incr_histo(_x,_v,_n) ((void)0) +#endif #else /* PERF_COUNTERS */ From dd53aba2e73aa348d6f026e9c324590678908a87 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Tue, 10 May 2005 13:03:18 +0000 Subject: [PATCH 4/6] bitkeeper revision 1.1389.14.1 (4280b116_nJbXsZ9VQ4cosX8Wdyi9g) boot.c: acpi_scan_rsdp's parameters are (start, len) and not (start, end). Signed-off-by: Christian Limpach --- xen/arch/x86/acpi/boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/acpi/boot.c b/xen/arch/x86/acpi/boot.c index 184d10af9b..7237d5e7e2 100644 --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -647,7 +647,7 @@ acpi_find_rsdp (void) */ rsdp_phys = acpi_scan_rsdp (0, 0x400); if (!rsdp_phys) - rsdp_phys = acpi_scan_rsdp (0xE0000, 0xFFFFF); + rsdp_phys = acpi_scan_rsdp (0xE0000, 0x20000); return rsdp_phys; } From 97995e1d4268953147afb348f6725b0734b89c03 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Tue, 10 May 2005 13:31:06 +0000 Subject: [PATCH 5/6] bitkeeper revision 1.1389.14.2 (4280b79axJTjlpP4pLQJ2vgfWKJ0og) smpboot_hooks.h, smpboot.c: Also setup IO APIC when running an SMP guest. Signed-off-by: Christian Limpach --- linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c | 2 ++ .../include/asm-xen/asm-i386/mach-xen/smpboot_hooks.h | 4 ---- .../include/asm-xen/asm-x86_64/mach-xen/smpboot_hooks.h | 4 ---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c index ec1b3b9dea..bbe0963942 100644 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c @@ -1267,9 +1267,11 @@ static void __init smp_boot_cpus(unsigned int max_cpus) #if 0 if (nmi_watchdog == NMI_LOCAL_APIC) check_nmi_watchdog(); +#endif smpboot_setup_io_apic(); +#if 0 setup_boot_APIC_clock(); /* diff --git a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mach-xen/smpboot_hooks.h b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mach-xen/smpboot_hooks.h index 421a81f17b..7479f82686 100644 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mach-xen/smpboot_hooks.h +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mach-xen/smpboot_hooks.h @@ -43,16 +43,12 @@ static inline void smpboot_restore_warm_reset_vector(void) static inline void smpboot_setup_io_apic(void) { -#if 1 - printk("smpboot_setup_io_apic\n"); -#else /* * Here we can be sure that there is an IO-APIC in the system. Let's * go and set it up: */ if (!skip_ioapic_setup && nr_ioapics) setup_IO_APIC(); -#endif } diff --git a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/smpboot_hooks.h b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/smpboot_hooks.h index 421a81f17b..7479f82686 100644 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/smpboot_hooks.h +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-x86_64/mach-xen/smpboot_hooks.h @@ -43,16 +43,12 @@ static inline void smpboot_restore_warm_reset_vector(void) static inline void smpboot_setup_io_apic(void) { -#if 1 - printk("smpboot_setup_io_apic\n"); -#else /* * Here we can be sure that there is an IO-APIC in the system. Let's * go and set it up: */ if (!skip_ioapic_setup && nr_ioapics) setup_IO_APIC(); -#endif } From fcf68acc05db177103ebb71725b554dc153ca9ce Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Tue, 10 May 2005 13:40:14 +0000 Subject: [PATCH 6/6] bitkeeper revision 1.1389.5.52 (4280b9beG5xwTCb0TZxrZ0Cx_ku3fQ) smpboot.c: start_secondary doesn't return anything. Dprintk gets defined in apic.h now. Signed-off-by: Christian Limpach --- linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c index bbe0963942..05ca6a3ee7 100644 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/kernel/smpboot.c @@ -51,11 +51,6 @@ #include #include -#if 1 -#define Dprintk(args...) -#else -#include -#endif #include #include @@ -462,7 +457,7 @@ extern void local_setup_timer(void); /* * Activate a secondary processor. */ -static int __init start_secondary(void *unused) +static void __init start_secondary(void *unused) { /* * Dont put anything before smp_callin(), SMP