Date: Sat, 22 Apr 2006 23:37:33 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 95906 for review Message-ID: <200604222337.k3MNbXTh021196@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95906 Change 95906 by jb@jb_freebsd2 on 2006/04/22 23:37:01 Get dtrace_state_create() and dtrace_state_destroy() working, except in the anonymous case. More work is required for that. Affected files ... .. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_state.c#2 edit Differences ... ==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_state.c#2 (text+ko) ==== @@ -176,10 +176,19 @@ } dtrace_state_t * +#if defined(sun) dtrace_state_create(dev_t *devp, cred_t *cr) +#else +dtrace_state_create(struct cdev *dev) +#endif { - minor_t minor; +#if defined(sun) + minor_t m; major_t major; +#else + cred_t *cr = dev->si_cred; + int m = minor(dev); +#endif char c[30]; dtrace_state_t *state; dtrace_optval_t *opt; @@ -188,31 +197,43 @@ ASSERT(MUTEX_HELD(&dtrace_lock)); ASSERT(MUTEX_HELD(&cpu_lock)); - minor = (minor_t)(uintptr_t)vmem_alloc(dtrace_minor, 1, +#if defined(sun) + m = (minor_t)(uintptr_t)vmem_alloc(dtrace_minor, 1, VM_BESTFIT | VM_SLEEP); - if (ddi_soft_state_zalloc(dtrace_softstate, minor) != DDI_SUCCESS) { - vmem_free(dtrace_minor, (void *)(uintptr_t)minor, 1); + if (ddi_soft_state_zalloc(dtrace_softstate, m) != DDI_SUCCESS) { + vmem_free(dtrace_minor, (void *)(uintptr_t)m, 1); return (NULL); } - state = ddi_get_soft_state(dtrace_softstate, minor); + state = ddi_get_soft_state(dtrace_softstate, m); state->dts_epid = DTRACE_EPIDNONE + 1; +#else + /* Allocate memory for the state. */ + state = malloc(sizeof(dtrace_state_t), M_DTRACE, M_WAITOK | M_ZERO); - (void) snprintf(c, sizeof (c), "dtrace_aggid_%d", minor); + /* Save the pointer to the state. */ + dev->si_drv1 = state; +#endif + + (void) snprintf(c, sizeof (c), "dtrace_aggid_%d", m); state->dts_aggid_arena = vmem_create(c, (void *)1, UINT32_MAX, 1, NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER); +#if defined(sun) if (devp != NULL) { major = getemajor(*devp); } else { major = ddi_driver_major(dtrace_devi); } - state->dts_dev = makedevice(major, minor); + state->dts_dev = makedevice(major, m); if (devp != NULL) *devp = state->dts_dev; +#else + state->dts_dev = dev; +#endif /* * We allocate NCPU buffers. On the one hand, this can be quite @@ -222,8 +243,10 @@ */ state->dts_buffer = kmem_zalloc(bufsize, KM_SLEEP); state->dts_aggbuffer = kmem_zalloc(bufsize, KM_SLEEP); +#ifdef DOODAD state->dts_cleaner = CYCLIC_NONE; state->dts_deadman = CYCLIC_NONE; +#endif state->dts_vstate.dtvs_state = state; for (i = 0; i < DTRACEOPT_MAX; i++) @@ -307,11 +330,13 @@ * we can do destructive things to processes which * have altered credentials. */ +#ifdef DOODAD if (priv_isequalset(priv_getset(cr, PRIV_EFFECTIVE), cr->cr_zone->zone_privset)) { state->dts_cred.dcr_action |= DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG; } +#endif } /* @@ -352,11 +377,13 @@ * we can do destructive things to processes which * have altered credentials. */ +#ifdef DOODAD if (priv_isequalset(priv_getset(cr, PRIV_EFFECTIVE), cr->cr_zone->zone_privset)) { state->dts_cred.dcr_action |= DTRACE_CRA_PROC_DESTRUCTIVE_CREDCHG; } +#endif } /* @@ -499,8 +526,10 @@ dtrace_optval_t *opt = state->dts_options, sz, nspec; dtrace_speculation_t *spec; dtrace_buffer_t *buf; +#ifdef DOODAD cyc_handler_t hdlr; cyc_time_t when; +#endif int rval = 0, i, bufsize = NCPU * sizeof (dtrace_buffer_t); dtrace_icookie_t cookie; @@ -678,24 +707,36 @@ if (opt[DTRACEOPT_CLEANRATE] > dtrace_cleanrate_max) opt[DTRACEOPT_CLEANRATE] = dtrace_cleanrate_max; +#ifdef DOODAD hdlr.cyh_func = (cyc_func_t)dtrace_state_clean; hdlr.cyh_arg = state; hdlr.cyh_level = CY_LOW_LEVEL; +#endif +#ifdef DOODAD when.cyt_when = 0; when.cyt_interval = opt[DTRACEOPT_CLEANRATE]; +#endif +#ifdef DOODAD state->dts_cleaner = cyclic_add(&hdlr, &when); +#endif +#ifdef DOODAD hdlr.cyh_func = (cyc_func_t)dtrace_state_deadman; hdlr.cyh_arg = state; hdlr.cyh_level = CY_LOW_LEVEL; +#endif +#ifdef DOODAD when.cyt_when = 0; when.cyt_interval = dtrace_deadman_interval; +#endif state->dts_alive = state->dts_laststatus = dtrace_gethrtime(); +#ifdef DOODAD state->dts_deadman = cyclic_add(&hdlr, &when); +#endif state->dts_activity = DTRACE_ACTIVITY_WARMUP; @@ -706,7 +747,9 @@ * level) and to manually activate the buffer for this CPU. */ cookie = dtrace_interrupt_disable(); +#ifdef DOODAD *cpu = CPU->cpu_id; +#endif ASSERT(state->dts_buffer[*cpu].dtb_flags & DTRACEBUF_INACTIVE); state->dts_buffer[*cpu].dtb_flags &= ~DTRACEBUF_INACTIVE; @@ -878,8 +921,12 @@ { dtrace_ecb_t *ecb; dtrace_vstate_t *vstate = &state->dts_vstate; +#if defined(sun) minor_t minor = getminor(state->dts_dev); int i, bufsize = NCPU * sizeof (dtrace_buffer_t); +#else + int i; +#endif dtrace_speculation_t *spec = state->dts_speculations; int nspec = state->dts_nspeculations; uint32_t match; @@ -954,21 +1001,21 @@ for (i = 0; i < nspec; i++) dtrace_buffer_free(spec[i].dtsp_buffer); +#ifdef DOODAD if (state->dts_cleaner != CYCLIC_NONE) cyclic_remove(state->dts_cleaner); if (state->dts_deadman != CYCLIC_NONE) cyclic_remove(state->dts_deadman); +#endif dtrace_dstate_fini(&vstate->dtvs_dynvars); dtrace_vstate_fini(vstate); kmem_free(state->dts_ecbs, state->dts_necbs * sizeof (dtrace_ecb_t *)); if (state->dts_aggregations != NULL) { -#ifdef DEBUG for (i = 0; i < state->dts_naggregations; i++) ASSERT(state->dts_aggregations[i] == NULL); -#endif ASSERT(state->dts_naggregations > 0); kmem_free(state->dts_aggregations, state->dts_naggregations * sizeof (dtrace_aggregation_t *)); @@ -985,6 +1032,8 @@ dtrace_format_destroy(state); vmem_destroy(state->dts_aggid_arena); +#if defined(sun) ddi_soft_state_free(dtrace_softstate, minor); vmem_free(dtrace_minor, (void *)(uintptr_t)minor, 1); +#endif }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604222337.k3MNbXTh021196>