DTrace: Get rid of the KDTRACE_HOOKS ifdefs in the kernel. Replace the
functions with inline function that are empty when KDTRACE_HOOKS is not defined.
This commit is contained in:
parent
d3b2fb89de
commit
383b7f700b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_dtrace.c,v 1.1 2010/02/21 07:28:51 darran Exp $ */
|
||||
/* $NetBSD: kern_dtrace.c,v 1.2 2010/02/23 22:19:27 darran Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007-2008 John Birrell <jb@FreeBSD.org>
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_dtrace.c,v 1.1 2010/02/21 07:28:51 darran Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_dtrace.c,v 1.2 2010/02/23 22:19:27 darran Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -37,11 +37,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_dtrace.c,v 1.1 2010/02/21 07:28:51 darran Exp $
|
||||
#include <sys/proc.h>
|
||||
#include <sys/dtrace_bsd.h>
|
||||
|
||||
#define KDTRACE_PROC_SIZE 64
|
||||
#define KDTRACE_PROC_ZERO 8
|
||||
#define KDTRACE_THREAD_SIZE 256
|
||||
#define KDTRACE_THREAD_ZERO 64
|
||||
|
||||
/* Return the DTrace process data size compiled in the kernel hooks. */
|
||||
size_t
|
||||
kdtrace_proc_size()
|
||||
@ -50,24 +45,6 @@ kdtrace_proc_size()
|
||||
return(KDTRACE_PROC_SIZE);
|
||||
}
|
||||
|
||||
void
|
||||
kdtrace_proc_ctor(void *arg, struct proc *p)
|
||||
{
|
||||
|
||||
p->p_dtrace = kmem_alloc(KDTRACE_PROC_SIZE, KM_SLEEP);
|
||||
memset(p->p_dtrace, 0, KDTRACE_PROC_ZERO);
|
||||
}
|
||||
|
||||
void
|
||||
kdtrace_proc_dtor(void *arg, struct proc *p)
|
||||
{
|
||||
|
||||
if (p->p_dtrace != NULL) {
|
||||
kmem_free(p->p_dtrace, KDTRACE_PROC_SIZE);
|
||||
p->p_dtrace = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the DTrace thread data size compiled in the kernel hooks. */
|
||||
size_t
|
||||
kdtrace_thread_size()
|
||||
@ -75,21 +52,3 @@ kdtrace_thread_size()
|
||||
|
||||
return(KDTRACE_THREAD_SIZE);
|
||||
}
|
||||
|
||||
void
|
||||
kdtrace_thread_ctor(void *arg, struct lwp *l)
|
||||
{
|
||||
|
||||
l->l_dtrace = kmem_alloc(KDTRACE_THREAD_SIZE, KM_SLEEP);
|
||||
memset(l->l_dtrace, 0, KDTRACE_THREAD_ZERO);
|
||||
}
|
||||
|
||||
void
|
||||
kdtrace_thread_dtor(void *arg, struct lwp *l)
|
||||
{
|
||||
|
||||
if (l->l_dtrace != NULL) {
|
||||
kmem_free(l->l_dtrace, KDTRACE_THREAD_SIZE);
|
||||
l->l_dtrace = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_lwp.c,v 1.139 2010/02/21 07:01:57 darran Exp $ */
|
||||
/* $NetBSD: kern_lwp.c,v 1.140 2010/02/23 22:19:27 darran Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
|
||||
@ -209,7 +209,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.139 2010/02/21 07:01:57 darran Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.140 2010/02/23 22:19:27 darran Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_lockdebug.h"
|
||||
@ -236,10 +236,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.139 2010/02/21 07:01:57 darran Exp $"
|
||||
#include <sys/lwpctl.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/filedesc.h>
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
#include <sys/dtrace_bsd.h>
|
||||
#endif
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
#include <uvm/uvm_object.h>
|
||||
@ -625,9 +622,7 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_t uaddr, int flags,
|
||||
l2->l_cpu = l1->l_cpu;
|
||||
kpreempt_enable();
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
kdtrace_thread_ctor(NULL, l2);
|
||||
#endif
|
||||
lwp_initspecific(l2);
|
||||
sched_lwp_fork(l1, l2);
|
||||
lwp_update_creds(l2);
|
||||
@ -964,9 +959,7 @@ lwp_free(struct lwp *l, bool recycle, bool last)
|
||||
|
||||
KASSERT(SLIST_EMPTY(&l->l_pi_lenders));
|
||||
KASSERT(l->l_inheritedprio == -1);
|
||||
#ifdef KDTRACE_HOOKS
|
||||
kdtrace_thread_dtor(NULL, l);
|
||||
#endif
|
||||
if (!recycle)
|
||||
pool_cache_put(lwp_cache, l);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_proc.c,v 1.161 2010/02/21 07:01:57 darran Exp $ */
|
||||
/* $NetBSD: kern_proc.c,v 1.162 2010/02/23 22:19:27 darran Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.161 2010/02/21 07:01:57 darran Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.162 2010/02/23 22:19:27 darran Exp $");
|
||||
|
||||
#include "opt_kstack.h"
|
||||
#include "opt_maxuprc.h"
|
||||
@ -94,10 +94,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.161 2010/02/21 07:01:57 darran Exp $
|
||||
#include <sys/sleepq.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/kmem.h>
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
#include <sys/dtrace_bsd.h>
|
||||
#endif
|
||||
|
||||
#include <uvm/uvm.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
@ -447,9 +444,7 @@ proc0_init(void)
|
||||
mutex_init(&p->p_sigacts->sa_mutex, MUTEX_DEFAULT, IPL_SCHED);
|
||||
siginit(p);
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
kdtrace_proc_ctor(NULL, p);
|
||||
#endif
|
||||
|
||||
proc_initspecific(p);
|
||||
lwp_initspecific(l);
|
||||
@ -719,9 +714,7 @@ proc_alloc(void)
|
||||
pt->pt_proc = p;
|
||||
pid_alloc_cnt++;
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
kdtrace_proc_ctor(NULL, p);
|
||||
#endif
|
||||
|
||||
mutex_exit(proc_lock);
|
||||
|
||||
@ -766,9 +759,7 @@ void
|
||||
proc_free_mem(struct proc *p)
|
||||
{
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
kdtrace_proc_dtor(NULL, p);
|
||||
#endif
|
||||
pool_cache_put(proc_cache, p);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_synch.c,v 1.278 2010/02/21 07:39:18 darran Exp $ */
|
||||
/* $NetBSD: kern_synch.c,v 1.279 2010/02/23 22:19:27 darran Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009
|
||||
@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.278 2010/02/21 07:39:18 darran Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.279 2010/02/23 22:19:27 darran Exp $");
|
||||
|
||||
#include "opt_kstack.h"
|
||||
#include "opt_perfctrs.h"
|
||||
@ -103,11 +103,9 @@ __KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.278 2010/02/21 07:39:18 darran Exp
|
||||
|
||||
#include <dev/lockstat.h>
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
#include <sys/dtrace_bsd.h>
|
||||
int dtrace_vtime_active;
|
||||
int dtrace_vtime_active=0;
|
||||
dtrace_vtime_switch_func_t dtrace_vtime_switch_func;
|
||||
#endif
|
||||
|
||||
static void sched_unsleep(struct lwp *, bool);
|
||||
static void sched_changepri(struct lwp *, pri_t);
|
||||
@ -769,7 +767,6 @@ mi_switch(lwp_t *l)
|
||||
SPINLOCK_BACKOFF(count);
|
||||
}
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
/*
|
||||
* If DTrace has set the active vtime enum to anything
|
||||
* other than INACTIVE (0), then it should have set the
|
||||
@ -778,7 +775,6 @@ mi_switch(lwp_t *l)
|
||||
if (__predict_false(dtrace_vtime_active)) {
|
||||
(*dtrace_vtime_switch_func)(newl);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Switch to the new LWP.. */
|
||||
prevlwp = cpu_switchto(l, newl, returning);
|
||||
@ -921,16 +917,14 @@ lwp_exit_switchaway(lwp_t *l)
|
||||
SPINLOCK_BACKOFF(count);
|
||||
}
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
/*
|
||||
* If DTrace has set the active vtime enum to anything
|
||||
* other than INACTIVE (0), then it should have set the
|
||||
* function to call.
|
||||
*/
|
||||
if (__predict_false(dtrace_vtime_active)) {
|
||||
(*dtrace_vtime_switch_func)(newl);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* If DTrace has set the active vtime enum to anything
|
||||
* other than INACTIVE (0), then it should have set the
|
||||
* function to call.
|
||||
*/
|
||||
if (__predict_false(dtrace_vtime_active)) {
|
||||
(*dtrace_vtime_switch_func)(newl);
|
||||
}
|
||||
|
||||
/* Switch to the new LWP.. */
|
||||
(void)cpu_switchto(NULL, newl, false);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dtrace_bsd.h,v 1.1 2010/02/21 02:11:39 darran Exp $ */
|
||||
/* $NetBSD: dtrace_bsd.h,v 1.2 2010/02/23 22:19:27 darran Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007-2008 John Birrell (jb@freebsd.org)
|
||||
@ -33,6 +33,15 @@
|
||||
#ifndef _SYS_DTRACE_BSD_H
|
||||
#define _SYS_DTRACE_BSD_H
|
||||
|
||||
#include "opt_dtrace.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
/* Forward definitions: */
|
||||
struct mbuf;
|
||||
struct trapframe;
|
||||
@ -148,18 +157,6 @@ typedef void (*dtrace_nfsclient_nfs23_done_probe_func_t)(uint32_t,
|
||||
extern dtrace_nfsclient_nfs23_done_probe_func_t
|
||||
dtrace_nfsclient_nfs23_done_probe;
|
||||
|
||||
/*
|
||||
* Functions which allow the dtrace module to check that the kernel
|
||||
* hooks have been compiled with sufficient space for it's private
|
||||
* structures.
|
||||
*/
|
||||
size_t kdtrace_proc_size(void);
|
||||
void kdtrace_proc_ctor(void *, struct proc *);
|
||||
void kdtrace_proc_dtor(void *, struct proc *);
|
||||
size_t kdtrace_thread_size(void);
|
||||
void kdtrace_thread_ctor(void *, struct lwp *);
|
||||
void kdtrace_thread_dtor(void *, struct lwp *);
|
||||
|
||||
/*
|
||||
* OpenSolaris compatible time functions returning nanoseconds.
|
||||
* On OpenSolaris these return hrtime_t which we define as uint64_t.
|
||||
@ -167,4 +164,83 @@ void kdtrace_thread_dtor(void *, struct lwp *);
|
||||
uint64_t dtrace_gethrtime(void);
|
||||
uint64_t dtrace_gethrestime(void);
|
||||
|
||||
/* sizes based on DTrace structure requirements */
|
||||
#define KDTRACE_PROC_SIZE 64
|
||||
#define KDTRACE_PROC_ZERO 8
|
||||
#define KDTRACE_THREAD_SIZE 256
|
||||
#define KDTRACE_THREAD_ZERO 64
|
||||
|
||||
/*
|
||||
* Functions for managing the opaque DTrace memory areas for
|
||||
* processes and lwps.
|
||||
*/
|
||||
|
||||
static inline size_t kdtrace_proc_size(void);
|
||||
static inline void kdtrace_proc_ctor(void *, struct proc *);
|
||||
static inline void kdtrace_proc_dtor(void *, struct proc *);
|
||||
static inline size_t kdtrace_thread_size(void);
|
||||
static inline void kdtrace_thread_ctor(void *, struct lwp *);
|
||||
static inline void kdtrace_thread_dtor(void *, struct lwp *);
|
||||
|
||||
|
||||
/* Return the DTrace process data size compiled in the kernel hooks. */
|
||||
static inline size_t
|
||||
kdtrace_proc_size()
|
||||
{
|
||||
|
||||
return(KDTRACE_PROC_SIZE);
|
||||
}
|
||||
|
||||
/* Return the DTrace thread data size compiled in the kernel hooks. */
|
||||
static inline size_t
|
||||
kdtrace_thread_size()
|
||||
{
|
||||
|
||||
return(KDTRACE_THREAD_SIZE);
|
||||
}
|
||||
|
||||
static inline void
|
||||
kdtrace_proc_ctor(void *arg, struct proc *p)
|
||||
{
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
p->p_dtrace = kmem_alloc(KDTRACE_PROC_SIZE, KM_SLEEP);
|
||||
memset(p->p_dtrace, 0, KDTRACE_PROC_ZERO);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
kdtrace_proc_dtor(void *arg, struct proc *p)
|
||||
{
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
if (p->p_dtrace != NULL) {
|
||||
kmem_free(p->p_dtrace, KDTRACE_PROC_SIZE);
|
||||
p->p_dtrace = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
kdtrace_thread_ctor(void *arg, struct lwp *l)
|
||||
{
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
l->l_dtrace = kmem_alloc(KDTRACE_THREAD_SIZE, KM_SLEEP);
|
||||
memset(l->l_dtrace, 0, KDTRACE_THREAD_ZERO);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
kdtrace_thread_dtor(void *arg, struct lwp *l)
|
||||
{
|
||||
|
||||
#ifdef KDTRACE_HOOKS
|
||||
if (l->l_dtrace != NULL) {
|
||||
kmem_free(l->l_dtrace, KDTRACE_THREAD_SIZE);
|
||||
l->l_dtrace = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* _SYS_DTRACE_BSD_H */
|
||||
|
Loading…
Reference in New Issue
Block a user