Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Nov 2008 10:28:26 +0000 (UTC)
From:      Alexander Leidinger <netchild@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r185365 - user/netchild/linuxulator-dtrace/src/sys/compat/linux
Message-ID:  <200811271028.mARASQNN084460@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: netchild
Date: Thu Nov 27 10:28:26 2008
New Revision: 185365
URL: http://svn.freebsd.org/changeset/base/185365

Log:
  Finish dtrace probes in first linux file (module):
   - Fix bugs in previous commit.
   - Add more probes.
   - Add helper macros in separate header file to make the job of adding more
     probes a little bit more easy (and to make the bitsize dependand provider
     name actually work instead of using the macro name as the provider name).
  
  Add some more dtrace scripts, see comments in the scripts for their purpose.
  
  This is only compile tested so far.

Added:
  user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d   (contents, props changed)
  user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_dtrace.h   (contents, props changed)
  user/netchild/linuxulator-dtrace/src/sys/compat/linux/stats_timing.d   (contents, props changed)
Modified:
  user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_emul_lock.d   (contents, props changed)
  user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_emul.c

Modified: user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_emul_lock.d
==============================================================================
--- user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_emul_lock.d	Thu Nov 27 09:21:37 2008	(r185364)
+++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_emul_lock.d	Thu Nov 27 10:28:26 2008	(r185365)
@@ -1,5 +1,35 @@
 #!/usr/sbin/dtrace -qs
 
+/*-
+ * Copyright (c) 2008 Alexander Leidinger <netchild@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
 /*
  * Check if the emul lock is correctly acquired/released:
  *  - no recursive locking

Added: user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/check_error.d	Thu Nov 27 10:28:26 2008	(r185365)
@@ -0,0 +1,43 @@
+#!/usr/sbin/dtrace -qs
+
+/*-
+ * Copyright (c) 2008 Alexander Leidinger <netchild@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/* Report error conditions. */
+
+linuxulator*:emul:proc_exit:child_clear_tid_error,
+linuxulator*:emul:proc_exit:futex_failed,
+linuxulator*:emul:linux_schedtail:copyout_error
+{
+	printf("ERROR: %s in %s:%s:%s\n", probename, probeprov, probemod, probefunc);
+	stack();
+	/* ustack(); */	/* needs to be enabled when PID tracing is available in FreeBSD dtrace */
+}
+

Added: user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_dtrace.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_dtrace.h	Thu Nov 27 10:28:26 2008	(r185365)
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2008 Alexander Leidinger <netchild@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LINUX_DTRACE_H_
+#define _LINUX_DTRACE_H_
+
+/*
+ * Some wrapper macros to make it more easy to handle the linuxulator
+ * providers and to allow to make the name depend upon the bitsize.
+ */
+
+#define	LIN_SDT_PROVIDER_DEFINE(x)	SDT_PROVIDER_DEFINE(x)
+#define LIN_SDT_PROVIDER_DECLARE(x)	SDT_PROVIDER_DECLARE(x)
+
+#define	_LIN_SDT_PROBE_DEFINE(a, b, c, d)	SDT_PROBE_DEFINE(a, b, c, d)
+#define	LIN_SDT_PROBE_DEFINE(a, b, c)	_LIN_SDT_PROBE_DEFINE(LINUX_DTRACE, a, \
+    b, c)
+
+#define	_LIN_SDT_PROBE_ARGTYPE(a, b, c, d, e, f)	SDT_PROBE_ARGTYPE(a, b,\
+    c, d, e, f)
+#define LIN_SDT_PROBE_ARGTYPE(a, b, c, d, e)	_LIN_SDT_PROBE_ARGTYPE( \
+    LINUX_DTRACE, a, b, c, d, e)
+
+#define	_LIN_SDT_PROBE(a, b, c, d, e, f, g, h, i)	SDT_PROBE(a, b, c, d, \
+    e, f, g, h, i)
+#define	LIN_SDT_PROBE(a, b, c, d, e, f, g, h)	_LIN_SDT_PROBE(LINUX_DTRACE, \
+    a, b, c, d, e, f, g, h)
+
+#endif /* _LINUX_DTRACE_H_ */

Modified: user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_emul.c
==============================================================================
--- user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_emul.c	Thu Nov 27 09:21:37 2008	(r185364)
+++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/linux_emul.c	Thu Nov 27 10:28:26 2008	(r185365)
@@ -60,55 +60,67 @@ __FBSDID("$FreeBSD$");
 
 #include <compat/linux/linux_emul.h>
 #include <compat/linux/linux_futex.h>
+#include <compat/linux/linux_dtrace.h>
 
 /*
  * In this file we define the provider for the entire linuxulator. All
  * modules (= files of the linuxulator) use it.
  *
  * We define a different name depending on the emulated bitsize, see
- * ../../<ARCH>/linux*/linux.h, e.g.:
+ * ../../<ARCH>/linux{,32}/linux.h, e.g.:
  * 	native bitsize		= linuxulator
  * 	amd64, 32bit emulation	= linuxulator32
  */
-SDT_PROVIDER_DEFINE(LINUX_DTRACE);
+LIN_SDT_PROVIDER_DEFINE(LINUX_DTRACE);
 
 /* DTrace probes in this module. */
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, em_find, entry);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, em_find, entry, 0, "struct proc *");
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, em_find, entry, 1, "int");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, em_find, emul_locked);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, em_find, emul_locked, 0, "struct mtx *");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, em_find, emul_unlock);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, em_find, emul_unlock, 0, "struct mtx *");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, em_find, return);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, em_find, return, 0,
-    "struct linux_emuldata *");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_init, entry);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_init, entry, 0, "struct thread *");
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_init, entry, 1, "pid_t");
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_init, entry, 2, "int");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_init, emul_unlock);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_init, emul_unlock, 0,
+LIN_SDT_PROBE_DEFINE(emul, em_find, entry);
+LIN_SDT_PROBE_ARGTYPE(emul, em_find, entry, 0, "struct proc *");
+LIN_SDT_PROBE_ARGTYPE(emul, em_find, entry, 1, "int");
+LIN_SDT_PROBE_DEFINE(emul, em_find, emul_locked);
+LIN_SDT_PROBE_ARGTYPE(emul, em_find, emul_locked, 0, "struct mtx *");
+LIN_SDT_PROBE_DEFINE(emul, em_find, emul_unlock);
+LIN_SDT_PROBE_ARGTYPE(emul, em_find, emul_unlock, 0, "struct mtx *");
+LIN_SDT_PROBE_DEFINE(emul, em_find, return);
+LIN_SDT_PROBE_ARGTYPE(emul, em_find, return, 0, "struct linux_emuldata *");
+LIN_SDT_PROBE_DEFINE(emul, proc_init, entry);
+LIN_SDT_PROBE_ARGTYPE(emul, proc_init, entry, 0, "struct thread *");
+LIN_SDT_PROBE_ARGTYPE(emul, proc_init, entry, 1, "pid_t");
+LIN_SDT_PROBE_ARGTYPE(emul, proc_init, entry, 2, "int");
+LIN_SDT_PROBE_DEFINE(emul, proc_init, create_thread);
+LIN_SDT_PROBE_DEFINE(emul, proc_init, fork);
+LIN_SDT_PROBE_DEFINE(emul, proc_init, exec);
+LIN_SDT_PROBE_DEFINE(emul, proc_init, emul_unlock);
+LIN_SDT_PROBE_ARGTYPE(emul, proc_init, emul_unlock, 0, "struct mtx *");
+LIN_SDT_PROBE_DEFINE(emul, proc_init, return);
+LIN_SDT_PROBE_DEFINE(emul, proc_exit, entry);
+LIN_SDT_PROBE_ARGTYPE(emul, proc_exit, entry, 0, "struct proc *");
+LIN_SDT_PROBE_DEFINE(emul, proc_exit, emul_unlock);
+LIN_SDT_PROBE_ARGTYPE(emul, proc_exit, emul_unlock, 0, "struct mtx *");
+LIN_SDT_PROBE_DEFINE(emul, proc_exit, futex_failed);
+LIN_SDT_PROBE_DEFINE(emul, proc_exit, reparent);
+LIN_SDT_PROBE_ARGTYPE(emul, proc_exit, reparent, 0, "pid_t");
+LIN_SDT_PROBE_ARGTYPE(emul, proc_exit, reparent, 1, "pid_t");
+LIN_SDT_PROBE_ARGTYPE(emul, proc_exit, reparent, 2, "struct proc *");
+LIN_SDT_PROBE_DEFINE(emul, proc_exit, child_clear_tid_error);
+LIN_SDT_PROBE_ARGTYPE(emul, proc_exit, child_clear_tid_error, 0, "int");
+LIN_SDT_PROBE_DEFINE(emul, proc_exit, return);
+LIN_SDT_PROBE_DEFINE(emul, proc_exec, entry);
+LIN_SDT_PROBE_ARGTYPE(emul, proc_exec, entry, 0, "struct proc *");
+LIN_SDT_PROBE_ARGTYPE(emul, proc_exec, entry, 1, "struct image_params *");
+LIN_SDT_PROBE_DEFINE(emul, proc_exec, return);
+LIN_SDT_PROBE_DEFINE(emul, linux_schedtail, entry);
+LIN_SDT_PROBE_DEFINE(emul, linux_schedtail, emul_unlock);
+LIN_SDT_PROBE_ARGTYPE(emul, linux_schedtail, emul_unlock, 0, "struct mtx *");
+LIN_SDT_PROBE_DEFINE(emul, linux_schedtail, copyout_error);
+LIN_SDT_PROBE_ARGTYPE(emul, linux_schedtail, copyout_error, 0, "int");
+LIN_SDT_PROBE_DEFINE(emul, linux_schedtail, return);
+LIN_SDT_PROBE_DEFINE(emul, linux_set_tid_address, entry);
+LIN_SDT_PROBE_ARGTYPE(emul, linux_set_tid_address, entry, 0, "int *");
+LIN_SDT_PROBE_DEFINE(emul, linux_set_tid_address, emul_unlock);
+LIN_SDT_PROBE_ARGTYPE(emul, linux_set_tid_address, emul_unlock, 0,
     "struct mtx *");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_init, return);
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_exit, entry);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_exit, entry, 0, "struct proc *");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_exit, emul_unlock);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_exit, emul_unlock, 0,
-    "struct mtx *");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_exit, reparent);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_exit, reparent, 0, "pid_t");
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_exit, reparent, 1, "pid_t");
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_exit, reparent, 2, "struct proc *");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_exit, child_clear_tid_error);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_exit, child_clear_tid_error, 0,
-    "int");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_exit, return);
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_exec, entry);
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_exec, entry, 0, "struct proc *");
-SDT_PROBE_ARGTYPE(LINUX_DTRACE, emul, proc_exec, entry, 0,
-    "struct image_params *");
-SDT_PROBE_DEFINE(LINUX_DTRACE, emul, proc_exec, return);
+LIN_SDT_PROBE_DEFINE(emul, linux_set_tid_address, return);
 
 struct sx	emul_shared_lock;
 struct mtx	emul_lock;
@@ -119,23 +131,23 @@ em_find(struct proc *p, int locked)
 {
 	struct linux_emuldata *em;
 
-	SDT_PROBE(LINUX_DTRACE, emul, em_find, entry, p, locked, 0, 0, 0);
+	LIN_SDT_PROBE(emul, em_find, entry, p, locked, 0, 0, 0);
 
 	if (locked == EMUL_DOLOCK) {
 		EMUL_LOCK(&emul_lock);
-		SDT_PROBE(LINUX_DTRACE, emul, em_find, emul_lock, &emul_lock,
+		LIN_SDT_PROBE(emul, em_find, emul_locked, &emul_lock,
 		    0, 0, 0, 0);
 	}
 
 	em = p->p_emuldata;
 
 	if (em == NULL && locked == EMUL_DOLOCK) {
-		SDT_PROBE(LINUX_DTRACE, emul, em_find, emul_unlock, &emul_lock,
+		LIN_SDT_PROBE(emul, em_find, emul_unlock, &emul_lock,
 		    0, 0, 0, 0);
 		EMUL_UNLOCK(&emul_lock);
 	}
 
-	SDT_PROBE(LINUX_DTRACE, emul, em_find, return, em, 0, 0, 0, 0);
+	LIN_SDT_PROBE(emul, em_find, return, em, 0, 0, 0, 0);
 	return (em);
 }
 
@@ -145,7 +157,7 @@ linux_proc_init(struct thread *td, pid_t
 	struct linux_emuldata *em, *p_em;
 	struct proc *p;
 
-	SDT_PROBE(LINUX_DTRACE, emul, proc_init, entry, td, child, flags, 0, 0);
+	LIN_SDT_PROBE(emul, proc_init, entry, td, child, flags, 0, 0);
 
 	if (child != 0) {
 		/* fork or create a thread */
@@ -156,12 +168,12 @@ linux_proc_init(struct thread *td, pid_t
 		em->robust_futexes = NULL;
 		if (flags & LINUX_CLONE_THREAD) {
 			/* handled later in the code */
-			SDT_PROBE(LINUX_DTRACE, emul, proc_init, create_thread,
+			LIN_SDT_PROBE(emul, proc_init, create_thread,
 			    0, 0, 0, 0, 0);
 		} else {
 			struct linux_emuldata_shared *s;
 
-			SDT_PROBE(LINUX_DTRACE, emul, proc_init, fork, 0, 0, 0,
+			LIN_SDT_PROBE(emul, proc_init, fork, 0, 0, 0,
 			    0, 0);
 
 			s = malloc(sizeof *s, M_LINUX, M_WAITOK | M_ZERO);
@@ -174,7 +186,7 @@ linux_proc_init(struct thread *td, pid_t
 	} else {
 		/* exec */
 
-		SDT_PROBE(LINUX_DTRACE, emul, proc_init, exec, 0, 0, 0, 0, 0);
+		LIN_SDT_PROBE(emul, proc_init, exec, 0, 0, 0, 0, 0);
 
 		/* lookup the old one */
 		em = em_find(td->td_proc, EMUL_DOLOCK);
@@ -220,12 +232,12 @@ linux_proc_init(struct thread *td, pid_t
 		p->p_emuldata = em;
 		PROC_UNLOCK(p);
 	} else {
-		SDT_PROBE(LINUX_DTRACE, emul, proc_init, emul_unlock,
+		LIN_SDT_PROBE(emul, proc_init, emul_unlock,
 		    &emul_lock, 0, 0, 0, 0);
 		EMUL_UNLOCK(&emul_lock);
 	}
 
-	SDT_PROBE(LINUX_DTRACE, emul, proc_init, return, 0, 0, 0, 0, 0);
+	LIN_SDT_PROBE(emul, proc_init, return, 0, 0, 0, 0, 0);
 	return (0);
 }
 
@@ -241,7 +253,7 @@ linux_proc_exit(void *arg __unused, stru
 	if (__predict_true(p->p_sysent != &elf_linux_sysvec))
 		return;
 
-	SDT_PROBE(LINUX_DTRACE, emul, proc_exit, entry, p, 0, 0, 0, 0);
+	LIN_SDT_PROBE(emul, proc_exit, entry, p, 0, 0, 0, 0);
 
 	release_futexes(p);
 
@@ -251,12 +263,12 @@ linux_proc_exit(void *arg __unused, stru
 
 	/* reparent all procs that are not a thread leader to initproc */
 	if (em->shared->group_pid != p->p_pid) {
-		SDT_PROBE(LINUX_DTRACE, emul, proc_exit, reparent,
+		LIN_SDT_PROBE(emul, proc_exit, reparent,
 		    em->shared->group_pid, p->p_pid, p, 0, 0);
 
 		child_clear_tid = em->child_clear_tid;
 
-		SDT_PROBE(LINUX_DTRACE, emul, proc_exit, emul_unlock,
+		LIN_SDT_PROBE(emul, proc_exit, emul_unlock,
 		    &emul_lock, 0, 0, 0, 0);
 		EMUL_UNLOCK(&emul_lock);
 
@@ -270,7 +282,7 @@ linux_proc_exit(void *arg __unused, stru
 	} else {
 		child_clear_tid = em->child_clear_tid;
 
-		SDT_PROBE(LINUX_DTRACE, emul, proc_exit, emul_unlock,
+		LIN_SDT_PROBE(emul, proc_exit, emul_unlock,
 		    &emul_lock, 0, 0, 0, 0);
 		EMUL_UNLOCK(&emul_lock);	
 	}
@@ -291,12 +303,12 @@ linux_proc_exit(void *arg __unused, stru
 
 		error = copyout(&null, child_clear_tid, sizeof(null));
 		if (error) {
-			SDT_PROBE(LINUX_DTRACE, emul, proc_exit,
+			LIN_SDT_PROBE(emul, proc_exit,
 			    child_clear_tid_error, error, 0, 0, 0, 0);
 
 			free(em, M_LINUX);
 
-			SDT_PROBE(LINUX_DTRACE, emul, proc_exit, return, 0, 0,
+			LIN_SDT_PROBE(emul, proc_exit, return, 0, 0,
 			    0, 0, 0);
 			return;
 		}
@@ -314,7 +326,7 @@ linux_proc_exit(void *arg __unused, stru
 		 * probably means there is a user space bug
 		 */
 		if (error) {
-			SDT_PROBE(LINUX_DTRACE, emul, proc_exit, futex_failed,
+			LIN_SDT_PROBE(emul, proc_exit, futex_failed,
 			    0, 0, 0, 0, 0);
 			printf(LMSG("futex stuff in proc_exit failed.\n"));
 		}
@@ -339,13 +351,13 @@ linux_proc_exit(void *arg __unused, stru
 			psignal(q, em->pdeath_signal);
 		}
 		PROC_UNLOCK(q);
-		SDT_PROBE(LINUX_DTRACE, emul, proc_exit, emul_unlock,
+		LIN_SDT_PROBE(emul, proc_exit, emul_unlock,
 		    &emul_lock, 0, 0, 0, 0);
 		EMUL_UNLOCK(&emul_lock);
 	}
 	sx_xunlock(&proctree_lock);
 
-	SDT_PROBE(LINUX_DTRACE, emul, proc_exit, return, 0, 0, 0, 0, 0);
+	LIN_SDT_PROBE(emul, proc_exit, return, 0, 0, 0, 0, 0);
 }
 
 /*
@@ -356,11 +368,11 @@ linux_proc_exit(void *arg __unused, stru
 void 
 linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
 {
-	if (__predict_false(imgp->sysent == &elf_linux_sysvec) {
-		SDT_PROBE(LINUX_DTRACE, emul, proc_exec, entry, p, imgp, 0, 0,
+	if (__predict_false(imgp->sysent == &elf_linux_sysvec)) {
+		LIN_SDT_PROBE(emul, proc_exec, entry, p, imgp, 0, 0,
 		    0);
 
-		if (p->p_sysent != &elf_linux_sysvec))
+		if (p->p_sysent != &elf_linux_sysvec)
 			linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0);
 		else {
 			struct linux_emuldata *em;
@@ -393,7 +405,7 @@ linux_proc_exec(void *arg __unused, stru
 			free(em, M_LINUX);
 		}
 
-		SDT_PROBE(LINUX_DTRACE, emul, proc_exec, return, 0, 0, 0, 0, 0);
+		LIN_SDT_PROBE(emul, proc_exec, return, 0, 0, 0, 0, 0);
 	}
 }
 
@@ -407,17 +419,30 @@ linux_schedtail(void *arg __unused, stru
 	if (__predict_true(p->p_sysent != &elf_linux_sysvec))
 		return;
 
+	LIN_SDT_PROBE(emul, linux_schedtail, entry, p, 0, 0, 0, 0);
+
 	/* find the emuldata */
 	em = em_find(p, EMUL_DOLOCK);
 
 	KASSERT(em != NULL, ("linux_schedtail: emuldata not found.\n"));
 	child_set_tid = em->child_set_tid;
+
+	LIN_SDT_PROBE(emul, linux_schedtail, emul_unlock, &emul_lock,
+	    0, 0, 0, 0);
 	EMUL_UNLOCK(&emul_lock);
 
-	if (child_set_tid != NULL)
+	if (child_set_tid != NULL) {
 		error = copyout(&p->p_pid, (int *)child_set_tid,
 		    sizeof(p->p_pid));
 
+		if (error != 0) {
+			LIN_SDT_PROBE(emul, linux_schedtail,
+			    copyout_error, error, 0, 0, 0, 0);
+		}
+	}
+
+	LIN_SDT_PROBE(emul, linux_schedtail, return, 0, 0, 0, 0, 0);
+
 	return;
 }
 
@@ -426,19 +451,21 @@ linux_set_tid_address(struct thread *td,
 {
 	struct linux_emuldata *em;
 
-#ifdef DEBUG
-	if (ldebug(set_tid_address))
-		printf(ARGS(set_tid_address, "%p"), args->tidptr);
-#endif
+	LIN_SDT_PROBE(emul, linux_set_tid_address, entry,
+	    args->tidptr, 0, 0, 0, 0);
 
 	/* find the emuldata */
 	em = em_find(td->td_proc, EMUL_DOLOCK);
-
 	KASSERT(em != NULL, ("set_tid_address: emuldata not found.\n"));
 
 	em->child_clear_tid = args->tidptr;
 	td->td_retval[0] = td->td_proc->p_pid;
 
+	LIN_SDT_PROBE(emul, linux_set_tid_address, emul_unlock,
+	    &emul_lock, 0, 0, 0, 0);
 	EMUL_UNLOCK(&emul_lock);
+
+	LIN_SDT_PROBE(emul, linux_set_tid_address, return, 0, 0, 0,
+	    0, 0);
 	return 0;
 }

Added: user/netchild/linuxulator-dtrace/src/sys/compat/linux/stats_timing.d
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ user/netchild/linuxulator-dtrace/src/sys/compat/linux/stats_timing.d	Thu Nov 27 10:28:26 2008	(r185365)
@@ -0,0 +1,69 @@
+#!/usr/sbin/dtrace -qs
+
+/*-
+ * Copyright (c) 2008 Alexander Leidinger <netchild@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * Some statistics (all per provider):
+ *  - number of calls to a function per executable binary (not per PID!)
+ *    - allows to see where an optimization would be beneficial for a given
+ *      application
+ *  - graph of CPU time spend in functions per executable binary
+ *    - together with the number of calls to this function this allows
+ *      to determine if a kernel optimization would be beneficial / is
+ *      possible for a given application
+ *  - graph of longest running (CPU-time!) function in total
+ *    - may help finding problem cases in the kernel code
+ */
+
+linuxulator*:::entry
+{
+	self->time[funcname] = vtimestamp;
+	@calls[probeprov, execname, probefunc] = count();
+}
+
+linuxulator*:::return
+/self->time[funcname] != 0/
+{
+	this->timediff = self->time[probefunc] - vtimestamp;
+
+	@stats[probeprov, execname, probefunc] = quantize(this->timediff);
+	@longest[probeprov, probefunc] = max(this->timediff);
+	
+	self->time[probefunc] = 0;
+}
+
+END
+{
+	printa("Number of calls per provider/application/kernel function", @calls);
+	printa("CPU-timing statistics per provider/application/kernel function (in ns)", @stats);
+	printa("Longest running (CPU-time!) functions per provider (in ns)", @longest);
+}
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811271028.mARASQNN084460>