From owner-p4-projects@FreeBSD.ORG Thu Sep 27 10:15:48 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 28A9916A421; Thu, 27 Sep 2007 10:15:48 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8C5016A41B for ; Thu, 27 Sep 2007 10:15:47 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id B2A1613C45A for ; Thu, 27 Sep 2007 10:15:47 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l8RAFlIR093028 for ; Thu, 27 Sep 2007 10:15:47 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l8RAFllA093025 for perforce@freebsd.org; Thu, 27 Sep 2007 10:15:47 GMT (envelope-from jb@freebsd.org) Date: Thu, 27 Sep 2007 10:15:47 GMT Message-Id: <200709271015.l8RAFllA093025@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 126860 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Sep 2007 10:15:48 -0000 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 #include #include +#include #include #include #include @@ -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);