From a47d6cdb07709c941993e334f9bd82b3aec11dac Mon Sep 17 00:00:00 2001 From: Boris Ostrovsky Date: Wed, 18 Mar 2015 14:19:01 +0100 Subject: [PATCH 1/4] x86/VPMU: VPMU should not exist when vpmu_initialise() is called We don't need to try to destroy it since it can't be already allocated at the time we try to initialize it. Suggested-by: Andrew Cooper Signed-off-by: Boris Ostrovsky --- xen/arch/x86/hvm/svm/vpmu.c | 3 --- xen/arch/x86/hvm/vpmu.c | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/xen/arch/x86/hvm/svm/vpmu.c b/xen/arch/x86/hvm/svm/vpmu.c index 64dc1678f1..6764070ddb 100644 --- a/xen/arch/x86/hvm/svm/vpmu.c +++ b/xen/arch/x86/hvm/svm/vpmu.c @@ -359,9 +359,6 @@ static int amd_vpmu_initialise(struct vcpu *v) struct vpmu_struct *vpmu = vcpu_vpmu(v); uint8_t family = current_cpu_data.x86; - if ( vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) ) - return 0; - if ( counters == NULL ) { switch ( family ) diff --git a/xen/arch/x86/hvm/vpmu.c b/xen/arch/x86/hvm/vpmu.c index 0e6b6c022b..c3273ee64b 100644 --- a/xen/arch/x86/hvm/vpmu.c +++ b/xen/arch/x86/hvm/vpmu.c @@ -236,10 +236,7 @@ void vpmu_initialise(struct vcpu *v) if ( is_pvh_vcpu(v) ) return; - if ( vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) ) - vpmu_destroy(v); - vpmu_clear(vpmu); - vpmu->context = NULL; + ASSERT(!vpmu->flags && !vpmu->context); switch ( vendor ) { From a90babbd23dc3a75f8b5c59541f963ed6a07d2c2 Mon Sep 17 00:00:00 2001 From: Dario Faggioli Date: Wed, 18 Mar 2015 14:20:01 +0100 Subject: [PATCH 2/4] sched_rt: avoid ASSERT()ing on runq dump if there are no domains being serviced by the RTDS scheduler, as that is a legit situation to be in: think, for instance, of a newly created RTDS cpupool, with no domains migrated to it yet. While there: - move the spinlock acquisition up, to effectively protect the domain list and avoid races; - the mask of online pCPUs was being retrieved but then not used anywhere in the function: get rid of that. Signed-off-by: Dario Faggioli Reviewed-by: Meng Xu Acked-by: George Dunlap --- xen/common/sched_rt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index ffc5107e85..2b0b7c6f8a 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -264,18 +264,17 @@ rt_dump(const struct scheduler *ops) struct list_head *iter_sdom, *iter_svc, *runq, *depletedq, *iter; struct rt_private *prv = rt_priv(ops); struct rt_vcpu *svc; - cpumask_t *online; struct rt_dom *sdom; unsigned long flags; - ASSERT(!list_empty(&prv->sdom)); + spin_lock_irqsave(&prv->lock, flags); + + if ( list_empty(&prv->sdom) ) + goto out; - sdom = list_entry(prv->sdom.next, struct rt_dom, sdom_elem); - online = cpupool_scheduler_cpumask(sdom->dom->cpupool); runq = rt_runq(ops); depletedq = rt_depletedq(ops); - spin_lock_irqsave(&prv->lock, flags); printk("Global RunQueue info:\n"); list_for_each( iter, runq ) { @@ -303,6 +302,7 @@ rt_dump(const struct scheduler *ops) } } + out: spin_unlock_irqrestore(&prv->lock, flags); } From ec61696dc648bf71aaa7e0673862fb3a30b4a8ad Mon Sep 17 00:00:00 2001 From: Dario Faggioli Date: Wed, 18 Mar 2015 14:20:37 +0100 Subject: [PATCH 3/4] print online pCPUs and free pCPUs when dumping e.g., with `xl debug-key r', like this: (XEN) Online Cpus: 0-15 (XEN) Free Cpus: 8-15 Also, for each cpupool, print the set of pCPUs it contains, like this: (XEN) Cpupool 0: (XEN) Cpus: 0-7 (XEN) Scheduler: SMP Credit Scheduler (credit) Signed-off-by: Dario Faggioli Acked-by: Juergen Gross cpumask_weight() -> !cpumask_empty() Signed-off-by: Jan Beulich --- xen/common/cpupool.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index cd6aab9661..a947c245f0 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #define for_each_cpupool(ptr) \ @@ -658,6 +659,12 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) return ret; } +static void print_cpumap(const char *str, const cpumask_t *map) +{ + cpulist_scnprintf(keyhandler_scratch, sizeof(keyhandler_scratch), map); + printk("%s: %s\n", str, keyhandler_scratch); +} + void dump_runq(unsigned char key) { unsigned long flags; @@ -671,12 +678,17 @@ void dump_runq(unsigned char key) sched_smt_power_savings? "enabled":"disabled"); printk("NOW=0x%08X%08X\n", (u32)(now>>32), (u32)now); + print_cpumap("Online Cpus", &cpu_online_map); + if ( !cpumask_empty(&cpupool_free_cpus) ) + print_cpumap("Free Cpus", &cpupool_free_cpus); + printk("Idle cpupool:\n"); schedule_dump(NULL); for_each_cpupool(c) { printk("Cpupool %d:\n", (*c)->cpupool_id); + print_cpumap("Cpus", (*c)->cpu_valid); schedule_dump(*c); } From 1b8884fdff064730e88cea04726e23964684c6d7 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 18 Mar 2015 14:21:40 +0100 Subject: [PATCH 4/4] x86/shadow: pass domain to sh_install_xen_entries_in_lN() Most callers have this available already, and the functions don't need any vcpu specifics. Signed-off-by: Jan Beulich Reviewed-by: Tim Deegan --- xen/arch/x86/mm/shadow/multi.c | 22 +++++++++++----------- xen/arch/x86/mm/shadow/private.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 16cd60d466..c82aa96682 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -1414,9 +1414,8 @@ do { \ // shadow-types.h to shadow-private.h // #if GUEST_PAGING_LEVELS == 4 -void sh_install_xen_entries_in_l4(struct vcpu *v, mfn_t gl4mfn, mfn_t sl4mfn) +void sh_install_xen_entries_in_l4(struct domain *d, mfn_t gl4mfn, mfn_t sl4mfn) { - struct domain *d = v->domain; shadow_l4e_t *sl4e; unsigned int slots; @@ -1444,7 +1443,7 @@ void sh_install_xen_entries_in_l4(struct vcpu *v, mfn_t gl4mfn, mfn_t sl4mfn) shadow_l4e_from_mfn(sl4mfn, __PAGE_HYPERVISOR); /* Self linear mapping. */ - if ( shadow_mode_translate(v->domain) && !shadow_mode_external(v->domain) ) + if ( shadow_mode_translate(d) && !shadow_mode_external(d) ) { // linear tables may not be used with translated PV guests sl4e[shadow_l4_table_offset(LINEAR_PT_VIRT_START)] = @@ -1465,12 +1464,11 @@ void sh_install_xen_entries_in_l4(struct vcpu *v, mfn_t gl4mfn, mfn_t sl4mfn) // place, which means that we need to populate the l2h entry in the l3 // table. -static void sh_install_xen_entries_in_l2h(struct vcpu *v, mfn_t sl2hmfn) +static void sh_install_xen_entries_in_l2h(struct domain *d, mfn_t sl2hmfn) { - struct domain *d = v->domain; shadow_l2e_t *sl2e; - if ( !is_pv_32on64_vcpu(v) ) + if ( !is_pv_32on64_domain(d) ) return; sl2e = sh_map_domain_page(sl2hmfn); @@ -1545,11 +1543,13 @@ sh_make_shadow(struct vcpu *v, mfn_t gmfn, u32 shadow_type) { #if GUEST_PAGING_LEVELS == 4 case SH_type_l4_shadow: - sh_install_xen_entries_in_l4(v, gmfn, smfn); break; + sh_install_xen_entries_in_l4(v->domain, gmfn, smfn); + break; #endif #if GUEST_PAGING_LEVELS >= 3 case SH_type_l2h_shadow: - sh_install_xen_entries_in_l2h(v, smfn); break; + sh_install_xen_entries_in_l2h(v->domain, smfn); + break; #endif default: /* Do nothing */ break; } @@ -1589,7 +1589,7 @@ sh_make_monitor_table(struct vcpu *v) { mfn_t m4mfn; m4mfn = shadow_alloc(d, SH_type_monitor_table, 0); - sh_install_xen_entries_in_l4(v, m4mfn, m4mfn); + sh_install_xen_entries_in_l4(d, m4mfn, m4mfn); /* Remember the level of this table */ mfn_to_page(m4mfn)->shadow_flags = 4; #if SHADOW_PAGING_LEVELS < 4 @@ -1613,7 +1613,7 @@ sh_make_monitor_table(struct vcpu *v) l3e[0] = l3e_from_pfn(mfn_x(m2mfn), __PAGE_HYPERVISOR); sh_unmap_domain_page(l3e); - if ( is_pv_32on64_vcpu(v) ) + if ( is_pv_32on64_domain(d) ) { /* For 32-on-64 PV guests, we need to map the 32-bit Xen * area into its usual VAs in the monitor tables */ @@ -1625,7 +1625,7 @@ sh_make_monitor_table(struct vcpu *v) mfn_to_page(m2mfn)->shadow_flags = 2; l3e = sh_map_domain_page(m3mfn); l3e[3] = l3e_from_pfn(mfn_x(m2mfn), _PAGE_PRESENT); - sh_install_xen_entries_in_l2h(v, m2mfn); + sh_install_xen_entries_in_l2h(d, m2mfn); sh_unmap_domain_page(l3e); } diff --git a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h index 1bf1deb087..64dd2baebb 100644 --- a/xen/arch/x86/mm/shadow/private.h +++ b/xen/arch/x86/mm/shadow/private.h @@ -361,7 +361,7 @@ mfn_t shadow_alloc(struct domain *d, void shadow_free(struct domain *d, mfn_t smfn); /* Install the xen mappings in various flavours of shadow */ -void sh_install_xen_entries_in_l4(struct vcpu *v, mfn_t gl4mfn, mfn_t sl4mfn); +void sh_install_xen_entries_in_l4(struct domain *, mfn_t gl4mfn, mfn_t sl4mfn); /* Update the shadows in response to a pagetable write from Xen */ int sh_validate_guest_entry(struct vcpu *v, mfn_t gmfn, void *entry, u32 size);