From: kaf24@scramble.cl.cam.ac.uk Date: Fri, 14 May 2004 20:53:51 +0000 (+0000) Subject: bitkeeper revision 1.891.1.25 (40a531dfFMvbTlnuYexvPVp5Q8CzFA) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~18211^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e34c52ae9aebdb63c9e438ee71c29bc63f877274;p=xen.git bitkeeper revision 1.891.1.25 (40a531dfFMvbTlnuYexvPVp5Q8CzFA) Slight possibility of deadlock during domain creation is now fixed. --- diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index 9370a61a8d..5956581018 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -23,15 +23,6 @@ extern unsigned int alloc_new_dom_mem(struct task_struct *, unsigned int); -/* Basically used to protect the domain-id space. */ -static spinlock_t create_dom_lock = SPIN_LOCK_UNLOCKED; - -static domid_t get_domnr(void) -{ - static domid_t domnr = 0; - return ++domnr; -} - static int msr_cpu_mask; static unsigned long msr_addr; static unsigned long msr_lo; @@ -109,23 +100,24 @@ long do_dom0_op(dom0_op_t *u_dom0_op) case DOM0_CREATEDOMAIN: { struct task_struct *p; - static unsigned int pro = 0; + static domid_t domnr = 0; + static spinlock_t domnr_lock = SPIN_LOCK_UNLOCKED; + unsigned int pro; domid_t dom; ret = -ENOMEM; - spin_lock_irq(&create_dom_lock); - - if ( (dom = get_domnr()) == 0 ) - goto exit_create; + spin_lock(&domnr_lock); + dom = ++domnr; + spin_unlock(&domnr_lock); if (op->u.createdomain.cpu == -1 ) - pro = (pro+1) % smp_num_cpus; + pro = (unsigned int)dom % smp_num_cpus; else pro = op->u.createdomain.cpu % smp_num_cpus; p = do_createdomain(dom, pro); if ( p == NULL ) - goto exit_create; + break; if ( op->u.createdomain.name[0] ) { @@ -137,16 +129,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op) if ( ret != 0 ) { __kill_domain(p); - goto exit_create; + break; } ret = 0; op->u.createdomain.domain = p->domain; copy_to_user(u_dom0_op, op, sizeof(*op)); - - exit_create: - spin_unlock_irq(&create_dom_lock); } break;