diff -r 9a6458e0c3f5 xen/common/cpupool.c --- a/xen/common/cpupool.c Tue Feb 01 19:26:36 2011 +0000 +++ b/xen/common/cpupool.c Thu Feb 03 18:51:40 2011 +0100 @@ -30,6 +30,7 @@ static int cpupool_moving_cpu = -1; static struct cpupool *cpupool_cpu_moving = NULL; static cpumask_t cpupool_locked_cpus = CPU_MASK_NONE; +static int cpupool_debug_move_continue = 0; static DEFINE_SPINLOCK(cpupool_lock); @@ -226,6 +227,8 @@ cpupool_id, cpu, ret); spin_lock(&cpupool_lock); + BUG_ON(!cpupool_debug_move_continue); // Continuation still flagged? + BUG_ON(cpu != *((volatile int*)&cpupool_moving_cpu)); ret = cpu_disable_scheduler(cpu); cpu_set(cpu, cpupool_free_cpus); if ( !ret ) @@ -236,6 +239,7 @@ cpupool_put(cpupool_cpu_moving); cpupool_cpu_moving = NULL; } + cpupool_debug_move_continue = 0; // Continuation done. spin_unlock(&cpupool_lock); return ret; } @@ -300,6 +304,8 @@ atomic_inc(&c->refcnt); cpupool_cpu_moving = c; cpu_clear(cpu, c->cpu_valid); + BUG_ON(cpupool_debug_move_continue); // Only one outstanding continuation! + cpupool_debug_move_continue = 1; spin_unlock(&cpupool_lock); work_cpu = smp_processor_id(); @@ -309,6 +315,7 @@ if ( work_cpu == cpu ) work_cpu = next_cpu(cpu, cpupool0->cpu_valid); } + // SD NOTE: Why not keep the protection through cpupool_lock until here? return continue_hypercall_on_cpu(work_cpu, cpupool_unassign_cpu_helper, c); out: diff -r 9a6458e0c3f5 xen/common/sched_credit.c --- a/xen/common/sched_credit.c Tue Feb 01 19:26:36 2011 +0000 +++ b/xen/common/sched_credit.c Thu Feb 03 18:51:40 2011 +0100 @@ -567,6 +567,14 @@ list_add(&svc->active_vcpu_elem, &sdom->active_vcpu); /* Make weight per-vcpu */ prv->weight += sdom->weight; + if (prv->weight < sdom->active_vcpu_count * sdom->weight) { + printk("%s, %i: Dom: %i VCPU: %i prv: %p &prv->lock: %p prv->weight: %i "\ + "sdom->active_vcpu_count: %i sdom->weight: %i\n", + __FILE__, __LINE__, sdom->dom->domain_id, svc->vcpu->vcpu_id, + (void*) prv, &(prv->lock), prv->weight, + sdom->active_vcpu_count, sdom->weight); + } + //BUG_ON(prv->weight < sdom->active_vcpu_count * sdom->weight); if ( list_empty(&sdom->active_sdom_elem) ) { list_add(&sdom->active_sdom_elem, &prv->active_sdom); @@ -591,6 +599,14 @@ sdom->active_vcpu_count--; list_del_init(&svc->active_vcpu_elem); prv->weight -= sdom->weight; + if (prv->weight < sdom->active_vcpu_count * sdom->weight) { + printk("%s, %i: Dom: %i VCPU: %i prv: %p &prv->lock: %p prv->weight: %i "\ + "sdom->active_vcpu_count: %i sdom->weight: %i\n", + __FILE__, __LINE__, sdom->dom->domain_id, svc->vcpu->vcpu_id, + (void*) prv, &(prv->lock), prv->weight, + sdom->active_vcpu_count, sdom->weight); + } + //BUG_ON(prv->weight < sdom->active_vcpu_count * sdom->weight); if ( list_empty(&sdom->active_vcpu) ) { list_del_init(&sdom->active_sdom_elem); @@ -987,6 +1003,17 @@ BUG_ON( is_idle_domain(sdom->dom) ); BUG_ON( sdom->active_vcpu_count == 0 ); BUG_ON( sdom->weight == 0 ); + if ( (sdom->weight * sdom->active_vcpu_count) > weight_left ) { + struct domain *d = sdom->dom; + struct vcpu *v; + for_each_vcpu ( d, v ) { + printk("BUG in %s,%i: Domain %i VCPU: %i on processor: %i with "\ + "state %i violates invariant!\n", + __FILE__,__LINE__, d->domain_id, v->vcpu_id, v->processor, + v->runstate.state); + } + } + BUG_ON( (sdom->weight * sdom->active_vcpu_count) > weight_left ); weight_left -= ( sdom->weight * sdom->active_vcpu_count );