Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys DTrace: Get rid of the KDTRACE_HOOKS ifdefs in the kerne...
details: https://anonhg.NetBSD.org/src/rev/67db3eb620b8
branches: trunk
changeset: 752337:67db3eb620b8
user: darran <darran%NetBSD.org@localhost>
date: Tue Feb 23 22:19:27 2010 +0000
description:
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.
diffstat:
sys/kern/kern_dtrace.c | 45 +--------------------
sys/kern/kern_lwp.c | 11 +----
sys/kern/kern_proc.c | 13 +-----
sys/kern/kern_synch.c | 28 +++++--------
sys/sys/dtrace_bsd.h | 102 ++++++++++++++++++++++++++++++++++++++++++------
5 files changed, 106 insertions(+), 93 deletions(-)
diffs (truncated from 384 to 300 lines):
diff -r a89c439fd105 -r 67db3eb620b8 sys/kern/kern_dtrace.c
--- a/sys/kern/kern_dtrace.c Tue Feb 23 21:38:36 2010 +0000
+++ b/sys/kern/kern_dtrace.c Tue Feb 23 22:19:27 2010 +0000
@@ -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@localhost>
@@ -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 @@
#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 @@
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 @@
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;
- }
-}
diff -r a89c439fd105 -r 67db3eb620b8 sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c Tue Feb 23 21:38:36 2010 +0000
+++ b/sys/kern/kern_lwp.c Tue Feb 23 22:19:27 2010 +0000
@@ -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 @@
#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 @@
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 @@
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);
}
diff -r a89c439fd105 -r 67db3eb620b8 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c Tue Feb 23 21:38:36 2010 +0000
+++ b/sys/kern/kern_proc.c Tue Feb 23 22:19:27 2010 +0000
@@ -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 @@
#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 @@
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 @@
pt->pt_proc = p;
pid_alloc_cnt++;
-#ifdef KDTRACE_HOOKS
kdtrace_proc_ctor(NULL, p);
-#endif
mutex_exit(proc_lock);
@@ -766,9 +759,7 @@
proc_free_mem(struct proc *p)
{
-#ifdef KDTRACE_HOOKS
kdtrace_proc_dtor(NULL, p);
-#endif
pool_cache_put(proc_cache, p);
}
diff -r a89c439fd105 -r 67db3eb620b8 sys/kern/kern_synch.c
--- a/sys/kern/kern_synch.c Tue Feb 23 21:38:36 2010 +0000
+++ b/sys/kern/kern_synch.c Tue Feb 23 22:19:27 2010 +0000
@@ -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 @@
#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 @@
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 @@
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 @@
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);
diff -r a89c439fd105 -r 67db3eb620b8 sys/sys/dtrace_bsd.h
--- a/sys/sys/dtrace_bsd.h Tue Feb 23 21:38:36 2010 +0000
+++ b/sys/sys/dtrace_bsd.h Tue Feb 23 22:19:27 2010 +0000
@@ -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@localhost)
@@ -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;
@@ -149,22 +158,89 @@
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.
Home |
Main Index |
Thread Index |
Old Index