7054 dmu_tx_hold_t should use refcount_t to track space
[unleashed.git] / usr / src / uts / common / tnf / trace_init.c
blob17b98a4e23d7c1ff0d3eaa8bced65e532ee060c5
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1994-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Includes
33 #include <sys/types.h>
34 #include <sys/param.h>
35 #include <sys/debug.h>
36 #include <sys/tnf.h>
37 #include <sys/thread.h>
38 #include <sys/dtrace.h>
40 #include "tnf_buf.h"
41 #include "tnf_types.h"
42 #include "tnf_trace.h"
44 #ifndef NPROBE
47 * Globals
50 size_t tnf_trace_file_size = TNF_TRACE_FILE_DEFAULT;
53 * tnf_trace_on
55 void
56 tnf_trace_on(void)
58 TNFW_B_UNSET_STOPPED(tnfw_b_state);
59 tnf_tracing_active = 1;
60 dtrace_vtime_enable_tnf();
61 /* Enable system call tracing for all processes */
62 set_all_proc_sys();
66 * tnf_trace_off
68 void
69 tnf_trace_off(void)
71 TNFW_B_SET_STOPPED(tnfw_b_state);
72 dtrace_vtime_disable_tnf();
73 tnf_tracing_active = 0;
74 /* System call tracing is automatically disabled */
78 * tnf_trace_init
79 * Not reentrant: only called from tnf_allocbuf(), which is
80 * single-threaded.
82 void
83 tnf_trace_init(void)
85 int stopped;
86 tnf_ops_t *ops;
88 ASSERT(tnf_buf != NULL);
89 ASSERT(!tnf_tracing_active);
91 stopped = tnfw_b_state & TNFW_B_STOPPED;
94 * Initialize the buffer
96 tnfw_b_init_buffer(tnf_buf, tnf_trace_file_size);
99 * Mark allocator running (not stopped). Luckily,
100 * tnf_trace_alloc() first checks tnf_tracing_active, so no
101 * trace data will be written.
103 tnfw_b_state = TNFW_B_RUNNING;
106 * 1195835: Write out some tags now. The stopped bit needs
107 * to be clear while we do this.
109 /* LINTED pointer cast may result in improper alignment */
110 if ((ops = (tnf_ops_t *)curthread->t_tnf_tpdp) != NULL) {
111 tnf_tag_data_t *tag;
112 TNFW_B_POS *pos;
114 ASSERT(!LOCK_HELD(&ops->busy));
115 LOCK_INIT_HELD(&ops->busy); /* XXX save a call */
117 tag = TAG_DATA(tnf_struct_type);
118 (void) tag->tag_desc(ops, tag);
119 tag = TAG_DATA(tnf_probe_type);
120 (void) tag->tag_desc(ops, tag);
121 tag = TAG_DATA(tnf_kernel_schedule);
122 (void) tag->tag_desc(ops, tag);
124 pos = &ops->wcb.tnfw_w_tag_pos;
125 TNFW_B_COMMIT(pos);
126 pos = &ops->wcb.tnfw_w_pos;
127 TNFW_B_ROLLBACK(pos);
129 LOCK_INIT_CLEAR(&ops->busy); /* XXX save a call */
132 /* Restore stopped bit */
133 tnfw_b_state |= stopped;
136 #endif /* NPROBE */