Index: share/dtrace/Makefile =================================================================== --- share/dtrace/Makefile +++ share/dtrace/Makefile @@ -30,4 +30,10 @@ SCRIPTSDIR= ${SHAREDIR}/dtrace +DSRCS= mbuf.d + +FILES= ${DSRCS} +FILESDIR= /usr/lib/dtrace +FILESMODE= ${NOBINMODE} + .include Index: sys/kern/kern_mbuf.c =================================================================== --- sys/kern/kern_mbuf.c +++ sys/kern/kern_mbuf.c @@ -731,6 +731,7 @@ zone_drain(zone_pack); uma_zalloc_arg(zone_clust, m, how); } + MBUF_PROBE2(m__clget, m, how); return (m->m_flags & M_EXT); } @@ -746,6 +747,8 @@ { uma_zone_t zone; + MBUF_PROBE3(m__cljget, m, how, size); + if (m != NULL) { KASSERT((m->m_flags & M_EXT) == 0, ("%s: mbuf %p has M_EXT", __func__, m)); @@ -933,6 +936,7 @@ void m_freem(struct mbuf *mb) { + MBUF_PROBE1(m__freem, mb); while (mb != NULL) mb = m_free(mb); Index: sys/kern/uipc_mbuf.c =================================================================== --- sys/kern/uipc_mbuf.c +++ sys/kern/uipc_mbuf.c @@ -47,6 +47,45 @@ #include #include #include +#include + +SDT_PROVIDER_DEFINE(mbuf); + +SDT_PROBE_DEFINE4_XLATE(mbuf, , , m__init, + "struct mbuf *", "mbufinfo_t *", + "uint32_t", "uint32_t", + "uint16_t", "uint16_t", + "uint32_t", "uint32_t"); + +SDT_PROBE_DEFINE3_XLATE(mbuf, , , m__gethdr, + "uint32_t", "uint32_t", + "uint16_t", "uint16_t", + "struct mbuf *", "mbufinfo_t *"); + +SDT_PROBE_DEFINE3_XLATE(mbuf, , , m__get, + "uint32_t", "uint32_t", + "uint16_t", "uint16_t", + "struct mbuf *", "mbufinfo_t *"); + +SDT_PROBE_DEFINE4_XLATE(mbuf, , , m__getcl, + "uint32_t", "uint32_t", + "uint16_t", "uint16_t", + "uint32_t", "uint32_t", + "struct mbuf *", "mbufinfo_t *"); + +SDT_PROBE_DEFINE3_XLATE(mbuf, , , m__clget, + "struct mbuf *", "mbufinfo_t *", + "uint32_t", "uint32_t", + "uint32_t", "uint32_t"); + +SDT_PROBE_DEFINE(mbuf, , , m__cljget); +SDT_PROBE_DEFINE(mbuf, , , m__cljset); + +SDT_PROBE_DEFINE1_XLATE(mbuf, , , m__free, + "struct mbuf *", "mbufinfo_t *"); + +SDT_PROBE_DEFINE1_XLATE(mbuf, , , m__freem, + "struct mbuf *", "mbufinfo_t *"); #include Index: sys/sys/mbuf.h =================================================================== --- sys/sys/mbuf.h +++ sys/sys/mbuf.h @@ -44,6 +44,32 @@ #endif #endif +#ifdef _KERNEL +#include + +#define MBUF_PROBE1(probe, arg0) \ + SDT_PROBE1(mbuf, , , probe, arg0) +#define MBUF_PROBE2(probe, arg0, arg1) \ + SDT_PROBE2(mbuf, , , probe, arg0, arg1) +#define MBUF_PROBE3(probe, arg0, arg1, arg2) \ + SDT_PROBE3(mbuf, , , probe, arg0, arg1, arg2) +#define MBUF_PROBE4(probe, arg0, arg1, arg2, arg3) \ + SDT_PROBE4(mbuf, , , probe, arg0, arg1, arg2, arg3) + +SDT_PROVIDER_DECLARE(mbuf); + +SDT_PROBE_DECLARE(mbuf, , , m__init); +SDT_PROBE_DECLARE(mbuf, , , m__gethdr); +SDT_PROBE_DECLARE(mbuf, , , m__get); +SDT_PROBE_DECLARE(mbuf, , , m__getcl); +SDT_PROBE_DECLARE(mbuf, , , m__clget); +SDT_PROBE_DECLARE(mbuf, , , m__cljget); +SDT_PROBE_DECLARE(mbuf, , , m__cljset); +SDT_PROBE_DECLARE(mbuf, , , m__free); +SDT_PROBE_DECLARE(mbuf, , , m__freem); + +#endif /* _KERNEL */ + /* * Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead. * An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in @@ -666,6 +692,7 @@ { int error; + MBUF_PROBE4(m__init, m, how, type, flags); m->m_next = NULL; m->m_nextpkt = NULL; m->m_data = m->m_dat; @@ -683,31 +710,40 @@ static __inline struct mbuf * m_get(int how, short type) { + struct mbuf *m; struct mb_args args; args.flags = 0; args.type = type; - return (uma_zalloc_arg(zone_mbuf, &args, how)); + m = uma_zalloc_arg(zone_mbuf, &args, how); + MBUF_PROBE3(m__get, how, type, m); + return (m); } static __inline struct mbuf * m_gethdr(int how, short type) { + struct mbuf *m; struct mb_args args; args.flags = M_PKTHDR; args.type = type; - return (uma_zalloc_arg(zone_mbuf, &args, how)); + m = uma_zalloc_arg(zone_mbuf, &args, how); + MBUF_PROBE3(m__gethdr, how, type, m); + return (m); } static __inline struct mbuf * m_getcl(int how, short type, int flags) { + struct mbuf *m; struct mb_args args; args.flags = flags; args.type = type; - return (uma_zalloc_arg(zone_pack, &args, how)); + m = uma_zalloc_arg(zone_pack, &args, how); + MBUF_PROBE4(m__getcl, how, type, flags, m); + return (m); } /* @@ -720,6 +756,7 @@ { int size; + MBUF_PROBE3(m__cljset, m, cl, type); switch (type) { case EXT_CLUSTER: size = MCLBYTES; @@ -1122,6 +1159,7 @@ { struct mbuf *n = m->m_next; + MBUF_PROBE1(m__free, m); if ((m->m_flags & (M_PKTHDR|M_NOFREE)) == (M_PKTHDR|M_NOFREE)) m_tag_delete_chain(m, NULL); if (m->m_flags & M_EXT)