PERFORCE change 95852 for review
John Birrell
jb at FreeBSD.org
Sat Apr 22 02:46:52 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=95852
Change 95852 by jb at jb_freebsd2 on 2006/04/22 02:46:20
Update my hacks to use the custom mutex and a dumber-than-dumb
vmem implementation that is expected to do nothing more than allocate
unique resource IDs. After 4 billion or so, bad things will happen,
so by that time we'd better have a different hack. 8-)
Affected files ...
.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_hacks.c#2 edit
.. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_hacks.h#2 edit
Differences ...
==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_hacks.c#2 (text+ko) ====
@@ -1,5 +1,37 @@
/* XXX Hacks.... */
+vmem_t *
+vmem_create(const char *name, void *base, size_t size, size_t quantum,
+ vmem_alloc_t *afunc, vmem_free_t *ffunc, vmem_t *source,
+ size_t qcache_max, int vmflag)
+{
+ return (malloc(sizeof(vmem_t), M_DTRACE, M_WAITOK | M_ZERO));
+}
+
+void *
+vmem_alloc(vmem_t *vmp, size_t size, int vmflag)
+{
+ /*
+ * Hope like hell that the caller only uses the value
+ * returned as an integer, not a pointer!
+ */
+ return ((void *) ++(*vmp));
+}
+
+void
+vmem_free(vmem_t *vmp, void *vaddr, size_t size)
+{
+ /*
+ * Nothing to do here. We didn't really allocate memory
+ * in the first place. 8-)
+ */
+}
+void
+vmem_destroy(vmem_t *vmp)
+{
+ free(vmp, M_DTRACE);
+}
+
dtrace_cacheid_t dtrace_predcache_id;
void *hack_refs[] =
@@ -61,9 +93,6 @@
void
dtrace_membar_producer(void)
{
- int i;
- for (i = 0; i < sizeof(hack_refs) / sizeof(hack_refs[0]); i++)
- printf("%p\n",hack_refs[i]);
}
void
dtrace_membar_consumer(void)
@@ -100,16 +129,6 @@
dtrace_interrupt_enable(dtrace_icookie_t a)
{
}
-hrtime_t
-dtrace_gethrestime(void)
-{
- return 0;
-}
-hrtime_t
-dtrace_gethrtime(void)
-{
- return 0;
-}
void
dtrace_getpcstack(pc_t *a, int b, int c, uint32_t *d)
{
@@ -138,20 +157,6 @@
{
return 0;
}
-void
-vmem_free(vmem_t *a, void *b, size_t c)
-{
-}
-void *
-vmem_alloc(vmem_t *a, size_t b, int c)
-{
- return NULL;
-}
-vmem_t *
-vmem_create(const char *a, void *b, size_t c, size_t d, vmem_alloc_t *e, vmem_free_t *f, vmem_t *g, size_t h, int i)
-{
- return NULL;
-}
boolean_t
priv_policy_only(const cred_t *a, int b, boolean_t c)
{
==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_hacks.h#2 (text+ko) ====
@@ -7,11 +7,23 @@
#define CPU curthread
#define cpu_id td_oncpu
-typedef struct mtx kmutex_t;
+#define VM_SLEEP 0x00000000 /* same as KM_SLEEP */
+#define VM_BESTFIT 0x00000100
+#define VMC_IDENTIFIER 0x00040000 /* not backed by memory */
+typedef void *(vmem_alloc_t)(vmem_t *, size_t, int);
+typedef void (vmem_free_t)(vmem_t *, void *, size_t);
+vmem_t *vmem_create(const char *, void *, size_t, size_t,
+ vmem_alloc_t *, vmem_free_t *, vmem_t *, size_t, int);
+void *vmem_alloc(vmem_t *, size_t, int);
+void vmem_free(vmem_t *, void *, size_t);
+void vmem_destroy(vmem_t *);
+
+typedef dtrace_mutex_t kmutex_t;
+#define mutex_enter(_a) dtrace_mutex_lock(_a)
+#define mutex_exit(_a) dtrace_mutex_unlock(_a)
+
#define crgetuid(_a) _a->cr_uid
#define crgetzoneid(_a) 0
-#define mutex_enter(_a) mtx_lock(_a)
-#define mutex_exit(_a) mtx_unlock(_a)
#define KM_SLEEP M_WAITOK
#define KM_NOSLEEP M_NOWAIT
#define kmem_zalloc(_a,_b) malloc(_a, M_DTRACE, _b | M_ZERO)
More information about the p4-projects
mailing list