direct-io.hg

changeset 9655:176302fe4dfb

Restrict netfront to 256 grant references to avoid
exhausting the global pool.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author kaf24@firebug.cl.cam.ac.uk
date Fri Apr 14 15:05:28 2006 +0100 (2006-04-14)
parents b36a43b9d9b5
children 4b168245977a
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Apr 14 15:05:04 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Apr 14 15:05:28 2006 +0100
     1.3 @@ -106,7 +106,7 @@ struct netfront_info
     1.4  	/* Receive-ring batched refills. */
     1.5  #define RX_MIN_TARGET 8
     1.6  #define RX_DFL_MIN_TARGET 64
     1.7 -#define RX_MAX_TARGET NET_RX_RING_SIZE
     1.8 +#define RX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
     1.9  	int rx_min_target, rx_max_target, rx_target;
    1.10  	struct sk_buff_head rx_batch;
    1.11  
    1.12 @@ -119,6 +119,7 @@ struct netfront_info
    1.13  	struct sk_buff *tx_skbs[NET_TX_RING_SIZE+1];
    1.14  	struct sk_buff *rx_skbs[NET_RX_RING_SIZE+1];
    1.15  
    1.16 +#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
    1.17  	grant_ref_t gref_tx_head;
    1.18  	grant_ref_t grant_tx_ref[NET_TX_RING_SIZE + 1];
    1.19  	grant_ref_t gref_rx_head;
    1.20 @@ -505,8 +506,9 @@ static void network_tx_buf_gc(struct net
    1.21  	} while (prod != np->tx.sring->rsp_prod);
    1.22  
    1.23   out:
    1.24 -	if (np->tx_full &&
    1.25 -	    ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE)) {
    1.26 +	if ((np->tx_full) &&
    1.27 +	    ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE) &&
    1.28 +	    !gnttab_empty_grant_references(&np->gref_tx_head)) {
    1.29  		np->tx_full = 0;
    1.30  		if (np->user_state == UST_OPEN)
    1.31  			netif_wake_queue(dev);
    1.32 @@ -705,7 +707,8 @@ static int network_start_xmit(struct sk_
    1.33  
    1.34  	network_tx_buf_gc(dev);
    1.35  
    1.36 -	if (RING_FULL(&np->tx)) {
    1.37 +	if (RING_FULL(&np->tx) ||
    1.38 +	    gnttab_empty_grant_references(&np->gref_tx_head)) {
    1.39  		np->tx_full = 1;
    1.40  		netif_stop_queue(dev);
    1.41  	}
    1.42 @@ -1140,14 +1143,14 @@ static int create_netdev(int handle, str
    1.43  	}
    1.44  
    1.45  	/* A grant for every tx ring slot */
    1.46 -	if (gnttab_alloc_grant_references(NET_TX_RING_SIZE,
    1.47 +	if (gnttab_alloc_grant_references(TX_MAX_TARGET,
    1.48  					  &np->gref_tx_head) < 0) {
    1.49  		printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
    1.50  		err = -ENOMEM;
    1.51  		goto exit;
    1.52  	}
    1.53  	/* A grant for every rx ring slot */
    1.54 -	if (gnttab_alloc_grant_references(NET_RX_RING_SIZE,
    1.55 +	if (gnttab_alloc_grant_references(RX_MAX_TARGET,
    1.56  					  &np->gref_rx_head) < 0) {
    1.57  		printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
    1.58  		gnttab_free_grant_references(np->gref_tx_head);