xref: /onnv-gate/usr/src/uts/common/tnf/tnf_res.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate /*
30*0Sstevel@tonic-gate  * "Resident" part of TNF -- this has to be around even when the
31*0Sstevel@tonic-gate  * driver is not loaded.
32*0Sstevel@tonic-gate  */
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #ifndef NPROBE
35*0Sstevel@tonic-gate #include <sys/types.h>
36*0Sstevel@tonic-gate #include <sys/systm.h>
37*0Sstevel@tonic-gate #include <sys/thread.h>
38*0Sstevel@tonic-gate #include <sys/klwp.h>
39*0Sstevel@tonic-gate #include <sys/proc.h>
40*0Sstevel@tonic-gate #include <sys/kmem.h>
41*0Sstevel@tonic-gate #include <sys/msacct.h>
42*0Sstevel@tonic-gate #include <sys/tnf_com.h>
43*0Sstevel@tonic-gate #include <sys/tnf_writer.h>
44*0Sstevel@tonic-gate #include <sys/tnf_probe.h>
45*0Sstevel@tonic-gate #include <sys/tnf.h>
46*0Sstevel@tonic-gate #include <sys/debug.h>
47*0Sstevel@tonic-gate #include <sys/modctl.h>
48*0Sstevel@tonic-gate #include <sys/kobj.h>
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate #include "tnf_buf.h"
51*0Sstevel@tonic-gate #include "tnf_types.h"
52*0Sstevel@tonic-gate #include "tnf_trace.h"
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /*
55*0Sstevel@tonic-gate  * Defines
56*0Sstevel@tonic-gate  */
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate #define	TNF_PC_COUNT	8
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate /*
61*0Sstevel@tonic-gate  * Declarations
62*0Sstevel@tonic-gate  */
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate /*
65*0Sstevel@tonic-gate  * TNF kernel probe management externs
66*0Sstevel@tonic-gate  */
67*0Sstevel@tonic-gate extern tnf_probe_control_t	*__tnf_probe_list_head;
68*0Sstevel@tonic-gate extern tnf_tag_data_t		*__tnf_tag_list_head;
69*0Sstevel@tonic-gate extern int			tnf_changed_probe_list;
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate /*
72*0Sstevel@tonic-gate  * This makes the state of the TNFW_B_STOPPED bit externally visible
73*0Sstevel@tonic-gate  * in the kernel.
74*0Sstevel@tonic-gate  */
75*0Sstevel@tonic-gate volatile int tnf_tracing_active = 0;
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate /*
78*0Sstevel@tonic-gate  * The trace buffer pointer
79*0Sstevel@tonic-gate  */
80*0Sstevel@tonic-gate caddr_t tnf_buf;
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /*
83*0Sstevel@tonic-gate  * Stub definitions for tag data pointers
84*0Sstevel@tonic-gate  */
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate /* tnf_writer module */
87*0Sstevel@tonic-gate tnf_tag_data_t *tnf_inline_tag_data = NULL;
88*0Sstevel@tonic-gate tnf_tag_data_t *tnf_tagged_tag_data = NULL;
89*0Sstevel@tonic-gate tnf_tag_data_t *tnf_scalar_tag_data = NULL;
90*0Sstevel@tonic-gate tnf_tag_data_t *tnf_char_tag_data = NULL;
91*0Sstevel@tonic-gate tnf_tag_data_t *tnf_int8_tag_data = NULL;
92*0Sstevel@tonic-gate tnf_tag_data_t *tnf_uint8_tag_data = NULL;
93*0Sstevel@tonic-gate tnf_tag_data_t *tnf_int16_tag_data = NULL;
94*0Sstevel@tonic-gate tnf_tag_data_t *tnf_uint16_tag_data = NULL;
95*0Sstevel@tonic-gate tnf_tag_data_t *tnf_int32_tag_data = NULL;
96*0Sstevel@tonic-gate tnf_tag_data_t *tnf_uint32_tag_data = NULL;
97*0Sstevel@tonic-gate tnf_tag_data_t *tnf_int64_tag_data = NULL;
98*0Sstevel@tonic-gate tnf_tag_data_t *tnf_uint64_tag_data = NULL;
99*0Sstevel@tonic-gate tnf_tag_data_t *tnf_float32_tag_data = NULL;
100*0Sstevel@tonic-gate tnf_tag_data_t *tnf_float64_tag_data = NULL;
101*0Sstevel@tonic-gate tnf_tag_data_t *tnf_array_tag_data = NULL;
102*0Sstevel@tonic-gate tnf_tag_data_t *tnf_string_tag_data = NULL;
103*0Sstevel@tonic-gate tnf_tag_data_t *tnf_type_array_tag_data = NULL;
104*0Sstevel@tonic-gate tnf_tag_data_t *tnf_name_array_tag_data = NULL;
105*0Sstevel@tonic-gate tnf_tag_data_t *tnf_derived_tag_data = NULL;
106*0Sstevel@tonic-gate tnf_tag_data_t *tnf_align_tag_data = NULL;
107*0Sstevel@tonic-gate tnf_tag_data_t *tnf_derived_base_tag_data = NULL;
108*0Sstevel@tonic-gate tnf_tag_data_t *tnf_element_type_tag_data = NULL;
109*0Sstevel@tonic-gate tnf_tag_data_t *tnf_header_size_tag_data = NULL;
110*0Sstevel@tonic-gate tnf_tag_data_t *tnf_name_tag_data = NULL;
111*0Sstevel@tonic-gate tnf_tag_data_t *tnf_opaque_tag_data = NULL;
112*0Sstevel@tonic-gate tnf_tag_data_t *tnf_properties_tag_data = NULL;
113*0Sstevel@tonic-gate tnf_tag_data_t *tnf_self_size_tag_data = NULL;
114*0Sstevel@tonic-gate tnf_tag_data_t *tnf_size_tag_data = NULL;
115*0Sstevel@tonic-gate tnf_tag_data_t *tnf_slot_names_tag_data = NULL;
116*0Sstevel@tonic-gate tnf_tag_data_t *tnf_slot_types_tag_data = NULL;
117*0Sstevel@tonic-gate tnf_tag_data_t *tnf_tag_tag_data = NULL;
118*0Sstevel@tonic-gate tnf_tag_data_t *tnf_tag_arg_tag_data = NULL;
119*0Sstevel@tonic-gate tnf_tag_data_t *tnf_type_size_tag_data = NULL;
120*0Sstevel@tonic-gate tnf_tag_data_t *tnf_struct_tag_data = NULL;
121*0Sstevel@tonic-gate tnf_tag_data_t *tnf_file_header_tag_data = NULL;
122*0Sstevel@tonic-gate tnf_tag_data_t *tnf_block_header_tag_data = NULL;
123*0Sstevel@tonic-gate tnf_tag_data_t *tnf_type_tag_data = NULL;
124*0Sstevel@tonic-gate tnf_tag_data_t *tnf_array_type_tag_data = NULL;
125*0Sstevel@tonic-gate tnf_tag_data_t *tnf_derived_type_tag_data = NULL;
126*0Sstevel@tonic-gate tnf_tag_data_t *tnf_scalar_type_tag_data = NULL;
127*0Sstevel@tonic-gate tnf_tag_data_t *tnf_struct_type_tag_data = NULL;
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate /* tnf_trace module */
130*0Sstevel@tonic-gate tnf_tag_data_t *tnf_probe_event_tag_data = NULL;
131*0Sstevel@tonic-gate tnf_tag_data_t *tnf_time_base_tag_data = NULL;
132*0Sstevel@tonic-gate tnf_tag_data_t *tnf_time_delta_tag_data = NULL;
133*0Sstevel@tonic-gate tnf_tag_data_t *tnf_pid_tag_data = NULL;
134*0Sstevel@tonic-gate tnf_tag_data_t *tnf_lwpid_tag_data = NULL;
135*0Sstevel@tonic-gate tnf_tag_data_t *tnf_kthread_id_tag_data = NULL;
136*0Sstevel@tonic-gate tnf_tag_data_t *tnf_cpuid_tag_data = NULL;
137*0Sstevel@tonic-gate tnf_tag_data_t *tnf_device_tag_data = NULL;
138*0Sstevel@tonic-gate tnf_tag_data_t *tnf_symbol_tag_data = NULL;
139*0Sstevel@tonic-gate tnf_tag_data_t *tnf_symbols_tag_data = NULL;
140*0Sstevel@tonic-gate tnf_tag_data_t *tnf_sysnum_tag_data = NULL;
141*0Sstevel@tonic-gate tnf_tag_data_t *tnf_microstate_tag_data = NULL;
142*0Sstevel@tonic-gate tnf_tag_data_t *tnf_offset_tag_data = NULL;
143*0Sstevel@tonic-gate tnf_tag_data_t *tnf_fault_type_tag_data = NULL;
144*0Sstevel@tonic-gate tnf_tag_data_t *tnf_seg_access_tag_data = NULL;
145*0Sstevel@tonic-gate tnf_tag_data_t *tnf_bioflags_tag_data = NULL;
146*0Sstevel@tonic-gate tnf_tag_data_t *tnf_diskaddr_tag_data = NULL;
147*0Sstevel@tonic-gate tnf_tag_data_t *tnf_kernel_schedule_tag_data = NULL;
148*0Sstevel@tonic-gate 
149*0Sstevel@tonic-gate tnf_tag_data_t *tnf_probe_type_tag_data = NULL;
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate /* Exported properties */
152*0Sstevel@tonic-gate tnf_tag_data_t	***tnf_user_struct_properties = NULL;
153*0Sstevel@tonic-gate 
154*0Sstevel@tonic-gate /*
155*0Sstevel@tonic-gate  * tnf_thread_create()
156*0Sstevel@tonic-gate  * Called from thread_create() to initialize thread's tracing state.
157*0Sstevel@tonic-gate  * XXX Do this when tracing is first turned on
158*0Sstevel@tonic-gate  */
159*0Sstevel@tonic-gate 
160*0Sstevel@tonic-gate void
tnf_thread_create(kthread_t * t)161*0Sstevel@tonic-gate tnf_thread_create(kthread_t *t)
162*0Sstevel@tonic-gate {
163*0Sstevel@tonic-gate 	/* If the allocation fails, this thread doesn't trace */
164*0Sstevel@tonic-gate 	t->t_tnf_tpdp = kmem_zalloc(sizeof (tnf_ops_t), KM_NOSLEEP);
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate 	TNF_PROBE_3(thread_create, "thread", /* CSTYLED */,
167*0Sstevel@tonic-gate 		tnf_kthread_id,	tid,		t,
168*0Sstevel@tonic-gate 		tnf_pid,	pid,		ttoproc(t)->p_pid,
169*0Sstevel@tonic-gate 		tnf_symbol,	start_pc,	t->t_startpc);
170*0Sstevel@tonic-gate }
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate /*
173*0Sstevel@tonic-gate  * tnf_thread_exit()
174*0Sstevel@tonic-gate  * Called from thread_exit() and lwp_exit() if thread has a tpdp.
175*0Sstevel@tonic-gate  * From this point on, we're off the allthreads list
176*0Sstevel@tonic-gate  */
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate void
tnf_thread_exit(void)179*0Sstevel@tonic-gate tnf_thread_exit(void)
180*0Sstevel@tonic-gate {
181*0Sstevel@tonic-gate 	tnf_ops_t *ops;
182*0Sstevel@tonic-gate 	tnf_block_header_t *block;
183*0Sstevel@tonic-gate 
184*0Sstevel@tonic-gate 	TNF_PROBE_0(thread_exit, "thread", /* CSTYLED */);
185*0Sstevel@tonic-gate         /* LINTED pointer cast may result in improper alignment */
186*0Sstevel@tonic-gate 	ops = (tnf_ops_t *)curthread->t_tnf_tpdp;
187*0Sstevel@tonic-gate 	/*
188*0Sstevel@tonic-gate 	 * Mark ops as busy from now on, so it will never be used
189*0Sstevel@tonic-gate 	 * again.  If we fail on the busy lock, the buffer
190*0Sstevel@tonic-gate 	 * deallocation code is cleaning our ops, so we don't need to
191*0Sstevel@tonic-gate 	 * do anything.  If we get the lock and the buffer exists,
192*0Sstevel@tonic-gate 	 * release all blocks we hold.  Once we're off allthreads,
193*0Sstevel@tonic-gate 	 * the deallocator will not examine our ops.
194*0Sstevel@tonic-gate 	 */
195*0Sstevel@tonic-gate 	if (ops->busy)
196*0Sstevel@tonic-gate 		return;
197*0Sstevel@tonic-gate 	LOCK_INIT_HELD(&ops->busy);
198*0Sstevel@tonic-gate 	if (tnf_buf != NULL) {
199*0Sstevel@tonic-gate 		/* Release any A-locks held */
200*0Sstevel@tonic-gate 		block = ops->wcb.tnfw_w_pos.tnfw_w_block;
201*0Sstevel@tonic-gate 		ops->wcb.tnfw_w_pos.tnfw_w_block = NULL;
202*0Sstevel@tonic-gate 		if (block != NULL)
203*0Sstevel@tonic-gate 			lock_clear(&block->A_lock);
204*0Sstevel@tonic-gate 		block = ops->wcb.tnfw_w_tag_pos.tnfw_w_block;
205*0Sstevel@tonic-gate 		ops->wcb.tnfw_w_tag_pos.tnfw_w_block = NULL;
206*0Sstevel@tonic-gate 		if (block != NULL)
207*0Sstevel@tonic-gate 			lock_clear(&block->A_lock);
208*0Sstevel@tonic-gate 	}
209*0Sstevel@tonic-gate }
210*0Sstevel@tonic-gate 
211*0Sstevel@tonic-gate /*
212*0Sstevel@tonic-gate  * Called from thread_free() if thread has tpdp.
213*0Sstevel@tonic-gate  */
214*0Sstevel@tonic-gate 
215*0Sstevel@tonic-gate void
tnf_thread_free(kthread_t * t)216*0Sstevel@tonic-gate tnf_thread_free(kthread_t *t)
217*0Sstevel@tonic-gate {
218*0Sstevel@tonic-gate 	tnf_ops_t *ops;
219*0Sstevel@tonic-gate 	/* LINTED pointer cast may result in improper alignment */
220*0Sstevel@tonic-gate 	ops = (tnf_ops_t *)t->t_tnf_tpdp;
221*0Sstevel@tonic-gate 	t->t_tnf_tpdp = NULL;
222*0Sstevel@tonic-gate 	kmem_free(ops, sizeof (*ops));
223*0Sstevel@tonic-gate }
224*0Sstevel@tonic-gate 
225*0Sstevel@tonic-gate /*
226*0Sstevel@tonic-gate  * tnf_thread_queue()
227*0Sstevel@tonic-gate  * Probe wrapper called when tracing is enabled and a thread is
228*0Sstevel@tonic-gate  * placed on some dispatch queue.
229*0Sstevel@tonic-gate  */
230*0Sstevel@tonic-gate 
231*0Sstevel@tonic-gate void
tnf_thread_queue(kthread_t * t,cpu_t * cp,pri_t tpri)232*0Sstevel@tonic-gate tnf_thread_queue(kthread_t *t, cpu_t *cp, pri_t tpri)
233*0Sstevel@tonic-gate {
234*0Sstevel@tonic-gate 	TNF_PROBE_4(thread_queue, "dispatcher", /* CSTYLED */,
235*0Sstevel@tonic-gate 		tnf_kthread_id,		tid,		t,
236*0Sstevel@tonic-gate 		tnf_cpuid,		cpuid,		cp->cpu_id,
237*0Sstevel@tonic-gate 		tnf_long,		priority,	tpri,
238*0Sstevel@tonic-gate 		tnf_ulong,		queue_length,
239*0Sstevel@tonic-gate 			/* cp->cpu_disp->disp_q[tpri].dq_sruncnt */
240*0Sstevel@tonic-gate 			cp->cpu_disp->disp_nrunnable);
241*0Sstevel@tonic-gate 
242*0Sstevel@tonic-gate 	TNF_PROBE_2(thread_state, "thread", /* CSTYLED */,
243*0Sstevel@tonic-gate 		tnf_kthread_id,		tid,		t,
244*0Sstevel@tonic-gate 		tnf_microstate,		state,		LMS_WAIT_CPU);
245*0Sstevel@tonic-gate }
246*0Sstevel@tonic-gate 
247*0Sstevel@tonic-gate /*
248*0Sstevel@tonic-gate  * pcstack(): fill in, NULL-terminate and return pc stack.
249*0Sstevel@tonic-gate  */
250*0Sstevel@tonic-gate 
251*0Sstevel@tonic-gate static pc_t *
pcstack(pc_t * pcs)252*0Sstevel@tonic-gate pcstack(pc_t *pcs)
253*0Sstevel@tonic-gate {
254*0Sstevel@tonic-gate 	uint_t n;
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate 	n = getpcstack(pcs, TNF_PC_COUNT);
257*0Sstevel@tonic-gate 	pcs[n] = 0;
258*0Sstevel@tonic-gate 	return (pcs);
259*0Sstevel@tonic-gate }
260*0Sstevel@tonic-gate 
261*0Sstevel@tonic-gate /*
262*0Sstevel@tonic-gate  * tnf_thread_switch()
263*0Sstevel@tonic-gate  * Probe wrapper called when tracing enabled and curthread is about to
264*0Sstevel@tonic-gate  * switch to the next thread.
265*0Sstevel@tonic-gate  * XXX Simple sleepstate and runstate calculations
266*0Sstevel@tonic-gate  */
267*0Sstevel@tonic-gate 
268*0Sstevel@tonic-gate #define	SLPSTATE(t, ts)					\
269*0Sstevel@tonic-gate 	(((ts) == TS_STOPPED) ? LMS_STOPPED :		\
270*0Sstevel@tonic-gate 	    ((t)->t_wchan0 ? LMS_USER_LOCK : LMS_SLEEP))
271*0Sstevel@tonic-gate 
272*0Sstevel@tonic-gate #define	RUNSTATE(next, lwp)				\
273*0Sstevel@tonic-gate 	((((lwp = ttolwp(next)) != NULL) &&		\
274*0Sstevel@tonic-gate 		lwp->lwp_state == LWP_USER) ?		\
275*0Sstevel@tonic-gate 		LMS_USER : LMS_SYSTEM)
276*0Sstevel@tonic-gate 
277*0Sstevel@tonic-gate void
tnf_thread_switch(kthread_t * next)278*0Sstevel@tonic-gate tnf_thread_switch(kthread_t *next)
279*0Sstevel@tonic-gate {
280*0Sstevel@tonic-gate 	kthread_t	*t;
281*0Sstevel@tonic-gate 	klwp_t		*lwp;
282*0Sstevel@tonic-gate 	caddr_t		ztpdp;
283*0Sstevel@tonic-gate 	int		borrow;
284*0Sstevel@tonic-gate 	uint_t		ts;
285*0Sstevel@tonic-gate 	pc_t		pcs[TNF_PC_COUNT + 1];
286*0Sstevel@tonic-gate 
287*0Sstevel@tonic-gate 	t = curthread;
288*0Sstevel@tonic-gate 	ts = t->t_state;
289*0Sstevel@tonic-gate 
290*0Sstevel@tonic-gate 	/*
291*0Sstevel@tonic-gate 	 * If we're a zombie, borrow idle thread's tpdp.  This lets
292*0Sstevel@tonic-gate 	 * the driver decide whether the buffer is busy by examining
293*0Sstevel@tonic-gate 	 * allthreads (idle threads are always on the list).
294*0Sstevel@tonic-gate 	 */
295*0Sstevel@tonic-gate 	if ((borrow = (ts == TS_ZOMB)) != 0) {
296*0Sstevel@tonic-gate 		ztpdp = t->t_tnf_tpdp;
297*0Sstevel@tonic-gate 		t->t_tnf_tpdp = CPU->cpu_idle_thread->t_tnf_tpdp;
298*0Sstevel@tonic-gate 		goto do_next;
299*0Sstevel@tonic-gate 	}
300*0Sstevel@tonic-gate 
301*0Sstevel@tonic-gate 	/*
302*0Sstevel@tonic-gate 	 * If we're blocked, test the blockage probe
303*0Sstevel@tonic-gate 	 */
304*0Sstevel@tonic-gate 	if (ts == TS_SLEEP && t->t_wchan)
305*0Sstevel@tonic-gate #if defined(__sparc)
306*0Sstevel@tonic-gate 		TNF_PROBE_2(thread_block, "synch", /* CSTYLED */,
307*0Sstevel@tonic-gate 		    tnf_opaque,	  reason,	t->t_wchan,
308*0Sstevel@tonic-gate 		    tnf_symbols,  stack,	(pc_t *)pcstack(pcs));
309*0Sstevel@tonic-gate #else /* defined(__sparc) */
310*0Sstevel@tonic-gate 		TNF_PROBE_2(thread_block, "synch", /* CSTYLED */,
311*0Sstevel@tonic-gate 		    tnf_opaque,   reason,	t->t_wchan,
312*0Sstevel@tonic-gate 		    tnf_symbols,  stack,	(tnf_opaque_t *)pcstack(pcs));
313*0Sstevel@tonic-gate #endif /* defined(__sparc) */
314*0Sstevel@tonic-gate 
315*0Sstevel@tonic-gate 	/*
316*0Sstevel@tonic-gate 	 * Record outgoing thread's state
317*0Sstevel@tonic-gate 	 * Kernel thread ID is implicit in schedule record
318*0Sstevel@tonic-gate 	 * supress lint: cast from 32-bit integer to 8-bit integer
319*0Sstevel@tonic-gate 	 * tnf_microstate_t = tnf_uint8_t
320*0Sstevel@tonic-gate 	 */
321*0Sstevel@tonic-gate #if defined(_LP64)
322*0Sstevel@tonic-gate 	/* LINTED */
323*0Sstevel@tonic-gate 	TNF_PROBE_1(thread_state, "thread", /* CSTYLED */,
324*0Sstevel@tonic-gate 	    tnf_microstate,	state,		SLPSTATE(t, ts));
325*0Sstevel@tonic-gate #else
326*0Sstevel@tonic-gate 	TNF_PROBE_1(thread_state, "thread", /* CSTYLED */,
327*0Sstevel@tonic-gate 		tnf_microstate,	state,	SLPSTATE(t, ts));
328*0Sstevel@tonic-gate #endif
329*0Sstevel@tonic-gate 
330*0Sstevel@tonic-gate do_next:
331*0Sstevel@tonic-gate 	/*
332*0Sstevel@tonic-gate 	 * Record incoming thread's state
333*0Sstevel@tonic-gate 	 *
334*0Sstevel@tonic-gate 	 * supress lint: cast from 32-bit integer to 8-bit integer
335*0Sstevel@tonic-gate 	 * tnf_microstate_t = tnf_uint8_t
336*0Sstevel@tonic-gate 	 */
337*0Sstevel@tonic-gate #if defined(_LP64)
338*0Sstevel@tonic-gate 	/* LINTED */
339*0Sstevel@tonic-gate 	TNF_PROBE_2(thread_state, "thread", /* CSTYLED */,
340*0Sstevel@tonic-gate 	    tnf_kthread_id,	tid,		next,
341*0Sstevel@tonic-gate 	    tnf_microstate,	state,		RUNSTATE(next, lwp));
342*0Sstevel@tonic-gate #else
343*0Sstevel@tonic-gate 	TNF_PROBE_2(thread_state, "thread", /* CSTYLED */,
344*0Sstevel@tonic-gate 		tnf_kthread_id,	tid,	next,
345*0Sstevel@tonic-gate 		tnf_microstate,	state,	RUNSTATE(next, lwp));
346*0Sstevel@tonic-gate #endif
347*0Sstevel@tonic-gate 
348*0Sstevel@tonic-gate 	/*
349*0Sstevel@tonic-gate 	 * If we borrowed idle thread's tpdp above, restore the zombies
350*0Sstevel@tonic-gate 	 * tpdp so that it will be freed from tnf_thread_free().
351*0Sstevel@tonic-gate 	 */
352*0Sstevel@tonic-gate 	if (borrow)
353*0Sstevel@tonic-gate 		t->t_tnf_tpdp = ztpdp;
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate }
356*0Sstevel@tonic-gate 
357*0Sstevel@tonic-gate #endif	/* NPROBE */
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate /*
360*0Sstevel@tonic-gate  * tnf_mod_load (and tnf_mod_unload), when called from a client module's _init
361*0Sstevel@tonic-gate  * (and _fini) entry points are insufficient mechanisms for maintaining the
362*0Sstevel@tonic-gate  * consistency of __tnf_probe_list_head and __tnf_tag_list_head whenever that
363*0Sstevel@tonic-gate  * module is loaded or unloaded.  The problem occurs because loading a module,
364*0Sstevel@tonic-gate  * at which time the modules probes are linked into the two lists, and
365*0Sstevel@tonic-gate  * installing that module are separate operations.  This means that it is
366*0Sstevel@tonic-gate  * possible for a module to be loaded, not installed, and unloaded without
367*0Sstevel@tonic-gate  * calling _init and _fini.  If the module contains TNF probes, the probe and
368*0Sstevel@tonic-gate  * tag lists will contain references to data addresses freed when the module
369*0Sstevel@tonic-gate  * is unloaded.
370*0Sstevel@tonic-gate  *
371*0Sstevel@tonic-gate  * The implemented solution for maintaining the lists is to perform the
372*0Sstevel@tonic-gate  * unsplicing when the module is unloaded. (Splicing into the lists, "probe
373*0Sstevel@tonic-gate  * discovery", is done when krtld processes relocation references when it
374*0Sstevel@tonic-gate  * loads the module; this information is not available for subsequent
375*0Sstevel@tonic-gate  * operations on the module.
376*0Sstevel@tonic-gate  */
377*0Sstevel@tonic-gate int
tnf_mod_load()378*0Sstevel@tonic-gate tnf_mod_load()
379*0Sstevel@tonic-gate {
380*0Sstevel@tonic-gate 	return (0);
381*0Sstevel@tonic-gate }
382*0Sstevel@tonic-gate 
383*0Sstevel@tonic-gate /* ARGSUSED */
384*0Sstevel@tonic-gate int
tnf_mod_unload(struct modlinkage * mlp)385*0Sstevel@tonic-gate tnf_mod_unload(struct modlinkage *mlp)
386*0Sstevel@tonic-gate {
387*0Sstevel@tonic-gate 	return (0);
388*0Sstevel@tonic-gate }
389