From 3f969213cb1f77a80237f0ba914f73b9ccf2fafb Mon Sep 17 00:00:00 2001 From: k-nakahara Date: Mon, 4 Apr 2016 13:01:33 +0900 Subject: [PATCH 2/3] add dtrace probe --- sys/kern/uipc_mbuf.c | 2 ++ sys/kern/uipc_mbuf2.c | 9 ++++++++- sys/sys/mbuf.h | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 4049b2b..23f2a5d 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -87,6 +87,8 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.163 2015/08/24 22:21:26 pooka Exp $" #include +SDT_PROVIDER_DEFINE(mbuf); + pool_cache_t mb_cache; /* mbuf cache */ pool_cache_t mcl_cache; /* mbuf cluster cache */ pool_cache_t mtag_cache;/* m_tag cache */ diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c index 18a6c97..6b2707d 100644 --- a/sys/kern/uipc_mbuf2.c +++ b/sys/kern/uipc_mbuf2.c @@ -70,6 +70,9 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.30 2013/10/08 19:59:49 christos Exp #include #include +SDT_PROBE_DEFINE2(mbuf, m_tag, pool_cache_get, success, "int", "int"); +SDT_PROBE_DEFINE2(mbuf, m_tag, pool_cache_get, fail, "int", "int"); + /* * ensure that [off, off + len) is contiguous on the mbuf chain "m". * packet chain before "off" is kept untouched. @@ -264,8 +267,12 @@ m_tag_get(int type, int len, int wait) tp = pool_cache_get(mtag_cache, wait == M_NOWAIT ? PR_NOWAIT : PR_WAITOK); - if (tp == NULL) + if (tp == NULL) { + SDT_PROBE2(mbuf, m_tag, pool_cache_get, fail, type, len); return NULL; + } else { + SDT_PROBE2(mbuf, m_tag, pool_cache_get, success, type, len); + } t = &tp->mp_tag; t->m_tag_id = type; t->m_tag_len = len; diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index c3da181..398eafb 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -66,6 +66,7 @@ #ifdef _KERNEL_OPT #include "opt_mbuftrace.h" +#include "opt_dtrace.h" #endif #ifndef M_WAITOK @@ -76,6 +77,7 @@ #if defined(_KERNEL) #include #endif /* defined(_KERNEL) */ +#include /* For offsetof() */ #if defined(_KERNEL) || defined(_STANDALONE) @@ -86,6 +88,8 @@ #include /* for MIN_PAGE_SIZE */ +SDT_PROVIDER_DECLARE(mbuf); + /* * Mbufs are of a single size, MSIZE (machine/param.h), which * includes overhead. An mbuf may add a single "mbuf cluster" of size -- 2.1.0