Date: Thu, 27 Sep 2007 10:15:47 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 126860 for review Message-ID: <200709271015.l8RAFllA093025@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=126860 Change 126860 by jb@jb_freebsd1 on 2007/09/27 10:14:48 Hi-ho, hi-ho, it's obfuscate we go. In mi_startup, get the traditional size of 'struct thread', including the 'struct td_sched' using sched_sizeof_thread(). That's the offset to the start of the DTrace-specific thread data. The overall size of that is saved in kdtrace_thread_size which is used in each call to uma_zcreate() when a thread is allocated. Affected files ... .. //depot/projects/dtrace/src/sys/kern/init_main.c#14 edit Differences ... ==== //depot/projects/dtrace/src/sys/kern/init_main.c#14 (text+ko) ==== @@ -60,6 +60,7 @@ #include <sys/syscallsubr.h> #include <sys/sysctl.h> #include <sys/proc.h> +#include <sys/kdtrace.h> #include <sys/resourcevar.h> #include <sys/systm.h> #include <sys/signalvar.h> @@ -98,6 +99,15 @@ struct vmspace vmspace0; struct proc *initproc; +/* DTrace data for the primary thread in proc0. */ +char kdtrace_thread0[KDTRACE_THREAD_SIZE]; + +/* Offset from 'struct thread *' to the opaque DTrace fields. */ +int kdtrace_thread_offset; + +/* Overall per-thread allocation size. */ +int kdtrace_thread_size; + int boothowto = 0; /* initialized so that it can be patched */ SYSCTL_INT(_debug, OID_AUTO, boothowto, CTLFLAG_RD, &boothowto, 0, ""); int bootverbose; @@ -177,6 +187,18 @@ int verbose; #endif + /* Get the size of 'struct thread' plus 'struct td_sched' */ + kdtrace_thread_offset = sched_sizeof_thread(); + + /* + * Allow for the DTrace-specific thread data after + * struct td_sched. This space is allocated opaquely to + * avoid license issues. The value of KDTRACE_THREAD_SIZE + * set in sys/proc.h must be larger than that required by + * the DTrace kernel modules. + */ + kdtrace_thread_size = kdtrace_thread_offset + KDTRACE_THREAD_SIZE; + if (sysinit == NULL) { sysinit = SET_BEGIN(sysinit_set); sysinit_end = SET_LIMIT(sysinit_set);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709271015.l8RAFllA093025>