PERFORCE change 127810 for review
John Birrell
jb at FreeBSD.org
Fri Oct 19 21:09:38 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=127810
Change 127810 by jb at 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);
More information about the p4-projects
mailing list