--- linux-2.6.16.13-xen/drivers/xen/netback/netback.c 2006-06-04 22:10:17.000000000 -0400 +++ new/drivers/xen/netback/netback.c 2006-06-04 22:22:51.000000000 -0400 @@ -100,6 +100,7 @@ static unsigned long mfn_list[MAX_MFN_ALLOC]; static unsigned int alloc_index = 0; static spinlock_t mfn_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t _lock = SPIN_LOCK_UNLOCKED; static unsigned long alloc_mfn(void) { @@ -448,9 +449,18 @@ 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 @@ -685,7 +695,6 @@ static void netif_idx_release(u16 pending_idx) { - static spinlock_t _lock = SPIN_LOCK_UNLOCKED; unsigned long flags; spin_lock_irqsave(&_lock, flags);