1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1994, by Sun Microsytems, Inc. 24*7c478bd9Sstevel@tonic-gate */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate /* 29*7c478bd9Sstevel@tonic-gate * Includes 30*7c478bd9Sstevel@tonic-gate */ 31*7c478bd9Sstevel@tonic-gate #include <sys/param.h> 32*7c478bd9Sstevel@tonic-gate #include <sys/time.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/debug.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/tnf.h> 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #include "tnf_buf.h" 38*7c478bd9Sstevel@tonic-gate #include "tnf_types.h" 39*7c478bd9Sstevel@tonic-gate #include "tnf_trace.h" 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate /* 42*7c478bd9Sstevel@tonic-gate * Defines 43*7c478bd9Sstevel@tonic-gate */ 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #define ENCODED_TAG(tag, tagarg) \ 46*7c478bd9Sstevel@tonic-gate ((tag) | ((tagarg) & 0xfffc) | TNF_REF32_T_PAIR) 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate /* 49*7c478bd9Sstevel@tonic-gate * CAUTION: halfword_accessible assumes that the pointer is to a reclaimable 50*7c478bd9Sstevel@tonic-gate * block - i.e. negative offsets have a 0 in high bit 51*7c478bd9Sstevel@tonic-gate */ 52*7c478bd9Sstevel@tonic-gate #define HALFWORD_ACCESSIBLE(x) \ 53*7c478bd9Sstevel@tonic-gate ((((x) & 0xffff8000) == 0) || (((x) & 0xffff8000) == 0x7fff8000)) 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate /* 56*7c478bd9Sstevel@tonic-gate * Check that x can be encoded in tagarg slot 57*7c478bd9Sstevel@tonic-gate * Same as above, but operates on ints (no space bit) 58*7c478bd9Sstevel@tonic-gate */ 59*7c478bd9Sstevel@tonic-gate #define TAGARG_CHECK(x) \ 60*7c478bd9Sstevel@tonic-gate (((x) < 32767) && ((x) > -32768)) 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate /* 63*7c478bd9Sstevel@tonic-gate * Check that hit 32 bits of hrtime are zero 64*7c478bd9Sstevel@tonic-gate */ 65*7c478bd9Sstevel@tonic-gate #define TIME_CHECK(x) \ 66*7c478bd9Sstevel@tonic-gate (((x) >> 32) == 0) 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * CAUTION: Use the following macro only when doing a self relative pointer 70*7c478bd9Sstevel@tonic-gate * to a target in the same block 71*7c478bd9Sstevel@tonic-gate */ 72*7c478bd9Sstevel@tonic-gate #define PTR_DIFF(item, ref) \ 73*7c478bd9Sstevel@tonic-gate ((tnf_ref32_t)((tnf_record_p)(item) - (tnf_record_p)(ref))) 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* 76*7c478bd9Sstevel@tonic-gate * Typedefs 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate typedef struct { 80*7c478bd9Sstevel@tonic-gate tnf_probe_event_t probe_event; 81*7c478bd9Sstevel@tonic-gate tnf_time_delta_t time_delta; 82*7c478bd9Sstevel@tonic-gate } probe_event_prototype_t; 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate /* 85*7c478bd9Sstevel@tonic-gate * Declarations 86*7c478bd9Sstevel@tonic-gate */ 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * tnf_trace_alloc 90*7c478bd9Sstevel@tonic-gate * the probe allocation function 91*7c478bd9Sstevel@tonic-gate */ 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate void * 94*7c478bd9Sstevel@tonic-gate tnf_trace_alloc(tnf_ops_t *ops, tnf_probe_control_t *probe_p, 95*7c478bd9Sstevel@tonic-gate tnf_probe_setup_t *set_p) 96*7c478bd9Sstevel@tonic-gate { 97*7c478bd9Sstevel@tonic-gate TNFW_B_WCB *wcb; 98*7c478bd9Sstevel@tonic-gate uintptr_t probe_index; 99*7c478bd9Sstevel@tonic-gate tnf_record_p sched_record_p; 100*7c478bd9Sstevel@tonic-gate tnf_reference_t sched_offset, tag_disp; 101*7c478bd9Sstevel@tonic-gate tnf_block_header_t *block; 102*7c478bd9Sstevel@tonic-gate tnf_uint32_t shift; 103*7c478bd9Sstevel@tonic-gate probe_event_prototype_t *buffer; 104*7c478bd9Sstevel@tonic-gate hrtime_t curr_time, time_diff; 105*7c478bd9Sstevel@tonic-gate tnf_schedule_t *sched; 106*7c478bd9Sstevel@tonic-gate tnf_ref32_t *fwd_p; 107*7c478bd9Sstevel@tonic-gate size_t size, asize; 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate /* 110*7c478bd9Sstevel@tonic-gate * Check the "tracing active" flag after setting the busy bit; 111*7c478bd9Sstevel@tonic-gate * this avoids a race in which we check the "tracing active" 112*7c478bd9Sstevel@tonic-gate * flag, then it gets turned off, and the buffer gets 113*7c478bd9Sstevel@tonic-gate * deallocated, before we've set the busy bit. 114*7c478bd9Sstevel@tonic-gate */ 115*7c478bd9Sstevel@tonic-gate if (!lock_try(&ops->busy)) /* atomic op flushes WB */ 116*7c478bd9Sstevel@tonic-gate return (NULL); 117*7c478bd9Sstevel@tonic-gate if (!tnf_tracing_active) 118*7c478bd9Sstevel@tonic-gate goto null_ret; 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* 121*7c478bd9Sstevel@tonic-gate * Write probe tag if needed 122*7c478bd9Sstevel@tonic-gate */ 123*7c478bd9Sstevel@tonic-gate probe_index = probe_p->index; 124*7c478bd9Sstevel@tonic-gate if (probe_index == 0) { 125*7c478bd9Sstevel@tonic-gate if ((probe_index = tnf_probe_tag(ops, probe_p)) == 0) 126*7c478bd9Sstevel@tonic-gate goto null_ret; 127*7c478bd9Sstevel@tonic-gate } 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate /* 130*7c478bd9Sstevel@tonic-gate * Determine how much memory is required 131*7c478bd9Sstevel@tonic-gate */ 132*7c478bd9Sstevel@tonic-gate size = probe_p->tnf_event_size; 133*7c478bd9Sstevel@tonic-gate asize = size + sizeof (tnf_ref32_t); /* one fwd ptr */ 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate if (PROBE_IS_FILE_PTR(probe_index)) 136*7c478bd9Sstevel@tonic-gate /* common case - probe_index is a file ptr */ 137*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 138*7c478bd9Sstevel@tonic-gate tag_disp = probe_index & PROBE_INDEX_LOW_MASK; 139*7c478bd9Sstevel@tonic-gate else 140*7c478bd9Sstevel@tonic-gate /* rare case -- get an extra fwd ptr */ 141*7c478bd9Sstevel@tonic-gate asize += sizeof (tnf_ref32_t); 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate /* 144*7c478bd9Sstevel@tonic-gate * Allocate memory 145*7c478bd9Sstevel@tonic-gate */ 146*7c478bd9Sstevel@tonic-gate wcb = &ops->wcb; 147*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 16-bit integer */ 148*7c478bd9Sstevel@tonic-gate TNFW_B_ALLOC(wcb, asize, buffer, probe_event_prototype_t *); 149*7c478bd9Sstevel@tonic-gate if (buffer == NULL) 150*7c478bd9Sstevel@tonic-gate goto null_ret; 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */ 153*7c478bd9Sstevel@tonic-gate fwd_p = (tnf_ref32_t *)((char *)buffer + size); 154*7c478bd9Sstevel@tonic-gate 155*7c478bd9Sstevel@tonic-gate /* 156*7c478bd9Sstevel@tonic-gate * Check if the probe tag needs more work 157*7c478bd9Sstevel@tonic-gate */ 158*7c478bd9Sstevel@tonic-gate if (!PROBE_IS_FILE_PTR(probe_index)) { 159*7c478bd9Sstevel@tonic-gate /* use up first fwd ptr */ 160*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 161*7c478bd9Sstevel@tonic-gate *fwd_p = TNF_REF32_MAKE_PERMANENT( 162*7c478bd9Sstevel@tonic-gate (tnf_record_p)probe_index - tnf_buf); 163*7c478bd9Sstevel@tonic-gate /* LINTED cast from 64-bit integer to 32-bit integer */ 164*7c478bd9Sstevel@tonic-gate tag_disp = PTR_DIFF(fwd_p, buffer); 165*7c478bd9Sstevel@tonic-gate tag_disp |= TNF_TAG16_T_REL; 166*7c478bd9Sstevel@tonic-gate tag_disp = tag_disp << TNF_REF32_TAG16_SHIFT; 167*7c478bd9Sstevel@tonic-gate fwd_p++; 168*7c478bd9Sstevel@tonic-gate } 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate /* 171*7c478bd9Sstevel@tonic-gate * Get timestamp 172*7c478bd9Sstevel@tonic-gate */ 173*7c478bd9Sstevel@tonic-gate curr_time = gethrtime(); 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate /* 176*7c478bd9Sstevel@tonic-gate * Write schedule record if needed 177*7c478bd9Sstevel@tonic-gate */ 178*7c478bd9Sstevel@tonic-gate sched = &ops->schedule; 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate /* LINTED pointer cast */ 181*7c478bd9Sstevel@tonic-gate shift = ((tnf_buf_file_header_t *)tnf_buf)->com.file_log_size; 182*7c478bd9Sstevel@tonic-gate block = (tnf_block_header_t *)((uintptr_t)buffer & TNF_BLOCK_MASK); 183*7c478bd9Sstevel@tonic-gate 184*7c478bd9Sstevel@tonic-gate if ((sched_record_p = sched->record_p) == NULL) 185*7c478bd9Sstevel@tonic-gate /* No record written yet */ 186*7c478bd9Sstevel@tonic-gate goto new_schedule; 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate /* 189*7c478bd9Sstevel@tonic-gate * Note: Don't bother about space bit here, because we'll 190*7c478bd9Sstevel@tonic-gate * only use bits 15:2 anyway 191*7c478bd9Sstevel@tonic-gate */ 192*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 193*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 194*7c478bd9Sstevel@tonic-gate sched_offset = ((sched->record_gen - block->generation) << shift) + 195*7c478bd9Sstevel@tonic-gate (sched_record_p - (caddr_t)buffer); 196*7c478bd9Sstevel@tonic-gate #else 197*7c478bd9Sstevel@tonic-gate sched_offset = ((sched->record_gen - block->generation) << shift) + 198*7c478bd9Sstevel@tonic-gate (sched_record_p - (caddr_t)buffer); 199*7c478bd9Sstevel@tonic-gate #endif 200*7c478bd9Sstevel@tonic-gate if (!TAGARG_CHECK(sched_offset)) 201*7c478bd9Sstevel@tonic-gate /* Record too far away to reference */ 202*7c478bd9Sstevel@tonic-gate goto new_schedule; 203*7c478bd9Sstevel@tonic-gate 204*7c478bd9Sstevel@tonic-gate time_diff = curr_time - sched->time_base; 205*7c478bd9Sstevel@tonic-gate if (!TIME_CHECK(time_diff)) 206*7c478bd9Sstevel@tonic-gate /* Time delta can't fit in 32 bits */ 207*7c478bd9Sstevel@tonic-gate goto new_schedule; 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate if (sched->cpuid != CPU->cpu_id) 210*7c478bd9Sstevel@tonic-gate /* CPU information is invalid */ 211*7c478bd9Sstevel@tonic-gate goto new_schedule; 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* 214*7c478bd9Sstevel@tonic-gate * Can reuse existing schedule record 215*7c478bd9Sstevel@tonic-gate * Since we did not allocate any more space, can giveback 216*7c478bd9Sstevel@tonic-gate */ 217*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 218*7c478bd9Sstevel@tonic-gate /* LINTED warning: assignment of 64-bit integer to 16-bit integer */ 219*7c478bd9Sstevel@tonic-gate TNFW_B_GIVEBACK(wcb, fwd_p); 220*7c478bd9Sstevel@tonic-gate #else 221*7c478bd9Sstevel@tonic-gate TNFW_B_GIVEBACK(wcb, fwd_p); 222*7c478bd9Sstevel@tonic-gate #endif 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate good_ret: 225*7c478bd9Sstevel@tonic-gate /* 226*7c478bd9Sstevel@tonic-gate * Store return params and two common event members, return buffer 227*7c478bd9Sstevel@tonic-gate */ 228*7c478bd9Sstevel@tonic-gate set_p->tpd_p = ops; 229*7c478bd9Sstevel@tonic-gate set_p->buffer_p = buffer; 230*7c478bd9Sstevel@tonic-gate set_p->probe_p = probe_p; 231*7c478bd9Sstevel@tonic-gate buffer->probe_event = ENCODED_TAG(tag_disp, sched_offset); 232*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 233*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 234*7c478bd9Sstevel@tonic-gate buffer->time_delta = tnf_time_delta(ops, (unsigned long)time_diff, 235*7c478bd9Sstevel@tonic-gate &buffer->probe_time_delta); 236*7c478bd9Sstevel@tonic-gate #else 237*7c478bd9Sstevel@tonic-gate buffer->time_delta = tnf_time_delta(ops, (unsigned long)time_diff, 238*7c478bd9Sstevel@tonic-gate &buffer->probe_time_delta); 239*7c478bd9Sstevel@tonic-gate #endif 240*7c478bd9Sstevel@tonic-gate return (buffer); 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate new_schedule: 243*7c478bd9Sstevel@tonic-gate /* 244*7c478bd9Sstevel@tonic-gate * Write a new schedule record for this thread 245*7c478bd9Sstevel@tonic-gate */ 246*7c478bd9Sstevel@tonic-gate sched->cpuid = CPU->cpu_id; 247*7c478bd9Sstevel@tonic-gate sched->time_base = curr_time; 248*7c478bd9Sstevel@tonic-gate time_diff = 0; 249*7c478bd9Sstevel@tonic-gate if ((sched_record_p = tnf_kernel_schedule(ops, sched)) != NULL) { 250*7c478bd9Sstevel@tonic-gate /* use one of the extra alloced words for the forwarding ptr */ 251*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 252*7c478bd9Sstevel@tonic-gate /* LINTED assignment of 64-bit integer to 32-bit integer */ 253*7c478bd9Sstevel@tonic-gate *fwd_p = TNF_REF32_MAKE_RECLAIMABLE( 254*7c478bd9Sstevel@tonic-gate ((sched->record_gen - block->generation) << shift) + 255*7c478bd9Sstevel@tonic-gate /* LINTED */ 256*7c478bd9Sstevel@tonic-gate (sched_record_p - (tnf_record_p)fwd_p)); 257*7c478bd9Sstevel@tonic-gate /* LINTED cast from 64-bit integer to 32-bit integer */ 258*7c478bd9Sstevel@tonic-gate sched_offset = PTR_DIFF(fwd_p, buffer); 259*7c478bd9Sstevel@tonic-gate #else 260*7c478bd9Sstevel@tonic-gate *fwd_p = TNF_REF32_MAKE_RECLAIMABLE( 261*7c478bd9Sstevel@tonic-gate ((sched->record_gen - block->generation) << shift) + 262*7c478bd9Sstevel@tonic-gate (sched_record_p - (tnf_record_p)fwd_p)); 263*7c478bd9Sstevel@tonic-gate sched_offset = PTR_DIFF(fwd_p, buffer); 264*7c478bd9Sstevel@tonic-gate #endif 265*7c478bd9Sstevel@tonic-gate } else { 266*7c478bd9Sstevel@tonic-gate /* Allocation failed (tracing may have been stopped) */ 267*7c478bd9Sstevel@tonic-gate sched_offset = 0; 268*7c478bd9Sstevel@tonic-gate *fwd_p = TNF_NULL; 269*7c478bd9Sstevel@tonic-gate } 270*7c478bd9Sstevel@tonic-gate goto good_ret; 271*7c478bd9Sstevel@tonic-gate 272*7c478bd9Sstevel@tonic-gate null_ret: 273*7c478bd9Sstevel@tonic-gate /* 274*7c478bd9Sstevel@tonic-gate * Clear busy flag and return null 275*7c478bd9Sstevel@tonic-gate */ 276*7c478bd9Sstevel@tonic-gate LOCK_INIT_CLEAR(&ops->busy); /* XXX save a call */ 277*7c478bd9Sstevel@tonic-gate return (NULL); 278*7c478bd9Sstevel@tonic-gate } 279*7c478bd9Sstevel@tonic-gate 280*7c478bd9Sstevel@tonic-gate /* 281*7c478bd9Sstevel@tonic-gate * tnf_trace_commit 282*7c478bd9Sstevel@tonic-gate */ 283*7c478bd9Sstevel@tonic-gate void 284*7c478bd9Sstevel@tonic-gate tnf_trace_commit(tnf_probe_setup_t *set_p) 285*7c478bd9Sstevel@tonic-gate { 286*7c478bd9Sstevel@tonic-gate tnf_ops_t *ops; 287*7c478bd9Sstevel@tonic-gate TNFW_B_WCB *wcb; 288*7c478bd9Sstevel@tonic-gate TNFW_B_POS *pos; 289*7c478bd9Sstevel@tonic-gate 290*7c478bd9Sstevel@tonic-gate ops = set_p->tpd_p; 291*7c478bd9Sstevel@tonic-gate wcb = &ops->wcb; 292*7c478bd9Sstevel@tonic-gate 293*7c478bd9Sstevel@tonic-gate /* commit reusable bytes */ 294*7c478bd9Sstevel@tonic-gate pos = &wcb->tnfw_w_pos; 295*7c478bd9Sstevel@tonic-gate TNFW_B_COMMIT(pos); 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate /* commit tag bytes */ 298*7c478bd9Sstevel@tonic-gate pos = &wcb->tnfw_w_tag_pos; 299*7c478bd9Sstevel@tonic-gate TNFW_B_COMMIT(pos); 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate /* clear busy flag */ 302*7c478bd9Sstevel@tonic-gate LOCK_INIT_CLEAR(&ops->busy); /* XXX save a call */ 303*7c478bd9Sstevel@tonic-gate } 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate /* 306*7c478bd9Sstevel@tonic-gate * tnf_trace_rollback 307*7c478bd9Sstevel@tonic-gate */ 308*7c478bd9Sstevel@tonic-gate void 309*7c478bd9Sstevel@tonic-gate tnf_trace_rollback(tnf_probe_setup_t *set_p) 310*7c478bd9Sstevel@tonic-gate { 311*7c478bd9Sstevel@tonic-gate tnf_ops_t *ops; 312*7c478bd9Sstevel@tonic-gate TNFW_B_WCB *wcb; 313*7c478bd9Sstevel@tonic-gate TNFW_B_POS *pos; 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate ops = set_p->tpd_p; 316*7c478bd9Sstevel@tonic-gate wcb = &ops->wcb; 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate /* rollback data bytes */ 319*7c478bd9Sstevel@tonic-gate pos = &wcb->tnfw_w_pos; 320*7c478bd9Sstevel@tonic-gate TNFW_B_ROLLBACK(pos); 321*7c478bd9Sstevel@tonic-gate 322*7c478bd9Sstevel@tonic-gate /* commit tag bytes */ 323*7c478bd9Sstevel@tonic-gate pos = &wcb->tnfw_w_tag_pos; 324*7c478bd9Sstevel@tonic-gate TNFW_B_COMMIT(pos); 325*7c478bd9Sstevel@tonic-gate 326*7c478bd9Sstevel@tonic-gate /* zap schedule record, since it is in uncommitted store */ 327*7c478bd9Sstevel@tonic-gate ops->schedule.record_p = NULL; 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate /* clear busy flag */ 330*7c478bd9Sstevel@tonic-gate LOCK_INIT_CLEAR(&ops->busy); /* XXX save a call */ 331*7c478bd9Sstevel@tonic-gate } 332*7c478bd9Sstevel@tonic-gate 333*7c478bd9Sstevel@tonic-gate /* 334*7c478bd9Sstevel@tonic-gate * tnf_allocate 335*7c478bd9Sstevel@tonic-gate * exported interface for allocating trace memory 336*7c478bd9Sstevel@tonic-gate */ 337*7c478bd9Sstevel@tonic-gate 338*7c478bd9Sstevel@tonic-gate void * 339*7c478bd9Sstevel@tonic-gate tnf_allocate(tnf_ops_t *ops, size_t size) 340*7c478bd9Sstevel@tonic-gate { 341*7c478bd9Sstevel@tonic-gate return (tnfw_b_alloc(&ops->wcb, size, ops->mode)); 342*7c478bd9Sstevel@tonic-gate } 343