I noticed a bunch of routines use MFREE() instead of m_free() (which 
    just calls MFREE()).  MFREE() is a huge macro.

text    data     bss     dec     hex filename
1986399  252380  145840 2384619  2462eb kernel

text    data     bss     dec     hex filename
1983343  252380  145840 2381563  2456fb kernel

    We save about 3K.  Any problems with this?  Maybe also MFC to -stable
    to save some bytes?

    (The #if 0's wouldn't be in a commit, I'd actually delete the code)

    Also, if you do a search for XXX, I think there was an MFREE in there
    that should have been an m_freem().  Could someone check that?

    The patch is against -stable.

                                        -Matt
                                        Matthew Dillon 
                                        <[EMAIL PROTECTED]>


Index: kern/uipc_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.68.2.17
diff -u -r1.68.2.17 uipc_socket.c
--- kern/uipc_socket.c  1 Dec 2001 21:32:42 -0000       1.68.2.17
+++ kern/uipc_socket.c  2 Jan 2002 06:01:40 -0000
@@ -782,7 +782,10 @@
                        m = m->m_next;
                } else {
                        sbfree(&so->so_rcv, m);
+                       so->so_rcv.sb_mb = m_free(m);
+#if 0
                        MFREE(m, so->so_rcv.sb_mb);
+#endif
                        m = so->so_rcv.sb_mb;
                }
        }
@@ -803,7 +806,10 @@
                                m->m_next = 0;
                                m = so->so_rcv.sb_mb;
                        } else {
+#if 0
                                MFREE(m, so->so_rcv.sb_mb);
+#endif
+                               so->so_rcv.sb_mb = m_free(m);
                                m = so->so_rcv.sb_mb;
                        }
                }
@@ -867,8 +873,13 @@
                                        so->so_rcv.sb_mb = m = m->m_next;
                                        *mp = (struct mbuf *)0;
                                } else {
+#if 0
                                        MFREE(m, so->so_rcv.sb_mb);
+#endif
+                                       so->so_rcv.sb_mb = m = m_free(m);
+#if 0
                                        m = so->so_rcv.sb_mb;
+#endif
                                }
                                if (m)
                                        m->m_nextpkt = nextrecord;
Index: kern/uipc_socket2.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/uipc_socket2.c,v
retrieving revision 1.55.2.10
diff -u -r1.55.2.10 uipc_socket2.c
--- kern/uipc_socket2.c 27 Dec 2001 18:36:10 -0000      1.55.2.10
+++ kern/uipc_socket2.c 2 Jan 2002 06:10:20 -0000
@@ -782,7 +782,7 @@
        register struct sockbuf *sb;
        register int len;
 {
-       register struct mbuf *m, *mn;
+       register struct mbuf *m;
        struct mbuf *next;
 
        next = (m = sb->sb_mb) ? m->m_nextpkt : 0;
@@ -802,13 +802,19 @@
                }
                len -= m->m_len;
                sbfree(sb, m);
+#if 0
                MFREE(m, mn);
                m = mn;
+#endif
+               m = m_free(m);
        }
        while (m && m->m_len == 0) {
                sbfree(sb, m);
+#if 0
                MFREE(m, mn);
                m = mn;
+#endif
+               m = m_free(m);
        }
        if (m) {
                sb->sb_mb = m;
@@ -825,15 +831,18 @@
 sbdroprecord(sb)
        register struct sockbuf *sb;
 {
-       register struct mbuf *m, *mn;
+       register struct mbuf *m;
 
        m = sb->sb_mb;
        if (m) {
                sb->sb_mb = m->m_nextpkt;
                do {
                        sbfree(sb, m);
+#if 0
                        MFREE(m, mn);
                        m = mn;
+#endif
+                       m = m_free(m);
                } while (m);
        }
 }
Index: net/if_ppp.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_ppp.c,v
retrieving revision 1.67.2.1
diff -u -r1.67.2.1 if_ppp.c
--- net/if_ppp.c        11 Sep 2001 09:49:54 -0000      1.67.2.1
+++ net/if_ppp.c        2 Jan 2002 06:03:07 -0000
@@ -1381,9 +1381,13 @@
        if (m->m_len <= M_TRAILINGSPACE(mp)) {
            bcopy(mtod(m, u_char *), mtod(mp, u_char *) + mp->m_len, m->m_len);
            mp->m_len += m->m_len;
+#if 0
            MFREE(m, mp->m_next);
-       } else
+#endif
+           mp->m_next = m_free(m);
+       } else {
            mp->m_next = m;
+       }
        m = mp;
        ilen += hlen - xlen;
 
Index: net/if_sl.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_sl.c,v
retrieving revision 1.84.2.1
diff -u -r1.84.2.1 if_sl.c
--- net/if_sl.c 26 Dec 2000 02:22:57 -0000      1.84.2.1
+++ net/if_sl.c 2 Jan 2002 06:10:31 -0000
@@ -548,7 +548,6 @@
        register u_char *cp;
        register struct ip *ip;
        int s;
-       struct mbuf *m2;
        u_char bpfbuf[SLTMAX + SLIP_HDRLEN];
        register int len = 0;
 
@@ -702,8 +701,11 @@
                                        sc->sc_if.if_obytes += 2;
                                }
                        }
+#if 0
                        MFREE(m, m2);
                        m = m2;
+#endif
+                       m = m_free(m);
                }
 
                if (putc(FRAME_END, &tp->t_outq)) {
Index: net/if_tap.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_tap.c,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 if_tap.c
--- net/if_tap.c        27 Jul 2000 13:57:05 -0000      1.3.2.1
+++ net/if_tap.c        2 Jan 2002 06:10:57 -0000
@@ -642,7 +642,7 @@
 {
        struct tap_softc        *tp = dev->si_drv1;
        struct ifnet            *ifp = &tp->tap_if;
-       struct mbuf             *m = NULL, *m0 = NULL;
+       struct mbuf             *m0 = NULL;
        int                      error = 0, len, s;
 
        TAPDEBUG("%s%d reading, minor = %#x\n",
@@ -686,8 +686,11 @@
                        break;
 
                error = uiomove(mtod(m0, caddr_t), len, uio);
+#if 0
                MFREE(m0, m);
                m0 = m;
+#endif
+               m0 = m_free(m0);
        }
 
        if (m0 != NULL) {
Index: net/if_tun.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_tun.c,v
retrieving revision 1.74.2.7
diff -u -r1.74.2.7 if_tun.c
--- net/if_tun.c        25 Nov 2001 08:48:15 -0000      1.74.2.7
+++ net/if_tun.c        2 Jan 2002 06:11:09 -0000
@@ -538,7 +538,7 @@
 {
        struct tun_softc *tp = dev->si_drv1;
        struct ifnet    *ifp = &tp->tun_if;
-       struct mbuf     *m, *m0;
+       struct mbuf     *m0;
        int             error=0, len, s;
 
        TUNDEBUG ("%s%d: read\n", ifp->if_name, ifp->if_unit);
@@ -572,8 +572,11 @@
                len = min(uio->uio_resid, m0->m_len);
                if (len != 0)
                        error = uiomove(mtod(m0, caddr_t), len, uio);
+#if 0
                MFREE(m0, m);
                m0 = m;
+#endif
+               m0 = m_free(m0);
        }
 
        if (m0) {
Index: net/ppp_tty.c
===================================================================
RCS file: /home/ncvs/src/sys/net/ppp_tty.c,v
retrieving revision 1.43
diff -u -r1.43 ppp_tty.c
--- net/ppp_tty.c       29 Jan 2000 16:56:24 -0000      1.43
+++ net/ppp_tty.c       2 Jan 2002 06:11:16 -0000
@@ -574,7 +574,6 @@
     register int len;
     register u_char *start, *stop, *cp;
     int n, ndone, done, idle;
-    struct mbuf *m2;
     int s;
 
     idle = 0;
@@ -712,8 +711,11 @@
            }
 
            /* Finished with this mbuf; free it and move on. */
+#if 0
            MFREE(m, m2);
            m = m2;
+#endif
+           m = m_free(m);
            if (m == NULL) {
                /* Finished a packet */
                break;
Index: netgraph/ng_async.c
===================================================================
RCS file: /home/ncvs/src/sys/netgraph/ng_async.c,v
retrieving revision 1.6.2.3
diff -u -r1.6.2.3 ng_async.c
--- netgraph/ng_async.c 24 Oct 2000 18:36:44 -0000      1.6.2.3
+++ netgraph/ng_async.c 2 Jan 2002 06:11:36 -0000
@@ -452,15 +452,16 @@
 
        /* Add packet payload */
        while (m != NULL) {
-               struct mbuf *n;
-
                while (m->m_len > 0) {
                        ADD_BYTE(*mtod(m, u_char *));
                        m->m_data++;
                        m->m_len--;
                }
+#if 0
                MFREE(m, n);
                m = n;
+#endif
+               m = m_free(m);
        }
 
        /* Add checksum and final sync flag */
@@ -567,8 +568,11 @@
                                sc->fcs = PPP_FCS(sc->fcs, ch);
                        }
                }
+#if 0
                MFREE(m, n);
                m = n;
+#endif
+               m = m_free(m);
        }
        return (0);
 }
Index: netgraph/ng_tty.c
===================================================================
RCS file: /home/ncvs/src/sys/netgraph/ng_tty.c,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 ng_tty.c
--- netgraph/ng_tty.c   24 Oct 2000 18:36:46 -0000      1.7.2.2
+++ netgraph/ng_tty.c   2 Jan 2002 06:11:43 -0000
@@ -429,7 +429,6 @@
 
                /* Send as much of it as possible */
                while (m) {
-                       struct mbuf *m2;
                        int     sent;
 
                        sent = m->m_len
@@ -438,8 +437,11 @@
                        m->m_len -= sent;
                        if (m->m_len > 0)
                                break;  /* device can't take no more */
+#if 0
                        MFREE(m, m2);
                        m = m2;
+#endif
+                       m = m_free(m);
                }
 
                /* Put remainder of mbuf chain (if any) back on queue */
Index: i386/isa/if_lnc.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/Attic/if_lnc.c,v
retrieving revision 1.68.2.4
diff -u -r1.68.2.4 if_lnc.c
--- i386/isa/if_lnc.c   8 Jan 2001 15:37:59 -0000       1.68.2.4
+++ i386/isa/if_lnc.c   2 Jan 2002 06:12:24 -0000
@@ -839,9 +839,13 @@
                                        sc->mbuf_count++;
                                        start->buff.mbuf = 0;
                                } else {
+#if 0
                                        struct mbuf *junk;
                                        MFREE(start->buff.mbuf, junk);
-                                       start->buff.mbuf = 0;
+#endif
+                                       /* XXX shouldn't this be m_freem ?? */
+                                       m_free(start->buff.mbuf);
+                                       start->buff.mbuf = NULL;
                                }
                        }
                        sc->pending_transmits--;
@@ -1702,8 +1706,12 @@
                                                m->m_len -= chunk;
                                                m->m_data += chunk;
                                                if (m->m_len <= 0) {
+#if 0
                                                        MFREE(m, head->m_next);
                                                        m = head->m_next;
+#endif
+                                                       m = m_free(m);
+                                                       head->m_next = m;
                                                }
                                        }
                                }

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to