bge and jumbo allocation diff

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

bge and jumbo allocation diff

Michael Shalayeff-2
re
currently bge(4) allocates 3.5M (~0.7%) of kernel memory per interface
that is never used unless jumbo frames are configured.
you can do the math to see that this is a horrible waste.
and that is in addition to normal mbuf clusters allocated for
normal frames (that is another 512k or so).
here is the diff that only allocates those huge buffers for jumbos
once the mtu has been raised high enough.
please test esp if you are using jumbo frames.
cu
--
    paranoic mickey       (my employers have changed but, the name has remained)

Index: if_bge.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_bge.c,v
retrieving revision 1.180
diff -u -r1.180 if_bge.c
--- if_bge.c 17 Sep 2006 23:31:07 -0000 1.180
+++ if_bge.c 18 Sep 2006 13:42:36 -0000
@@ -581,6 +581,10 @@
  int i, rseg, state, error;
  struct bge_jpool_entry   *entry;
 
+ /* see if already allocated */
+ if (sc->bge_cdata.bge_jumbo_buf)
+ return (0);
+
  state = error = 0;
 
  /* Grab a big chunk o' storage. */
@@ -659,6 +663,7 @@
  default:
  break;
  }
+ sc->bge_cdata.bge_jumbo_buf = NULL;
  }
 
  return (error);
@@ -1868,16 +1873,6 @@
 
  bzero(sc->bge_rdata, sizeof(struct bge_ring_data));
 
- /*
- * Try to allocate memory for Jumbo buffers.
- */
- if (BGE_IS_JUMBO_CAPABLE(sc)) {
- if (bge_alloc_jumbo_mem(sc)) {
- printf(": jumbo buffer allocation failed\n");
- goto fail_5;
- }
- }
-
  /* Set default tuneable values. */
  sc->bge_stat_ticks = BGE_TICKS_PER_SEC;
  sc->bge_rx_coal_ticks = 150;
@@ -2825,6 +2820,17 @@
  bge_stop(sc);
  bge_reset(sc);
  bge_chipinit(sc);
+
+ /*
+ * Try to allocate memory for Jumbo buffers.
+ */
+ if (ifp->if_mtu > ETHERMTU && BGE_IS_JUMBO_CAPABLE(sc) &&
+    bge_alloc_jumbo_mem(sc)) {
+ printf("%s: jumbo buffer allocation failed\n",
+    sc->bge_dev.dv_xname);
+ splx(s);
+ return;
+ }
 
  /*
  * Init the various state machines, ring