Date: Sat, 26 Jan 2008 22:27:33 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 134154 for review Message-ID: <200801262227.m0QMRXEW069308@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134154 Change 134154 by jb@jb_freebsd1 on 2008/01/26 22:26:53 Add some fasttrap hooks for fork/exec/exit in pursuit of the pid provider. Affected files ... .. //depot/projects/dtrace/src/sys/kern/kern_exec.c#24 edit .. //depot/projects/dtrace/src/sys/kern/kern_exit.c#17 edit .. //depot/projects/dtrace/src/sys/kern/kern_fork.c#27 edit .. //depot/projects/dtrace/src/sys/sys/dtrace_bsd.h#12 edit Differences ... ==== //depot/projects/dtrace/src/sys/kern/kern_exec.c#24 (text+ko) ==== @@ -85,6 +85,11 @@ #include <security/audit/audit.h> #include <security/mac/mac_framework.h> +#ifdef KDTRACE_HOOKS +#include <sys/dtrace_bsd.h> +dtrace_execexit_func_t dtrace_fasttrap_exec; +#endif + SDT_PROVIDER_DECLARE(proc); SDT_PROBE_DEFINE(proc, kernel, , exec); SDT_PROBE_ARGTYPE(proc, kernel, , exec, 0, "char *"); @@ -668,6 +673,13 @@ p->p_textvp = ndp->ni_vp; /* + * Tell the DTrace fasttrap provider about the exec if it + * has declared an interest. + */ + if (dtrace_fasttrap_exec) + dtrace_fasttrap_exec(p); + + /* * Notify others that we exec'd, and clear the P_INEXEC flag * as we're now a bona fide freshly-execed process. */ @@ -729,6 +741,7 @@ vfs_mark_atime(imgp->vp, td); done1: + /* * Free any resources malloc'd earlier that we didn't use. */ ==== //depot/projects/dtrace/src/sys/kern/kern_exit.c#17 (text+ko) ==== @@ -84,6 +84,11 @@ #include <vm/vm_page.h> #include <vm/uma.h> +#ifdef KDTRACE_HOOKS +#include <sys/dtrace_bsd.h> +dtrace_execexit_func_t dtrace_fasttrap_exit; +#endif + SDT_PROVIDER_DECLARE(proc); SDT_PROBE_DEFINE(proc, kernel, , exit); SDT_PROBE_ARGTYPE(proc, kernel, , exit, 0, "int"); @@ -454,6 +459,14 @@ PROC_LOCK(p); p->p_xstat = rv; p->p_xthread = td; + + /* + * Tell the DTrace fasttrap provider about the exit if it + * has declared an interest. + */ + if (dtrace_fasttrap_exit) + dtrace_fasttrap_exit(p); + /* * Notify interested parties of our demise. */ ==== //depot/projects/dtrace/src/sys/kern/kern_fork.c#27 (text+ko) ==== @@ -77,6 +77,11 @@ #include <vm/vm_extern.h> #include <vm/uma.h> +#ifdef KDTRACE_HOOKS +#include <sys/dtrace_bsd.h> +dtrace_fork_func_t dtrace_fasttrap_fork; +#endif + SDT_PROVIDER_DECLARE(proc); SDT_PROBE_DEFINE(proc, kernel, , create); SDT_PROBE_ARGTYPE(proc, kernel, , create, 0, "struct proc *"); @@ -635,6 +640,13 @@ } /* + * Tell the DTrace fasttrap provider about the new process + * if it has registered an interest. + */ + if (dtrace_fasttrap_fork) + dtrace_fasttrap_fork(p1, p2); + + /* * This begins the section where we must prevent the parent * from being swapped. */ ==== //depot/projects/dtrace/src/sys/sys/dtrace_bsd.h#12 (text+ko) ==== @@ -72,6 +72,19 @@ extern int dtrace_vtime_active; extern dtrace_vtime_switch_func_t dtrace_vtime_switch_func; +/* The fasttrap module hooks into the fork, exit and exit. */ +typedef void (*dtrace_fork_func_t)(struct proc *, struct proc *); +typedef void (*dtrace_execexit_func_t)(struct proc *); + +/* Global variable in kern_fork.c */ +extern dtrace_fork_func_t dtrace_fasttrap_fork; + +/* Global variable in kern_exec.c */ +extern dtrace_execexit_func_t dtrace_fasttrap_exec; + +/* Global variable in kern_exit.c */ +extern dtrace_execexit_func_t dtrace_fasttrap_exit; + /* * Functions which allow the dtrace module to check that the kernel * hooks have been compiled with sufficient space for it's private
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801262227.m0QMRXEW069308>