PERFORCE change 133701 for review
John Birrell
jb at FreeBSD.org
Sat Jan 19 16:48:34 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=133701
Change 133701 by jb at jb_freebsd1 on 2008/01/20 00:47:57
peter@ pointed out that we have alloc_unr() to allocate unique
resource IDs which turns out to be exactly what is needed here.
Affected files ...
.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_clone.c#7 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_load.c#28 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_unload.c#24 edit
.. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/dtrace/dtrace.c#18 edit
.. //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/sys/dtrace_impl.h#15 edit
Differences ...
==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_clone.c#7 (text+ko) ====
@@ -50,7 +50,7 @@
return;
/* Allocate a unique minor number. */
- u = dtrace_minor++;
+ u = alloc_unr(dtrace_minor);
/* Clone the device to the new minor number. */
if (clone_create(&dtrace_clones, &dtrace_cdevsw, &u, dev, 0) != 0)
==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_load.c#28 (text+ko) ====
@@ -97,6 +97,9 @@
1, INT_MAX, 0);
#endif
+ dtrace_arena = new_unrhdr(1, INT_MAX, &dtrace_unr_mtx);
+ dtrace_minor = 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);
==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_unload.c#24 (text+ko) ====
@@ -122,6 +122,9 @@
kmem_cache_destroy(dtrace_state_cache);
+ delete_unrhdr(dtrace_arena);
+ delete_unrhdr(dtrace_minor);
+
if (dtrace_toxrange != NULL) {
kmem_free(dtrace_toxrange, 0);
dtrace_toxrange = NULL;
==== //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/dtrace/dtrace.c#18 (text) ====
@@ -196,8 +196,8 @@
static vmem_t *dtrace_minor; /* minor number arena */
static taskq_t *dtrace_taskq; /* task queue */
#else
-static u_long dtrace_arena; /* Probe ID number. */
-static u_long dtrace_minor; /* Minor device number. */
+static struct unrhdr *dtrace_arena; /* Probe ID number. */
+static struct unrhdr *dtrace_minor; /* Minor number. */
#endif
static dtrace_probe_t **dtrace_probes; /* array of all probes */
static int dtrace_nprobes; /* number of probes */
@@ -224,6 +224,8 @@
static dtrace_enabling_t *dtrace_retained; /* list of retained enablings */
static dtrace_dynvar_t dtrace_dynhash_sink; /* end of dynamic hash chains */
#if !defined(sun)
+static struct mtx dtrace_unr_mtx;
+MTX_SYSINIT(dtrace_unr_mtx, &dtrace_unr_mtx, "Unique resource identifier", MTX_DEF);
int dtrace_in_probe; /* non-zero if executing a probe */
#if defined(__i386__) || defined(__amd64__)
uintptr_t dtrace_in_probe_addr; /* Address of invop when already in probe */
@@ -7168,6 +7170,8 @@
kmem_free(probe->dtpr_name, strlen(probe->dtpr_name) + 1);
#if defined(sun)
vmem_free(dtrace_arena, (void *)(uintptr_t)(probe->dtpr_id), 1);
+#else
+ free_unr(dtrace_arena, probe->dtpr_id);
#endif
kmem_free(probe, sizeof (dtrace_probe_t));
}
@@ -7285,6 +7289,8 @@
kmem_free(probe, sizeof (dtrace_probe_t));
#if defined(sun)
vmem_free(dtrace_arena, (void *)((uintptr_t)i + 1), 1);
+#else
+ free_unr(dtrace_arena, i + 1);
#endif
}
@@ -7325,7 +7331,7 @@
id = (dtrace_id_t)(uintptr_t)vmem_alloc(dtrace_arena, 1,
VM_BESTFIT | VM_SLEEP);
#else
- id = ++dtrace_arena;
+ id = alloc_unr(dtrace_arena);
#endif
probe = kmem_zalloc(sizeof (dtrace_probe_t), KM_SLEEP);
@@ -9527,7 +9533,7 @@
aggid = (dtrace_aggid_t)(uintptr_t)vmem_alloc(state->dts_aggid_arena, 1,
VM_BESTFIT | VM_SLEEP);
#else
- aggid = ++(state->dts_aggid_arena);
+ aggid = alloc_unr(state->dts_aggid_arena);
#endif
if (aggid - 1 >= state->dts_naggregations) {
@@ -9579,6 +9585,8 @@
ASSERT(DTRACEACT_ISAGG(act->dta_kind));
#if defined(sun)
vmem_free(state->dts_aggid_arena, (void *)(uintptr_t)aggid, 1);
+#else
+ free_unr(state->dts_aggid_arena, aggid);
#endif
ASSERT(state->dts_aggregations[aggid - 1] == agg);
@@ -12410,7 +12418,7 @@
if (devp != NULL)
*devp = state->dts_dev;
#else
- state->dts_aggid_arena = 0;
+ state->dts_aggid_arena = new_unrhdr(1, INT_MAX, &dtrace_unr_mtx);
state->dts_dev = dev;
#endif
@@ -13200,11 +13208,15 @@
dtrace_format_destroy(state);
+ if (state->dts_aggid_arena != NULL) {
#if defined(sun)
- if (state->dts_aggid_arena != NULL) {
vmem_destroy(state->dts_aggid_arena);
+#else
+ delete_unrhdr(state->dts_aggid_arena);
+#endif
state->dts_aggid_arena = NULL;
}
+#if defined(sun)
ddi_soft_state_free(dtrace_softstate, minor);
vmem_free(dtrace_minor, (void *)(uintptr_t)minor, 1);
#endif
==== //depot/projects/dtrace/src/sys/contrib/opensolaris/uts/common/sys/dtrace_impl.h#15 (text) ====
@@ -1128,7 +1128,7 @@
#if defined(sun)
vmem_t *dts_aggid_arena; /* arena for aggregation IDs */
#else
- u_long dts_aggid_arena; /* arena for aggregation IDs */
+ 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 */
More information about the p4-projects
mailing list