ia64/xen-unstable

changeset 10828:4782114d0713

[NET] back: Make use of the simplicity of tasklets in net_rx_action

Tasklets have the property that each one is running on only one CPU at
any time. This means that you don't have to worry about the tasklet
racing against itself. Therefore any resources used by just a single
tasklet does not need to be guarded by locks.

Since net_rx_action is the only user of alloc_mfn, we can remove the
mfn_lock that guard it.

The notify_list array is huge by Linux standards so placing it on the
stack is unsafe. Since net_rx_action is not re-entrant, we can simply
make it static.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
author kfraser@localhost.localdomain
date Thu Jul 27 13:34:09 2006 +0100 (2006-07-27)
parents 3c95a8ed22d0
children b40cb6db44e4
files linux-2.6-xen-sparse/drivers/xen/netback/netback.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Jul 27 13:32:29 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Jul 27 13:34:09 2006 +0100
     1.3 @@ -99,24 +99,21 @@ static spinlock_t net_schedule_list_lock
     1.4  #define MAX_MFN_ALLOC 64
     1.5  static unsigned long mfn_list[MAX_MFN_ALLOC];
     1.6  static unsigned int alloc_index = 0;
     1.7 -static DEFINE_SPINLOCK(mfn_lock);
     1.8  
     1.9  static unsigned long alloc_mfn(void)
    1.10  {
    1.11 -	unsigned long mfn = 0, flags;
    1.12 +	unsigned long mfn = 0;
    1.13  	struct xen_memory_reservation reservation = {
    1.14  		.nr_extents   = MAX_MFN_ALLOC,
    1.15  		.extent_order = 0,
    1.16  		.domid        = DOMID_SELF
    1.17  	};
    1.18  	set_xen_guest_handle(reservation.extent_start, mfn_list);
    1.19 -	spin_lock_irqsave(&mfn_lock, flags);
    1.20  	if ( unlikely(alloc_index == 0) )
    1.21  		alloc_index = HYPERVISOR_memory_op(
    1.22  			XENMEM_increase_reservation, &reservation);
    1.23  	if ( alloc_index != 0 )
    1.24  		mfn = mfn_list[--alloc_index];
    1.25 -	spin_unlock_irqrestore(&mfn_lock, flags);
    1.26  	return mfn;
    1.27  }
    1.28  
    1.29 @@ -222,9 +219,13 @@ static void net_rx_action(unsigned long 
    1.30  	unsigned long vdata, old_mfn, new_mfn;
    1.31  	struct sk_buff_head rxq;
    1.32  	struct sk_buff *skb;
    1.33 -	u16 notify_list[NET_RX_RING_SIZE];
    1.34  	int notify_nr = 0;
    1.35  	int ret;
    1.36 +	/*
    1.37 +	 * Putting hundreds of bytes on the stack is considered rude.
    1.38 +	 * Static works because a tasklet can only be on one CPU at any time.
    1.39 +	 */
    1.40 +	static u16 notify_list[NET_RX_RING_SIZE];
    1.41  
    1.42  	skb_queue_head_init(&rxq);
    1.43