ia64/xen-unstable
changeset 1390:a06f35e2fccf
bitkeeper revision 1.891.1.25 (40a531dfFMvbTlnuYexvPVp5Q8CzFA)
Slight possibility of deadlock during domain creation is now fixed.
Slight possibility of deadlock during domain creation is now fixed.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Fri May 14 20:53:51 2004 +0000 (2004-05-14) |
parents | 25e4846d6d3d |
children | b0bfb2a6a6ca |
files | xen/common/dom0_ops.c |
line diff
1.1 --- a/xen/common/dom0_ops.c Fri May 14 19:22:06 2004 +0000 1.2 +++ b/xen/common/dom0_ops.c Fri May 14 20:53:51 2004 +0000 1.3 @@ -23,15 +23,6 @@ 1.4 1.5 extern unsigned int alloc_new_dom_mem(struct task_struct *, unsigned int); 1.6 1.7 -/* Basically used to protect the domain-id space. */ 1.8 -static spinlock_t create_dom_lock = SPIN_LOCK_UNLOCKED; 1.9 - 1.10 -static domid_t get_domnr(void) 1.11 -{ 1.12 - static domid_t domnr = 0; 1.13 - return ++domnr; 1.14 -} 1.15 - 1.16 static int msr_cpu_mask; 1.17 static unsigned long msr_addr; 1.18 static unsigned long msr_lo; 1.19 @@ -109,23 +100,24 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 1.20 case DOM0_CREATEDOMAIN: 1.21 { 1.22 struct task_struct *p; 1.23 - static unsigned int pro = 0; 1.24 + static domid_t domnr = 0; 1.25 + static spinlock_t domnr_lock = SPIN_LOCK_UNLOCKED; 1.26 + unsigned int pro; 1.27 domid_t dom; 1.28 ret = -ENOMEM; 1.29 1.30 - spin_lock_irq(&create_dom_lock); 1.31 - 1.32 - if ( (dom = get_domnr()) == 0 ) 1.33 - goto exit_create; 1.34 + spin_lock(&domnr_lock); 1.35 + dom = ++domnr; 1.36 + spin_unlock(&domnr_lock); 1.37 1.38 if (op->u.createdomain.cpu == -1 ) 1.39 - pro = (pro+1) % smp_num_cpus; 1.40 + pro = (unsigned int)dom % smp_num_cpus; 1.41 else 1.42 pro = op->u.createdomain.cpu % smp_num_cpus; 1.43 1.44 p = do_createdomain(dom, pro); 1.45 if ( p == NULL ) 1.46 - goto exit_create; 1.47 + break; 1.48 1.49 if ( op->u.createdomain.name[0] ) 1.50 { 1.51 @@ -137,16 +129,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 1.52 if ( ret != 0 ) 1.53 { 1.54 __kill_domain(p); 1.55 - goto exit_create; 1.56 + break; 1.57 } 1.58 1.59 ret = 0; 1.60 1.61 op->u.createdomain.domain = p->domain; 1.62 copy_to_user(u_dom0_op, op, sizeof(*op)); 1.63 - 1.64 - exit_create: 1.65 - spin_unlock_irq(&create_dom_lock); 1.66 } 1.67 break; 1.68