From owner-p4-projects@FreeBSD.ORG Sat Oct 20 04:09:38 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 44FD016A468; Sat, 20 Oct 2007 04:09:38 +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 DFD2E16A420 for ; Sat, 20 Oct 2007 04:09:37 +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 ACC9513C469 for ; Sat, 20 Oct 2007 04:09:37 +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 l9K49bZo034053 for ; Sat, 20 Oct 2007 04:09:37 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l9K49bpu034050 for perforce@freebsd.org; Sat, 20 Oct 2007 04:09:37 GMT (envelope-from jb@freebsd.org) Date: Sat, 20 Oct 2007 04:09:37 GMT Message-Id: <200710200409.l9K49bpu034050@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 127810 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: Sat, 20 Oct 2007 04:09:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=127810 Change 127810 by jb@jb_freebsd1 on 2007/10/20 04:09:01 Allocate extra thread space opaquely. Affected files ... .. //depot/projects/dtrace6/src/sys/kern/init_main.c#2 edit .. //depot/projects/dtrace6/src/sys/kern/kern_thread.c#3 edit .. //depot/projects/dtrace6/src/sys/sys/proc.h#4 edit Differences ... ==== //depot/projects/dtrace6/src/sys/kern/init_main.c#2 (text+ko) ==== @@ -98,6 +98,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 +186,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); ==== //depot/projects/dtrace6/src/sys/kern/kern_thread.c#3 (text+ko) ==== @@ -303,7 +303,7 @@ mtx_init(&tid_lock, "TID lock", NULL, MTX_DEF); tid_unrhdr = new_unrhdr(PID_MAX + 1, INT_MAX, &tid_lock); - thread_zone = uma_zcreate("THREAD", sched_sizeof_thread(), + thread_zone = uma_zcreate("THREAD", kdtrace_thread_size, thread_ctor, thread_dtor, thread_init, thread_fini, THREAD_ALIGN - 1, 0); ksegrp_zone = uma_zcreate("KSEGRP", sched_sizeof_ksegrp(), ==== //depot/projects/dtrace6/src/sys/sys/proc.h#4 (text+ko) ==== @@ -860,6 +860,21 @@ extern u_long ps_arg_cache_limit; extern int sched_quantum; /* Scheduling quantum in ticks. */ +/* + * Space to append to struct thread for DTrace specific thread + * variables. This space is after the 'struct td_sched'. + */ +#define KDTRACE_THREAD_SIZE 128 + +/* Offset from 'struct thread *' to the opaque DTrace fields. */ +extern int kdtrace_thread_offset; + +/* Overall per-thread allocation size. */ +extern int kdtrace_thread_size; + +/* DTrace data for the primary thread in proc0. */ +extern char kdtrace_thread0[]; + LIST_HEAD(proclist, proc); TAILQ_HEAD(procqueue, proc); TAILQ_HEAD(threadqueue, thread);