--- linux-2.6.16.13-xen/drivers/xen/netback/netback.c 2006-06-04 01:03:54.000000000 -0400 +++ new/drivers/xen/netback/netback.c 2006-06-04 23:05:21.000000000 -0400 @@ -100,6 +100,7 @@ static unsigned long mfn_list[MAX_MFN_ALLOC]; static unsigned int alloc_index = 0; static DEFINE_SPINLOCK(mfn_lock); +static DEFINE_SPINLOCK(_lock); static unsigned long alloc_mfn(void) { @@ -454,9 +455,19 @@ PEND_RING_IDX dc, dp; netif_t *netif; int ret; + unsigned long flags; dc = dealloc_cons; + + /* + * dealloc_prod is updated under the protection of the spin lock + * in the function netif_idx_release(). We need to see the updates to + * dealloc_prod in the order it is updated in netif_idx_release. To + * force this, snapshot dealloc_prod under the protection of the lock. + */ + spin_lock_irqsave(&_lock, flags); dp = dealloc_prod; + spin_unlock_irqrestore(&_lock, flags); /* * Free up any grants we have finished using @@ -691,7 +702,6 @@ static void netif_idx_release(u16 pending_idx) { - static DEFINE_SPINLOCK(_lock); unsigned long flags; spin_lock_irqsave(&_lock, flags);