From 8ac39fe21904dacc07126546e30af03118fa1fce Mon Sep 17 00:00:00 2001 From: Graeme Jenkinson Date: Mon, 4 Mar 2019 13:42:20 +0000 Subject: [PATCH 1/2] Minor fixes preventing in-tree dlog from building. --- contrib/dlog/bin/dlogd/dl_request_queue.h | 2 +- contrib/dlog/bin/dlogd/dlogd.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/dlog/bin/dlogd/dl_request_queue.h b/contrib/dlog/bin/dlogd/dl_request_queue.h index 61ea7020303..84744209827 100644 --- a/contrib/dlog/bin/dlogd/dl_request_queue.h +++ b/contrib/dlog/bin/dlogd/dl_request_queue.h @@ -61,7 +61,7 @@ struct dl_request_q_stats { int dlrq_capacity; int dlrq_requests; int dlrq_unackd; -} dlrq_stats; +}; struct dl_request_q; diff --git a/contrib/dlog/bin/dlogd/dlogd.c b/contrib/dlog/bin/dlogd/dlogd.c index 01ac8dab63f..65584123bd4 100644 --- a/contrib/dlog/bin/dlogd/dlogd.c +++ b/contrib/dlog/bin/dlogd/dlogd.c @@ -96,6 +96,7 @@ const dlog_malloc_func dlog_alloc = malloc; const dlog_free_func dlog_free = free; /* GLobal singleton dlogd configuration */ +extern nvlist_t *dlogd_props; nvlist_t *dlogd_props; static int stop = 0; From 03f83bfe7c0f78b0356cb2f113a76ecddf3883c3 Mon Sep 17 00:00:00 2001 From: Graeme Jenkinson Date: Tue, 26 Mar 2019 16:51:33 +0000 Subject: [PATCH 2/2] Ensure that the CPU on which the BEGIN probe fires is processed first. This accounts for the simplest case. Other cases where the END probe has already fired remain to be fixed. --- .../opensolaris/uts/common/dtrace/dtrace.c | 10 +++++----- .../opensolaris/uts/common/sys/dtrace_impl.h | 2 +- sys/cddl/dev/dtrace/dtrace_anon.c | 3 ++- sys/modules/ddtrace/ddtrace.c | 18 ++++++++++-------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index 2b410aa9fb5..a707386e604 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -15189,7 +15189,7 @@ dtrace_state_go(dtrace_state_t *state, processorid_t *cpu) state->dts_options[DTRACEOPT_GRABANON] = opt[DTRACEOPT_GRABANON]; - *cpu = dtrace_anon.dta_beganon; + *cpu = dtrace_anon.dta_state->dts_beganon; /* * If the anonymous state is active (as it almost certainly * is if the anonymous enabling ultimately matched anything), @@ -17363,7 +17363,8 @@ dtrace_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) /* * If we created any anonymous state, set it going now. */ - (void) dtrace_state_go(state, &dtrace_anon.dta_beganon); + (void) dtrace_state_go(state, + &dtrace_anon.dta_state->dts_beganon); } return (DDI_SUCCESS); @@ -18067,13 +18068,12 @@ dtrace_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv) } case DTRACEIOC_GO: { - processorid_t cpuid; - rval = dtrace_state_go(state, &cpuid); + rval = dtrace_state_go(state, &dtp->dts_beganon); if (rval != 0) return (rval); - if (copyout(&cpuid, (void *)arg, sizeof (cpuid)) != 0) + if (copyout(&dtp->dts_beganon, (void *)arg, sizeof(processorid_t)) != 0) return (EFAULT); return (0); diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h index 89b8bb065c4..4117603311b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h @@ -1177,6 +1177,7 @@ struct dtrace_state { size_t dts_nretained; /* number of retained enabs */ int dts_getf; /* number of getf() calls */ uint64_t dts_rstate[NCPU][2]; /* per-CPU random state */ + processorid_t dts_beganon; /* which CPU BEGIN ran on */ }; struct dtrace_dist { @@ -1244,7 +1245,6 @@ typedef struct dtrace_enabling { typedef struct dtrace_anon { dtrace_state_t *dta_state; /* DTrace consumer state */ dtrace_enabling_t *dta_enabling; /* pointer to enabling */ - processorid_t dta_beganon; /* which CPU BEGIN ran on */ } dtrace_anon_t; /* diff --git a/sys/cddl/dev/dtrace/dtrace_anon.c b/sys/cddl/dev/dtrace/dtrace_anon.c index b81ec5be3f1..34b02137f2e 100644 --- a/sys/cddl/dev/dtrace/dtrace_anon.c +++ b/sys/cddl/dev/dtrace/dtrace_anon.c @@ -79,6 +79,7 @@ dtrace_anon_init(void *dummy) /* * If we created any anonymous state, set it going now. */ - (void) dtrace_state_go(state, &dtrace_anon.dta_beganon); + (void) dtrace_state_go(state, + &dtrace_anon.dta_state->dts_beganon); } } diff --git a/sys/modules/ddtrace/ddtrace.c b/sys/modules/ddtrace/ddtrace.c index 452fc860a61..db5e29fde57 100644 --- a/sys/modules/ddtrace/ddtrace.c +++ b/sys/modules/ddtrace/ddtrace.c @@ -249,6 +249,7 @@ ddtrace_buffer_switch(dtrace_state_t *state, struct dlog_handle *handle) caddr_t cached; dtrace_bufdesc_t desc; dtrace_buffer_t *buf; + processorid_t cpu = state->dts_beganon; DL_ASSERT(state != NULL, ("DTrace state cannot be NULL\n")); DL_ASSERT(handle != NULL, ("DLog handle cannot be NULL\n")); @@ -260,11 +261,10 @@ ddtrace_buffer_switch(dtrace_state_t *state, struct dlog_handle *handle) * Persisting the buffer may involving splitting into portions portions * on a record boundary. */ - for (int cpu = 0; cpu < mp_ncpus; cpu++) { + for (int i = 0; i < mp_ncpus; i++) { - /* NOTE: - * Unlike in the BUFSNAP ioctl it is unnecessary to acquire - * dtrace_lock. + /* NOTE: Unlike in the BUFSNAP ioctl it is unnecessary to + * acquire dtrace_lock. */ buf = &state->dts_buffer[cpu]; @@ -307,6 +307,9 @@ ddtrace_buffer_switch(dtrace_state_t *state, struct dlog_handle *handle) */ if (desc.dtbd_size != 0) ddtrace_persist_trace(state, handle, &desc); + + /* Increment the CPU */ + cpu = (cpu + 1) % mp_ncpus; } } @@ -362,7 +365,7 @@ ddtrace_persist_trace(dtrace_state_t *state, struct dlog_handle *hdl, { dtrace_epid_t epid; size_t msg_start = 0, msg_size = 0, size = 0; - + DL_ASSERT(state != NULL, ("DTrace state cannot be NULL.")); DL_ASSERT(hdl != NULL, ("DLog handle cannot be NULL.")); DL_ASSERT(desc != NULL, @@ -371,7 +374,7 @@ ddtrace_persist_trace(dtrace_state_t *state, struct dlog_handle *hdl, ("ddtrace_persist_trace called with NULL buffer.")); DL_ASSERT(desc->dtbd_size != 0, ("ddtrace_persist_trace called with empty buffer.")); - + while (size < desc->dtbd_size) { epid = *(dtrace_epid_t *) ((uintptr_t) desc->dtbd_data + size); @@ -388,7 +391,6 @@ ddtrace_persist_trace(dtrace_state_t *state, struct dlog_handle *hdl, break; } - /* Check whether the record would take the msg_size * over the MTU configured for the distributed log. */ @@ -439,7 +441,7 @@ ddtrace_persist_trace(dtrace_state_t *state, struct dlog_handle *hdl, */ if (msg_size == desc->dtbd_size) { if (dlog_produce(hdl, - DDTRACE_KEY, strlen(DDTRACE_KEY), + DDTRACE_KEY, strlen(DDTRACE_KEY), &desc->dtbd_data[msg_start], msg_size) != 0) {