svn commit: r260091 - in head/sys/cddl: contrib/opensolaris/uts/common/dtrace contrib/opensolaris/uts/common/sys dev/dtrace
Mark Johnston
markj at FreeBSD.org
Mon Dec 30 17:37:33 UTC 2013
Author: markj
Date: Mon Dec 30 17:37:32 2013
New Revision: 260091
URL: http://svnweb.freebsd.org/changeset/base/260091
Log:
Now that vmem(9) is available, use vmem arenas to allocate probe and
aggregation IDs, as is done in the upstream illumos code. This still
requires some FreeBSD-specific code, as our vmem API is not identical to the
one in illumos.
Submitted by: Mike Ma <mikemandarine at gmail.com>
Modified:
head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
head/sys/cddl/dev/dtrace/dtrace_load.c
head/sys/cddl/dev/dtrace/dtrace_unload.c
Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Mon Dec 30 17:26:06 2013 (r260090)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Mon Dec 30 17:37:32 2013 (r260091)
@@ -206,12 +206,11 @@ const char dtrace_zero[256] = { 0 }; /*
#if defined(sun)
static dev_info_t *dtrace_devi; /* device info */
#endif
-#if defined(sun)
static vmem_t *dtrace_arena; /* probe ID arena */
+#if defined(sun)
static vmem_t *dtrace_minor; /* minor number arena */
#else
static taskq_t *dtrace_taskq; /* task queue */
-static struct unrhdr *dtrace_arena; /* Probe ID number. */
#endif
static dtrace_probe_t **dtrace_probes; /* array of all probes */
static int dtrace_nprobes; /* number of probes */
@@ -7832,7 +7831,7 @@ dtrace_unregister(dtrace_provider_id_t i
#if defined(sun)
vmem_free(dtrace_arena, (void *)(uintptr_t)(probe->dtpr_id), 1);
#else
- free_unr(dtrace_arena, probe->dtpr_id);
+ vmem_free(dtrace_arena, (vmem_addr_t)(probe->dtpr_id), 1);
#endif
kmem_free(probe, sizeof (dtrace_probe_t));
}
@@ -7953,7 +7952,7 @@ dtrace_condense(dtrace_provider_id_t id)
#if defined(sun)
vmem_free(dtrace_arena, (void *)((uintptr_t)i + 1), 1);
#else
- free_unr(dtrace_arena, i + 1);
+ vmem_free(dtrace_arena, (vmem_addr_t)i + 1, 1);
#endif
}
@@ -7983,6 +7982,9 @@ dtrace_probe_create(dtrace_provider_id_t
dtrace_probe_t *probe, **probes;
dtrace_provider_t *provider = (dtrace_provider_t *)prov;
dtrace_id_t id;
+#if !defined(sun)
+ vmem_addr_t addr;
+#endif
if (provider == dtrace_provider) {
ASSERT(MUTEX_HELD(&dtrace_lock));
@@ -7992,9 +7994,10 @@ dtrace_probe_create(dtrace_provider_id_t
#if defined(sun)
id = (dtrace_id_t)(uintptr_t)vmem_alloc(dtrace_arena, 1,
- VM_BESTFIT | VM_SLEEP);
+ VM_BESTFIT | VM_WAITOK);
#else
- id = alloc_unr(dtrace_arena);
+ vmem_alloc(dtrace_arena, 1, M_BESTFIT | M_WAITOK, &addr);
+ id = (dtrace_id_t)addr;
#endif
probe = kmem_zalloc(sizeof (dtrace_probe_t), KM_SLEEP);
@@ -10045,6 +10048,9 @@ dtrace_ecb_aggregation_create(dtrace_ecb
dtrace_recdesc_t *frec;
dtrace_aggid_t aggid;
dtrace_state_t *state = ecb->dte_state;
+#if !defined(sun)
+ vmem_addr_t addr;
+#endif
agg = kmem_zalloc(sizeof (dtrace_aggregation_t), KM_SLEEP);
agg->dtag_ecb = ecb;
@@ -10184,7 +10190,8 @@ success:
aggid = (dtrace_aggid_t)(uintptr_t)vmem_alloc(state->dts_aggid_arena, 1,
VM_BESTFIT | VM_SLEEP);
#else
- aggid = alloc_unr(state->dts_aggid_arena);
+ vmem_alloc(state->dts_aggid_arena, 1, M_BESTFIT | M_WAITOK, &addr);
+ aggid = (dtrace_aggid_t)addr;
#endif
if (aggid - 1 >= state->dts_naggregations) {
@@ -10237,7 +10244,7 @@ dtrace_ecb_aggregation_destroy(dtrace_ec
#if defined(sun)
vmem_free(state->dts_aggid_arena, (void *)(uintptr_t)aggid, 1);
#else
- free_unr(state->dts_aggid_arena, aggid);
+ vmem_free(state->dts_aggid_arena, (vmem_addr_t)aggid, 1);
#endif
ASSERT(state->dts_aggregations[aggid - 1] == agg);
@@ -13205,7 +13212,7 @@ dtrace_state_create(struct cdev *dev)
if (dev != NULL) {
cr = dev->si_cred;
m = dev2unit(dev);
- }
+ }
/* Allocate memory for the state. */
state = kmem_zalloc(sizeof(dtrace_state_t), KM_SLEEP);
@@ -13217,7 +13224,12 @@ dtrace_state_create(struct cdev *dev)
#if defined(sun)
state->dts_aggid_arena = vmem_create(c, (void *)1, UINT32_MAX, 1,
NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
+#else
+ state->dts_aggid_arena = vmem_create(c, (vmem_addr_t)1, UINT32_MAX, 1,
+ 0, M_WAITOK);
+#endif
+#if defined(sun)
if (devp != NULL) {
major = getemajor(*devp);
} else {
@@ -13229,7 +13241,6 @@ dtrace_state_create(struct cdev *dev)
if (devp != NULL)
*devp = state->dts_dev;
#else
- state->dts_aggid_arena = new_unrhdr(1, INT_MAX, &dtrace_unr_mtx);
state->dts_dev = dev;
#endif
@@ -14036,11 +14047,7 @@ dtrace_state_destroy(dtrace_state_t *sta
dtrace_format_destroy(state);
if (state->dts_aggid_arena != NULL) {
-#if defined(sun)
vmem_destroy(state->dts_aggid_arena);
-#else
- delete_unrhdr(state->dts_aggid_arena);
-#endif
state->dts_aggid_arena = NULL;
}
#if defined(sun)
@@ -15375,7 +15382,7 @@ dtrace_module_unloaded(modctl_t *ctl, in
#if defined(sun)
vmem_free(dtrace_arena, (void *)(uintptr_t)probe->dtpr_id, 1);
#else
- free_unr(dtrace_arena, probe->dtpr_id);
+ vmem_free(dtrace_arena, (vmem_addr_t)probe->dtpr_id, 1);
#endif
kmem_free(probe, sizeof (dtrace_probe_t));
}
Modified: head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h Mon Dec 30 17:26:06 2013 (r260090)
+++ head/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h Mon Dec 30 17:37:32 2013 (r260091)
@@ -1139,11 +1139,7 @@ struct dtrace_state {
int dts_nspeculations; /* number of speculations */
int dts_naggregations; /* number of aggregations */
dtrace_aggregation_t **dts_aggregations; /* aggregation array */
-#if defined(sun)
vmem_t *dts_aggid_arena; /* arena for aggregation IDs */
-#else
- struct unrhdr *dts_aggid_arena; /* arena for aggregation IDs */
-#endif
uint64_t dts_errors; /* total number of errors */
uint32_t dts_speculations_busy; /* number of spec. busy */
uint32_t dts_speculations_unavail; /* number of spec unavail */
Modified: head/sys/cddl/dev/dtrace/dtrace_load.c
==============================================================================
--- head/sys/cddl/dev/dtrace/dtrace_load.c Mon Dec 30 17:26:06 2013 (r260090)
+++ head/sys/cddl/dev/dtrace/dtrace_load.c Mon Dec 30 17:37:32 2013 (r260091)
@@ -58,6 +58,9 @@ dtrace_load(void *dummy)
dtrace_taskq = taskq_create("dtrace_taskq", 1, maxclsyspri, 0, 0, 0);
+ dtrace_arena = vmem_create("dtrace", 1, UINT32_MAX, 1, 0,
+ M_WAITOK | M_BESTFIT);
+
/* Register callbacks for linker file load and unload events. */
dtrace_kld_load_tag = EVENTHANDLER_REGISTER(kld_load,
dtrace_kld_load, NULL, EVENTHANDLER_PRI_ANY);
@@ -85,8 +88,6 @@ dtrace_load(void *dummy)
ASSERT(MUTEX_HELD(&cpu_lock));
- dtrace_arena = new_unrhdr(1, INT_MAX, &dtrace_unr_mtx);
-
dtrace_state_cache = kmem_cache_create("dtrace_state_cache",
sizeof (dtrace_dstate_percpu_t) * NCPU, DTRACE_STATE_ALIGN,
NULL, NULL, NULL, NULL, NULL, 0);
Modified: head/sys/cddl/dev/dtrace/dtrace_unload.c
==============================================================================
--- head/sys/cddl/dev/dtrace/dtrace_unload.c Mon Dec 30 17:26:06 2013 (r260090)
+++ head/sys/cddl/dev/dtrace/dtrace_unload.c Mon Dec 30 17:37:32 2013 (r260091)
@@ -104,7 +104,7 @@ dtrace_unload()
kmem_cache_destroy(dtrace_state_cache);
- delete_unrhdr(dtrace_arena);
+ vmem_destroy(dtrace_arena);
if (dtrace_toxrange != NULL) {
kmem_free(dtrace_toxrange, 0);
More information about the svn-src-head
mailing list