dtrace.c (249573) | dtrace.c (250574) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 4 unchanged lines hidden (view full) --- 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 * | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 4 unchanged lines hidden (view full) --- 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 * |
21 * $FreeBSD: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c 249573 2013-04-17 02:20:17Z pfg $ | 21 * $FreeBSD: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c 250574 2013-05-12 16:26:33Z markj $ |
22 */ 23 24/* 25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. | 22 */ 23 24/* 25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
26 * Copyright (c) 2012 by Delphix. All rights reserved |
|
26 * Use is subject to license terms. 27 */ 28 29#pragma ident "%Z%%M% %I% %E% SMI" 30 31/* 32 * DTrace - Dynamic Tracing for Solaris 33 * --- 2306 unchanged lines hidden (view full) --- 2340 * to the state transition diagram outlined in <sys/dtrace_impl.h> 2341 */ 2342static void 2343dtrace_speculation_commit(dtrace_state_t *state, processorid_t cpu, 2344 dtrace_specid_t which) 2345{ 2346 dtrace_speculation_t *spec; 2347 dtrace_buffer_t *src, *dest; | 27 * Use is subject to license terms. 28 */ 29 30#pragma ident "%Z%%M% %I% %E% SMI" 31 32/* 33 * DTrace - Dynamic Tracing for Solaris 34 * --- 2306 unchanged lines hidden (view full) --- 2341 * to the state transition diagram outlined in <sys/dtrace_impl.h> 2342 */ 2343static void 2344dtrace_speculation_commit(dtrace_state_t *state, processorid_t cpu, 2345 dtrace_specid_t which) 2346{ 2347 dtrace_speculation_t *spec; 2348 dtrace_buffer_t *src, *dest; |
2348 uintptr_t daddr, saddr, dlimit; | 2349 uintptr_t daddr, saddr, dlimit, slimit; |
2349 dtrace_speculation_state_t current, new = 0; 2350 intptr_t offs; | 2350 dtrace_speculation_state_t current, new = 0; 2351 intptr_t offs; |
2352 uint64_t timestamp; |
|
2351 2352 if (which == 0) 2353 return; 2354 2355 if (which > state->dts_nspeculations) { 2356 cpu_core[cpu].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP; 2357 return; 2358 } --- 59 unchanged lines hidden (view full) --- 2418 */ 2419 if ((offs = dtrace_buffer_reserve(dest, src->dtb_offset, 2420 sizeof (uint64_t), state, NULL)) < 0) { 2421 dtrace_buffer_drop(dest); 2422 goto out; 2423 } 2424 2425 /* | 2353 2354 if (which == 0) 2355 return; 2356 2357 if (which > state->dts_nspeculations) { 2358 cpu_core[cpu].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP; 2359 return; 2360 } --- 59 unchanged lines hidden (view full) --- 2420 */ 2421 if ((offs = dtrace_buffer_reserve(dest, src->dtb_offset, 2422 sizeof (uint64_t), state, NULL)) < 0) { 2423 dtrace_buffer_drop(dest); 2424 goto out; 2425 } 2426 2427 /* |
2426 * We have the space; copy the buffer across. (Note that this is a | 2428 * We have sufficient space to copy the speculative buffer into the 2429 * primary buffer. First, modify the speculative buffer, filling 2430 * in the timestamp of all entries with the current time. The data 2431 * must have the commit() time rather than the time it was traced, 2432 * so that all entries in the primary buffer are in timestamp order. 2433 */ 2434 timestamp = dtrace_gethrtime(); 2435 saddr = (uintptr_t)src->dtb_tomax; 2436 slimit = saddr + src->dtb_offset; 2437 while (saddr < slimit) { 2438 size_t size; 2439 dtrace_rechdr_t *dtrh = (dtrace_rechdr_t *)saddr; 2440 2441 if (dtrh->dtrh_epid == DTRACE_EPIDNONE) { 2442 saddr += sizeof (dtrace_epid_t); 2443 continue; 2444 } 2445 ASSERT3U(dtrh->dtrh_epid, <=, state->dts_necbs); 2446 size = state->dts_ecbs[dtrh->dtrh_epid - 1]->dte_size; 2447 2448 ASSERT3U(saddr + size, <=, slimit); 2449 ASSERT3U(size, >=, sizeof (dtrace_rechdr_t)); 2450 ASSERT3U(DTRACE_RECORD_LOAD_TIMESTAMP(dtrh), ==, UINT64_MAX); 2451 2452 DTRACE_RECORD_STORE_TIMESTAMP(dtrh, timestamp); 2453 2454 saddr += size; 2455 } 2456 2457 /* 2458 * Copy the buffer across. (Note that this is a |
2427 * highly subobtimal bcopy(); in the unlikely event that this becomes 2428 * a serious performance issue, a high-performance DTrace-specific 2429 * bcopy() should obviously be invented.) 2430 */ 2431 daddr = (uintptr_t)dest->dtb_tomax + offs; 2432 dlimit = daddr + src->dtb_offset; 2433 saddr = (uintptr_t)src->dtb_tomax; 2434 --- 3766 unchanged lines hidden (view full) --- 6201 continue; 6202 } 6203#endif 6204 } 6205 6206 if (now - state->dts_alive > dtrace_deadman_timeout) { 6207 /* 6208 * We seem to be dead. Unless we (a) have kernel | 2459 * highly subobtimal bcopy(); in the unlikely event that this becomes 2460 * a serious performance issue, a high-performance DTrace-specific 2461 * bcopy() should obviously be invented.) 2462 */ 2463 daddr = (uintptr_t)dest->dtb_tomax + offs; 2464 dlimit = daddr + src->dtb_offset; 2465 saddr = (uintptr_t)src->dtb_tomax; 2466 --- 3766 unchanged lines hidden (view full) --- 6233 continue; 6234 } 6235#endif 6236 } 6237 6238 if (now - state->dts_alive > dtrace_deadman_timeout) { 6239 /* 6240 * We seem to be dead. Unless we (a) have kernel |
6209 * destructive permissions (b) have expicitly enabled | 6241 * destructive permissions (b) have explicitly enabled |
6210 * destructive actions and (c) destructive actions have 6211 * not been disabled, we're going to transition into 6212 * the KILLED state, from which no further processing 6213 * on this state will be performed. 6214 */ 6215 if (!dtrace_priv_kernel_destructive(state) || 6216 !state->dts_cred.dcr_destructive || 6217 dtrace_destructive_disallow) { --- 11 unchanged lines hidden (view full) --- 6229 6230 if ((offs = dtrace_buffer_reserve(buf, ecb->dte_needed, 6231 ecb->dte_alignment, state, &mstate)) < 0) 6232 continue; 6233 6234 tomax = buf->dtb_tomax; 6235 ASSERT(tomax != NULL); 6236 | 6242 * destructive actions and (c) destructive actions have 6243 * not been disabled, we're going to transition into 6244 * the KILLED state, from which no further processing 6245 * on this state will be performed. 6246 */ 6247 if (!dtrace_priv_kernel_destructive(state) || 6248 !state->dts_cred.dcr_destructive || 6249 dtrace_destructive_disallow) { --- 11 unchanged lines hidden (view full) --- 6261 6262 if ((offs = dtrace_buffer_reserve(buf, ecb->dte_needed, 6263 ecb->dte_alignment, state, &mstate)) < 0) 6264 continue; 6265 6266 tomax = buf->dtb_tomax; 6267 ASSERT(tomax != NULL); 6268 |
6237 if (ecb->dte_size != 0) 6238 DTRACE_STORE(uint32_t, tomax, offs, ecb->dte_epid); | 6269 if (ecb->dte_size != 0) { 6270 dtrace_rechdr_t dtrh; 6271 if (!(mstate.dtms_present & DTRACE_MSTATE_TIMESTAMP)) { 6272 mstate.dtms_timestamp = dtrace_gethrtime(); 6273 mstate.dtms_present |= DTRACE_MSTATE_TIMESTAMP; 6274 } 6275 ASSERT3U(ecb->dte_size, >=, sizeof (dtrace_rechdr_t)); 6276 dtrh.dtrh_epid = ecb->dte_epid; 6277 DTRACE_RECORD_STORE_TIMESTAMP(&dtrh, 6278 mstate.dtms_timestamp); 6279 *((dtrace_rechdr_t *)(tomax + offs)) = dtrh; 6280 } |
6239 6240 mstate.dtms_epid = ecb->dte_epid; 6241 mstate.dtms_present |= DTRACE_MSTATE_EPID; 6242 6243 if (state->dts_cred.dcr_visible & DTRACE_CRV_KERNEL) 6244 mstate.dtms_access = DTRACE_ACCESS_KERNEL; 6245 else 6246 mstate.dtms_access = 0; --- 130 unchanged lines hidden (view full) --- 6377 ASSERT(dp != NULL); 6378 6379 val = dtrace_dif_emulate(dp, &mstate, vstate, state); 6380 6381 if (*flags & CPU_DTRACE_ERROR) 6382 continue; 6383 6384 switch (act->dta_kind) { | 6281 6282 mstate.dtms_epid = ecb->dte_epid; 6283 mstate.dtms_present |= DTRACE_MSTATE_EPID; 6284 6285 if (state->dts_cred.dcr_visible & DTRACE_CRV_KERNEL) 6286 mstate.dtms_access = DTRACE_ACCESS_KERNEL; 6287 else 6288 mstate.dtms_access = 0; --- 130 unchanged lines hidden (view full) --- 6419 ASSERT(dp != NULL); 6420 6421 val = dtrace_dif_emulate(dp, &mstate, vstate, state); 6422 6423 if (*flags & CPU_DTRACE_ERROR) 6424 continue; 6425 6426 switch (act->dta_kind) { |
6385 case DTRACEACT_SPECULATE: | 6427 case DTRACEACT_SPECULATE: { 6428 dtrace_rechdr_t *dtrh; 6429 |
6386 ASSERT(buf == &state->dts_buffer[cpuid]); 6387 buf = dtrace_speculation_buffer(state, 6388 cpuid, val); 6389 6390 if (buf == NULL) { 6391 *flags |= CPU_DTRACE_DROP; 6392 continue; 6393 } --- 5 unchanged lines hidden (view full) --- 6399 if (offs < 0) { 6400 *flags |= CPU_DTRACE_DROP; 6401 continue; 6402 } 6403 6404 tomax = buf->dtb_tomax; 6405 ASSERT(tomax != NULL); 6406 | 6430 ASSERT(buf == &state->dts_buffer[cpuid]); 6431 buf = dtrace_speculation_buffer(state, 6432 cpuid, val); 6433 6434 if (buf == NULL) { 6435 *flags |= CPU_DTRACE_DROP; 6436 continue; 6437 } --- 5 unchanged lines hidden (view full) --- 6443 if (offs < 0) { 6444 *flags |= CPU_DTRACE_DROP; 6445 continue; 6446 } 6447 6448 tomax = buf->dtb_tomax; 6449 ASSERT(tomax != NULL); 6450 |
6407 if (ecb->dte_size != 0) 6408 DTRACE_STORE(uint32_t, tomax, offs, 6409 ecb->dte_epid); | 6451 if (ecb->dte_size == 0) 6452 continue; 6453 6454 ASSERT3U(ecb->dte_size, >=, 6455 sizeof (dtrace_rechdr_t)); 6456 dtrh = ((void *)(tomax + offs)); 6457 dtrh->dtrh_epid = ecb->dte_epid; 6458 /* 6459 * When the speculation is committed, all of 6460 * the records in the speculative buffer will 6461 * have their timestamps set to the commit 6462 * time. Until then, it is set to a sentinel 6463 * value, for debugability. 6464 */ 6465 DTRACE_RECORD_STORE_TIMESTAMP(dtrh, UINT64_MAX); |
6410 continue; | 6466 continue; |
6467 } |
|
6411 6412 case DTRACEACT_PRINTM: { 6413 /* The DIF returns a 'memref'. */ 6414 uintptr_t *memref = (uintptr_t *)(uintptr_t) val; 6415 6416 /* Get the size from the memref. */ 6417 size = memref[1]; 6418 --- 3330 unchanged lines hidden (view full) --- 9749 ASSERT(MUTEX_HELD(&dtrace_lock)); 9750 9751 ecb = kmem_zalloc(sizeof (dtrace_ecb_t), KM_SLEEP); 9752 ecb->dte_predicate = NULL; 9753 ecb->dte_probe = probe; 9754 9755 /* 9756 * The default size is the size of the default action: recording | 6468 6469 case DTRACEACT_PRINTM: { 6470 /* The DIF returns a 'memref'. */ 6471 uintptr_t *memref = (uintptr_t *)(uintptr_t) val; 6472 6473 /* Get the size from the memref. */ 6474 size = memref[1]; 6475 --- 3330 unchanged lines hidden (view full) --- 9806 ASSERT(MUTEX_HELD(&dtrace_lock)); 9807 9808 ecb = kmem_zalloc(sizeof (dtrace_ecb_t), KM_SLEEP); 9809 ecb->dte_predicate = NULL; 9810 ecb->dte_probe = probe; 9811 9812 /* 9813 * The default size is the size of the default action: recording |
9757 * the epid. | 9814 * the header. |
9758 */ | 9815 */ |
9759 ecb->dte_size = ecb->dte_needed = sizeof (dtrace_epid_t); | 9816 ecb->dte_size = ecb->dte_needed = sizeof (dtrace_rechdr_t); |
9760 ecb->dte_alignment = sizeof (dtrace_epid_t); 9761 9762 epid = state->dts_epid++; 9763 9764 if (epid - 1 >= state->dts_necbs) { 9765 dtrace_ecb_t **oecbs = state->dts_ecbs, **ecbs; 9766 int necbs = state->dts_necbs << 1; 9767 --- 81 unchanged lines hidden (view full) --- 9849 9850 dtrace_sync(); 9851 } 9852} 9853 9854static void 9855dtrace_ecb_resize(dtrace_ecb_t *ecb) 9856{ | 9817 ecb->dte_alignment = sizeof (dtrace_epid_t); 9818 9819 epid = state->dts_epid++; 9820 9821 if (epid - 1 >= state->dts_necbs) { 9822 dtrace_ecb_t **oecbs = state->dts_ecbs, **ecbs; 9823 int necbs = state->dts_necbs << 1; 9824 --- 81 unchanged lines hidden (view full) --- 9906 9907 dtrace_sync(); 9908 } 9909} 9910 9911static void 9912dtrace_ecb_resize(dtrace_ecb_t *ecb) 9913{ |
9857 uint32_t maxalign = sizeof (dtrace_epid_t); 9858 uint32_t align = sizeof (uint8_t), offs, diff; | |
9859 dtrace_action_t *act; | 9914 dtrace_action_t *act; |
9860 int wastuple = 0; | 9915 uint32_t curneeded = UINT32_MAX; |
9861 uint32_t aggbase = UINT32_MAX; | 9916 uint32_t aggbase = UINT32_MAX; |
9862 dtrace_state_t *state = ecb->dte_state; | |
9863 9864 /* | 9917 9918 /* |
9865 * If we record anything, we always record the epid. (And we always 9866 * record it first.) | 9919 * If we record anything, we always record the dtrace_rechdr_t. (And 9920 * we always record it first.) |
9867 */ | 9921 */ |
9868 offs = sizeof (dtrace_epid_t); 9869 ecb->dte_size = ecb->dte_needed = sizeof (dtrace_epid_t); | 9922 ecb->dte_size = sizeof (dtrace_rechdr_t); 9923 ecb->dte_alignment = sizeof (dtrace_epid_t); |
9870 9871 for (act = ecb->dte_action; act != NULL; act = act->dta_next) { 9872 dtrace_recdesc_t *rec = &act->dta_rec; | 9924 9925 for (act = ecb->dte_action; act != NULL; act = act->dta_next) { 9926 dtrace_recdesc_t *rec = &act->dta_rec; |
9927 ASSERT(rec->dtrd_size > 0 || rec->dtrd_alignment == 1); |
|
9873 | 9928 |
9874 if ((align = rec->dtrd_alignment) > maxalign) 9875 maxalign = align; | 9929 ecb->dte_alignment = MAX(ecb->dte_alignment, 9930 rec->dtrd_alignment); |
9876 | 9931 |
9877 if (!wastuple && act->dta_intuple) { 9878 /* 9879 * This is the first record in a tuple. Align the 9880 * offset to be at offset 4 in an 8-byte aligned 9881 * block. 9882 */ 9883 diff = offs + sizeof (dtrace_aggid_t); 9884 9885 if ((diff = (diff & (sizeof (uint64_t) - 1)))) 9886 offs += sizeof (uint64_t) - diff; 9887 9888 aggbase = offs - sizeof (dtrace_aggid_t); 9889 ASSERT(!(aggbase & (sizeof (uint64_t) - 1))); 9890 } 9891 9892 /*LINTED*/ 9893 if (rec->dtrd_size != 0 && (diff = (offs & (align - 1)))) { 9894 /* 9895 * The current offset is not properly aligned; align it. 9896 */ 9897 offs += align - diff; 9898 } 9899 9900 rec->dtrd_offset = offs; 9901 9902 if (offs + rec->dtrd_size > ecb->dte_needed) { 9903 ecb->dte_needed = offs + rec->dtrd_size; 9904 9905 if (ecb->dte_needed > state->dts_needed) 9906 state->dts_needed = ecb->dte_needed; 9907 } 9908 | |
9909 if (DTRACEACT_ISAGG(act->dta_kind)) { 9910 dtrace_aggregation_t *agg = (dtrace_aggregation_t *)act; | 9932 if (DTRACEACT_ISAGG(act->dta_kind)) { 9933 dtrace_aggregation_t *agg = (dtrace_aggregation_t *)act; |
9911 dtrace_action_t *first = agg->dtag_first, *prev; | |
9912 | 9934 |
9913 ASSERT(rec->dtrd_size != 0 && first != NULL); 9914 ASSERT(wastuple); | 9935 ASSERT(rec->dtrd_size != 0); 9936 ASSERT(agg->dtag_first != NULL); 9937 ASSERT(act->dta_prev->dta_intuple); |
9915 ASSERT(aggbase != UINT32_MAX); | 9938 ASSERT(aggbase != UINT32_MAX); |
9939 ASSERT(curneeded != UINT32_MAX); |
|
9916 9917 agg->dtag_base = aggbase; 9918 | 9940 9941 agg->dtag_base = aggbase; 9942 |
9919 while ((prev = first->dta_prev) != NULL && 9920 DTRACEACT_ISAGG(prev->dta_kind)) { 9921 agg = (dtrace_aggregation_t *)prev; 9922 first = agg->dtag_first; 9923 } | 9943 curneeded = P2ROUNDUP(curneeded, rec->dtrd_alignment); 9944 rec->dtrd_offset = curneeded; 9945 curneeded += rec->dtrd_size; 9946 ecb->dte_needed = MAX(ecb->dte_needed, curneeded); |
9924 | 9947 |
9925 if (prev != NULL) { 9926 offs = prev->dta_rec.dtrd_offset + 9927 prev->dta_rec.dtrd_size; 9928 } else { 9929 offs = sizeof (dtrace_epid_t); | 9948 aggbase = UINT32_MAX; 9949 curneeded = UINT32_MAX; 9950 } else if (act->dta_intuple) { 9951 if (curneeded == UINT32_MAX) { 9952 /* 9953 * This is the first record in a tuple. Align 9954 * curneeded to be at offset 4 in an 8-byte 9955 * aligned block. 9956 */ 9957 ASSERT(act->dta_prev == NULL || 9958 !act->dta_prev->dta_intuple); 9959 ASSERT3U(aggbase, ==, UINT32_MAX); 9960 curneeded = P2PHASEUP(ecb->dte_size, 9961 sizeof (uint64_t), sizeof (dtrace_aggid_t)); 9962 9963 aggbase = curneeded - sizeof (dtrace_aggid_t); 9964 ASSERT(IS_P2ALIGNED(aggbase, 9965 sizeof (uint64_t))); |
9930 } | 9966 } |
9931 wastuple = 0; | 9967 curneeded = P2ROUNDUP(curneeded, rec->dtrd_alignment); 9968 rec->dtrd_offset = curneeded; 9969 curneeded += rec->dtrd_size; |
9932 } else { | 9970 } else { |
9933 if (!act->dta_intuple) 9934 ecb->dte_size = offs + rec->dtrd_size; | 9971 /* tuples must be followed by an aggregation */ 9972 ASSERT(act->dta_prev == NULL || 9973 !act->dta_prev->dta_intuple); |
9935 | 9974 |
9936 offs += rec->dtrd_size; | 9975 ecb->dte_size = P2ROUNDUP(ecb->dte_size, 9976 rec->dtrd_alignment); 9977 rec->dtrd_offset = ecb->dte_size; 9978 ecb->dte_size += rec->dtrd_size; 9979 ecb->dte_needed = MAX(ecb->dte_needed, ecb->dte_size); |
9937 } | 9980 } |
9938 9939 wastuple = act->dta_intuple; | |
9940 } 9941 9942 if ((act = ecb->dte_action) != NULL && 9943 !(act->dta_kind == DTRACEACT_SPECULATE && act->dta_next == NULL) && | 9981 } 9982 9983 if ((act = ecb->dte_action) != NULL && 9984 !(act->dta_kind == DTRACEACT_SPECULATE && act->dta_next == NULL) && |
9944 ecb->dte_size == sizeof (dtrace_epid_t)) { | 9985 ecb->dte_size == sizeof (dtrace_rechdr_t)) { |
9945 /* | 9986 /* |
9946 * If the size is still sizeof (dtrace_epid_t), then all | 9987 * If the size is still sizeof (dtrace_rechdr_t), then all |
9947 * actions store no data; set the size to 0. 9948 */ | 9988 * actions store no data; set the size to 0. 9989 */ |
9949 ecb->dte_alignment = maxalign; | |
9950 ecb->dte_size = 0; | 9990 ecb->dte_size = 0; |
9951 9952 /* 9953 * If the needed space is still sizeof (dtrace_epid_t), then 9954 * all actions need no additional space; set the needed 9955 * size to 0. 9956 */ 9957 if (ecb->dte_needed == sizeof (dtrace_epid_t)) 9958 ecb->dte_needed = 0; 9959 9960 return; | |
9961 } 9962 | 9991 } 9992 |
9963 /* 9964 * Set our alignment, and make sure that the dte_size and dte_needed 9965 * are aligned to the size of an EPID. 9966 */ 9967 ecb->dte_alignment = maxalign; 9968 ecb->dte_size = (ecb->dte_size + (sizeof (dtrace_epid_t) - 1)) & 9969 ~(sizeof (dtrace_epid_t) - 1); 9970 ecb->dte_needed = (ecb->dte_needed + (sizeof (dtrace_epid_t) - 1)) & 9971 ~(sizeof (dtrace_epid_t) - 1); 9972 ASSERT(ecb->dte_size <= ecb->dte_needed); | 9993 ecb->dte_size = P2ROUNDUP(ecb->dte_size, sizeof (dtrace_epid_t)); 9994 ecb->dte_needed = P2ROUNDUP(ecb->dte_needed, (sizeof (dtrace_epid_t))); 9995 ecb->dte_state->dts_needed = MAX(ecb->dte_state->dts_needed, 9996 ecb->dte_needed); |
9973} 9974 9975static dtrace_action_t * 9976dtrace_ecb_aggregation_create(dtrace_ecb_t *ecb, dtrace_actdesc_t *desc) 9977{ 9978 dtrace_aggregation_t *agg; 9979 size_t size = sizeof (uint64_t); 9980 int ntuple = desc->dtad_ntuple; --- 363 unchanged lines hidden (view full) --- 10344 case DTRACEACT_EXIT: 10345 if (dp == NULL || 10346 (size = dp->dtdo_rtype.dtdt_size) != sizeof (int) || 10347 (dp->dtdo_rtype.dtdt_flags & DIF_TF_BYREF)) 10348 return (EINVAL); 10349 break; 10350 10351 case DTRACEACT_SPECULATE: | 9997} 9998 9999static dtrace_action_t * 10000dtrace_ecb_aggregation_create(dtrace_ecb_t *ecb, dtrace_actdesc_t *desc) 10001{ 10002 dtrace_aggregation_t *agg; 10003 size_t size = sizeof (uint64_t); 10004 int ntuple = desc->dtad_ntuple; --- 363 unchanged lines hidden (view full) --- 10368 case DTRACEACT_EXIT: 10369 if (dp == NULL || 10370 (size = dp->dtdo_rtype.dtdt_size) != sizeof (int) || 10371 (dp->dtdo_rtype.dtdt_flags & DIF_TF_BYREF)) 10372 return (EINVAL); 10373 break; 10374 10375 case DTRACEACT_SPECULATE: |
10352 if (ecb->dte_size > sizeof (dtrace_epid_t)) | 10376 if (ecb->dte_size > sizeof (dtrace_rechdr_t)) |
10353 return (EINVAL); 10354 10355 if (dp == NULL) 10356 return (EINVAL); 10357 10358 state->dts_speculates = 1; 10359 break; 10360 --- 104 unchanged lines hidden (view full) --- 10465 } else { 10466 kmem_free(act, sizeof (dtrace_action_t)); 10467 } 10468 } 10469 } 10470 10471 ecb->dte_action = NULL; 10472 ecb->dte_action_last = NULL; | 10377 return (EINVAL); 10378 10379 if (dp == NULL) 10380 return (EINVAL); 10381 10382 state->dts_speculates = 1; 10383 break; 10384 --- 104 unchanged lines hidden (view full) --- 10489 } else { 10490 kmem_free(act, sizeof (dtrace_action_t)); 10491 } 10492 } 10493 } 10494 10495 ecb->dte_action = NULL; 10496 ecb->dte_action_last = NULL; |
10473 ecb->dte_size = sizeof (dtrace_epid_t); | 10497 ecb->dte_size = 0; |
10474} 10475 10476static void 10477dtrace_ecb_disable(dtrace_ecb_t *ecb) 10478{ 10479 /* 10480 * We disable the ECB by removing it from its probe. 10481 */ --- 252 unchanged lines hidden (view full) --- 10734 * the same CPU. 10735 */ 10736static void 10737dtrace_buffer_switch(dtrace_buffer_t *buf) 10738{ 10739 caddr_t tomax = buf->dtb_tomax; 10740 caddr_t xamot = buf->dtb_xamot; 10741 dtrace_icookie_t cookie; | 10498} 10499 10500static void 10501dtrace_ecb_disable(dtrace_ecb_t *ecb) 10502{ 10503 /* 10504 * We disable the ECB by removing it from its probe. 10505 */ --- 252 unchanged lines hidden (view full) --- 10758 * the same CPU. 10759 */ 10760static void 10761dtrace_buffer_switch(dtrace_buffer_t *buf) 10762{ 10763 caddr_t tomax = buf->dtb_tomax; 10764 caddr_t xamot = buf->dtb_xamot; 10765 dtrace_icookie_t cookie; |
10742 hrtime_t now = dtrace_gethrtime(); | 10766 hrtime_t now; |
10743 10744 ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH)); 10745 ASSERT(!(buf->dtb_flags & DTRACEBUF_RING)); 10746 10747 cookie = dtrace_interrupt_disable(); | 10767 10768 ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH)); 10769 ASSERT(!(buf->dtb_flags & DTRACEBUF_RING)); 10770 10771 cookie = dtrace_interrupt_disable(); |
10772 now = dtrace_gethrtime(); |
|
10748 buf->dtb_tomax = xamot; 10749 buf->dtb_xamot = tomax; 10750 buf->dtb_xamot_drops = buf->dtb_drops; 10751 buf->dtb_xamot_offset = buf->dtb_offset; 10752 buf->dtb_xamot_errors = buf->dtb_errors; 10753 buf->dtb_xamot_flags = buf->dtb_flags; 10754 buf->dtb_offset = 0; 10755 buf->dtb_drops = 0; --- 349 unchanged lines hidden (view full) --- 11105 11106 while (offs + total > woffs) { 11107 dtrace_epid_t epid = *(uint32_t *)(tomax + woffs); 11108 size_t size; 11109 11110 if (epid == DTRACE_EPIDNONE) { 11111 size = sizeof (uint32_t); 11112 } else { | 10773 buf->dtb_tomax = xamot; 10774 buf->dtb_xamot = tomax; 10775 buf->dtb_xamot_drops = buf->dtb_drops; 10776 buf->dtb_xamot_offset = buf->dtb_offset; 10777 buf->dtb_xamot_errors = buf->dtb_errors; 10778 buf->dtb_xamot_flags = buf->dtb_flags; 10779 buf->dtb_offset = 0; 10780 buf->dtb_drops = 0; --- 349 unchanged lines hidden (view full) --- 11130 11131 while (offs + total > woffs) { 11132 dtrace_epid_t epid = *(uint32_t *)(tomax + woffs); 11133 size_t size; 11134 11135 if (epid == DTRACE_EPIDNONE) { 11136 size = sizeof (uint32_t); 11137 } else { |
11113 ASSERT(epid <= state->dts_necbs); | 11138 ASSERT3U(epid, <=, state->dts_necbs); |
11114 ASSERT(state->dts_ecbs[epid - 1] != NULL); 11115 11116 size = state->dts_ecbs[epid - 1]->dte_size; 11117 } 11118 11119 ASSERT(woffs + size <= buf->dtb_size); 11120 ASSERT(size != 0); 11121 --- 5260 unchanged lines hidden (view full) --- 16382 mutex_exit(&dtrace_lock); 16383 return (EFAULT); 16384 } 16385 16386 desc.dtbd_size = sz; 16387 desc.dtbd_drops = buf->dtb_drops; 16388 desc.dtbd_errors = buf->dtb_errors; 16389 desc.dtbd_oldest = buf->dtb_xamot_offset; | 11139 ASSERT(state->dts_ecbs[epid - 1] != NULL); 11140 11141 size = state->dts_ecbs[epid - 1]->dte_size; 11142 } 11143 11144 ASSERT(woffs + size <= buf->dtb_size); 11145 ASSERT(size != 0); 11146 --- 5260 unchanged lines hidden (view full) --- 16407 mutex_exit(&dtrace_lock); 16408 return (EFAULT); 16409 } 16410 16411 desc.dtbd_size = sz; 16412 desc.dtbd_drops = buf->dtb_drops; 16413 desc.dtbd_errors = buf->dtb_errors; 16414 desc.dtbd_oldest = buf->dtb_xamot_offset; |
16415 desc.dtbd_timestamp = dtrace_gethrtime(); |
|
16390 16391 mutex_exit(&dtrace_lock); 16392 16393 if (copyout(&desc, (void *)arg, sizeof (desc)) != 0) 16394 return (EFAULT); 16395 16396 buf->dtb_flags |= DTRACEBUF_CONSUMED; 16397 --- 36 unchanged lines hidden (view full) --- 16434 mutex_exit(&dtrace_lock); 16435 return (EFAULT); 16436 } 16437 16438 desc.dtbd_size = buf->dtb_xamot_offset; 16439 desc.dtbd_drops = buf->dtb_xamot_drops; 16440 desc.dtbd_errors = buf->dtb_xamot_errors; 16441 desc.dtbd_oldest = 0; | 16416 16417 mutex_exit(&dtrace_lock); 16418 16419 if (copyout(&desc, (void *)arg, sizeof (desc)) != 0) 16420 return (EFAULT); 16421 16422 buf->dtb_flags |= DTRACEBUF_CONSUMED; 16423 --- 36 unchanged lines hidden (view full) --- 16460 mutex_exit(&dtrace_lock); 16461 return (EFAULT); 16462 } 16463 16464 desc.dtbd_size = buf->dtb_xamot_offset; 16465 desc.dtbd_drops = buf->dtb_xamot_drops; 16466 desc.dtbd_errors = buf->dtb_xamot_errors; 16467 desc.dtbd_oldest = 0; |
16468 desc.dtbd_timestamp = buf->dtb_switched; |
|
16442 16443 mutex_exit(&dtrace_lock); 16444 16445 /* 16446 * Finally, copy out the buffer description. 16447 */ 16448 if (copyout(&desc, (void *)arg, sizeof (desc)) != 0) 16449 return (EFAULT); --- 406 unchanged lines hidden --- | 16469 16470 mutex_exit(&dtrace_lock); 16471 16472 /* 16473 * Finally, copy out the buffer description. 16474 */ 16475 if (copyout(&desc, (void *)arg, sizeof (desc)) != 0) 16476 return (EFAULT); --- 406 unchanged lines hidden --- |