diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 765692e..0954a5b 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -553,7 +553,7 @@ mbufphdrcluster_ctor(void *obj, void *private, int ocflags) mbufphdr_ctor(obj, private, ocflags); cl = objcache_get(mclmeta_cache, ocflags); if (cl == NULL) { - ++mbstat[mycpu->gd_cpuid].m_drops; + M_STAT_GET(m_drops); return (FALSE); } m->m_flags |= M_CLCACHE; @@ -570,7 +570,7 @@ mbufphdrjcluster_ctor(void *obj, void *private, int ocflags) mbufphdr_ctor(obj, private, ocflags); cl = objcache_get(mjclmeta_cache, ocflags); if (cl == NULL) { - ++mbstat[mycpu->gd_cpuid].m_drops; + M_STAT_GET(m_drops); return (FALSE); } m->m_flags |= M_CLCACHE; @@ -587,7 +587,7 @@ mbufcluster_ctor(void *obj, void *private, int ocflags) mbuf_ctor(obj, private, ocflags); cl = objcache_get(mclmeta_cache, ocflags); if (cl == NULL) { - ++mbstat[mycpu->gd_cpuid].m_drops; + M_STAT_GET(m_drops); return (FALSE); } m->m_flags |= M_CLCACHE; @@ -604,7 +604,7 @@ mbufjcluster_ctor(void *obj, void *private, int ocflags) mbuf_ctor(obj, private, ocflags); cl = objcache_get(mjclmeta_cache, ocflags); if (cl == NULL) { - ++mbstat[mycpu->gd_cpuid].m_drops; + M_STAT_GET(m_drops); return (FALSE); } m->m_flags |= M_CLCACHE; @@ -788,7 +788,7 @@ m_reclaim(void) (*pr->pr_drain)(); } } - ++mbstat[mycpu->gd_cpuid].m_drain; + M_STAT_GET(m_drain); } static __inline void @@ -804,7 +804,7 @@ updatestats(struct mbuf *m, int type) #endif ++mbtypes[gd->gd_cpuid].stats[type]; - ++mbstat[gd->gd_cpuid].m_mbufs; + M_STAT_GET(m_mbufs); } @@ -837,7 +837,7 @@ retryonce: m_reclaim(); goto retryonce; } - ++mbstat[mycpu->gd_cpuid].m_drops; + M_STAT_GET(m_drops); return (NULL); } #ifdef MBUF_DEBUG @@ -873,7 +873,7 @@ retryonce: m_reclaim(); goto retryonce; } - ++mbstat[mycpu->gd_cpuid].m_drops; + M_STAT_GET(m_drops); return (NULL); } #ifdef MBUF_DEBUG @@ -928,7 +928,7 @@ retryonce: m_reclaim(); goto retryonce; } - ++mbstat[mycpu->gd_cpuid].m_drops; + M_STAT_GET(m_drops); return (NULL); } @@ -1198,13 +1198,13 @@ m_free(struct mbuf *m) objcache_put(mbufphdrjcluster_cache, m); else objcache_put(mbufjcluster_cache, m); - --mbstat[mycpu->gd_cpuid].m_jclusters; + M_STAT_PUT(m_jclusters); } else { if (m->m_flags & M_PHCACHE) objcache_put(mbufphdrcluster_cache, m); else objcache_put(mbufcluster_cache, m); - --mbstat[mycpu->gd_cpuid].m_clusters; + M_STAT_PUT(m_clusters); } } else { /* @@ -1254,7 +1254,7 @@ m_free(struct mbuf *m) m->m_data = m->m_dat; objcache_put(mbuf_cache, m); } - --mbstat[mycpu->gd_cpuid].m_mbufs; + M_STAT_PUT(m_mbufs); break; default: if (!panicstr) @@ -1402,11 +1402,12 @@ m_copym(const struct mbuf *m, int off0, int len, int wait) np = &n->m_next; } if (top == NULL) - ++mbstat[mycpu->gd_cpuid].m_mcfail; + M_STAT_GET(m_mcfail); return (top); nospace: m_freem(top); - ++mbstat[mycpu->gd_cpuid].m_mcfail; + M_STAT_GET(m_mcfail); + return (NULL); } @@ -1468,7 +1469,7 @@ m_copypacket(struct mbuf *m, int how) return top; nospace: m_freem(top); - ++mbstat[mycpu->gd_cpuid].m_mcfail; + M_STAT_GET(m_mcfail); return (NULL); } @@ -1561,7 +1562,7 @@ m_dup(struct mbuf *m, int how) nospace: m_freem(top); nospace0: - ++mbstat[mycpu->gd_cpuid].m_mcfail; + M_STAT_GET(m_mcfail); return (NULL); } @@ -1638,7 +1639,7 @@ m_dup_data(struct mbuf *m, int how) nospace: *p = NULL; m_freem(top); - ++mbstat[mycpu->gd_cpuid].m_mcfail; + M_STAT_GET(m_mcfail); return (NULL); } @@ -1964,7 +1965,7 @@ m_pullup(struct mbuf *n, int len) return (m); bad: m_freem(n); - ++mbstat[mycpu->gd_cpuid].m_mcfail; + M_STAT_GET(m_mcfail); return (NULL); } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index aa2b941..5e8899f 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -80,6 +80,18 @@ #define mtodoff(m, t, off) ((t)((m)->m_data + (off))) /* + * Macros for updating statistics. + */ +#define M_STAT_GET(field) ++mbstat[mycpu->gd_cpuid].field + +#define M_STAT_PUT(field) \ +do { \ + if (mbstat[mycpu->gd_cpuid].field == 0) \ + kprintf("mbuf stat underflow for %s\n", #field); \ + --mbstat[mycpu->gd_cpuid].field; \ +} while(0) + +/* * Header present at the beginning of every mbuf. */ struct m_hdr {