Author: np
Date: Mon Feb  3 23:25:12 2020
New Revision: 357475
URL: https://svnweb.freebsd.org/changeset/base/357475

Log:
  cxgbe(4): Initialize the rx buffer's metadata on first-use and not on
  allocation.
  
  refill_fl doesn't touch any part of a freshly allocated cluster after
  this change.
  
  MFC after:    1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/adapter.h
==============================================================================
--- head/sys/dev/cxgbe/adapter.h        Mon Feb  3 23:06:42 2020        
(r357474)
+++ head/sys/dev/cxgbe/adapter.h        Mon Feb  3 23:25:12 2020        
(r357475)
@@ -327,7 +327,6 @@ struct cluster_layout {
 
 struct cluster_metadata {
        u_int refcount;
-       struct fl_sdesc *sd;    /* For debug only.  Could easily be stale */
 };
 
 struct fl_sdesc {

Modified: head/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- head/sys/dev/cxgbe/t4_sge.c Mon Feb  3 23:06:42 2020        (r357474)
+++ head/sys/dev/cxgbe/t4_sge.c Mon Feb  3 23:25:12 2020        (r357475)
@@ -1872,11 +1872,12 @@ get_scatter_segment(struct adapter *sc, struct sge_fl 
                    fr_offset == 0 ? M_PKTHDR | M_NOFREE : M_NOFREE))
                        return (NULL);
                fl->mbuf_inlined++;
+               if (sd->nmbuf++ == 0) {
+                       clm->refcount = 1;
+                       counter_u64_add(extfree_refs, 1);
+               }
                m_extaddref(m, payload, blen, &clm->refcount, rxb_free,
                    swz->zone, sd->cl);
-               if (sd->nmbuf++ == 0)
-                       counter_u64_add(extfree_refs, 1);
-
        } else {
 
                /*
@@ -1890,10 +1891,12 @@ get_scatter_segment(struct adapter *sc, struct sge_fl 
                        return (NULL);
                fl->mbuf_allocated++;
                if (clm != NULL) {
+                       if (sd->nmbuf++ == 0) {
+                               clm->refcount = 1;
+                               counter_u64_add(extfree_refs, 1);
+                       }
                        m_extaddref(m, payload, blen, &clm->refcount,
                            rxb_free, swz->zone, sd->cl);
-                       if (sd->nmbuf++ == 0)
-                               counter_u64_add(extfree_refs, 1);
                } else {
                        m_cljset(m, sd->cl, swz->type);
                        sd->cl = NULL;  /* consumed, not a recycle candidate */
@@ -4401,7 +4404,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n
                                if (clm != NULL)
                                        MPASS(clm->refcount == 1);
 #endif
-                               goto recycled_fast;
+                               goto recycled;
                        }
 
                        /*
@@ -4440,16 +4443,8 @@ alloc:
                sd->cl = cl;
                sd->cll = *cll;
                *d = htobe64(pa | cll->hwidx);
-               clm = cl_metadata(sc, fl, cll, cl);
-               if (clm != NULL) {
 recycled:
-#ifdef INVARIANTS
-                       clm->sd = sd;
-#endif
-                       clm->refcount = 1;
-               }
                sd->nmbuf = 0;
-recycled_fast:
                d++;
                sd++;
                if (__predict_false(++fl->pidx % 8 == 0)) {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to