[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Restrict netfront to 256 grant references to avoid



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 176302fe4dfb47bf5f4c74c26ea00e1a90726770
# Parent  b36a43b9d9b55cd8bae08b4b72dc369c5ab6862d
Restrict netfront to 256 grant references to avoid
exhausting the global pool.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff -r b36a43b9d9b5 -r 176302fe4dfb 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Fri Apr 14 
14:05:04 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Fri Apr 14 
14:05:28 2006
@@ -106,7 +106,7 @@
        /* Receive-ring batched refills. */
 #define RX_MIN_TARGET 8
 #define RX_DFL_MIN_TARGET 64
-#define RX_MAX_TARGET NET_RX_RING_SIZE
+#define RX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
        int rx_min_target, rx_max_target, rx_target;
        struct sk_buff_head rx_batch;
 
@@ -119,6 +119,7 @@
        struct sk_buff *tx_skbs[NET_TX_RING_SIZE+1];
        struct sk_buff *rx_skbs[NET_RX_RING_SIZE+1];
 
+#define TX_MAX_TARGET min_t(int, NET_RX_RING_SIZE, 256)
        grant_ref_t gref_tx_head;
        grant_ref_t grant_tx_ref[NET_TX_RING_SIZE + 1];
        grant_ref_t gref_rx_head;
@@ -505,8 +506,9 @@
        } while (prod != np->tx.sring->rsp_prod);
 
  out:
-       if (np->tx_full &&
-           ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE)) {
+       if ((np->tx_full) &&
+           ((np->tx.sring->req_prod - prod) < NET_TX_RING_SIZE) &&
+           !gnttab_empty_grant_references(&np->gref_tx_head)) {
                np->tx_full = 0;
                if (np->user_state == UST_OPEN)
                        netif_wake_queue(dev);
@@ -705,7 +707,8 @@
 
        network_tx_buf_gc(dev);
 
-       if (RING_FULL(&np->tx)) {
+       if (RING_FULL(&np->tx) ||
+           gnttab_empty_grant_references(&np->gref_tx_head)) {
                np->tx_full = 1;
                netif_stop_queue(dev);
        }
@@ -1140,14 +1143,14 @@
        }
 
        /* A grant for every tx ring slot */
-       if (gnttab_alloc_grant_references(NET_TX_RING_SIZE,
+       if (gnttab_alloc_grant_references(TX_MAX_TARGET,
                                          &np->gref_tx_head) < 0) {
                printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
                err = -ENOMEM;
                goto exit;
        }
        /* A grant for every rx ring slot */
-       if (gnttab_alloc_grant_references(NET_RX_RING_SIZE,
+       if (gnttab_alloc_grant_references(RX_MAX_TARGET,
                                          &np->gref_rx_head) < 0) {
                printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
                gnttab_free_grant_references(np->gref_tx_head);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.