From owner-p4-projects@FreeBSD.ORG Sat Apr 22 02:46:52 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EA86216A403; Sat, 22 Apr 2006 02:46:51 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ADA6F16A401 for ; Sat, 22 Apr 2006 02:46:51 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7662743D45 for ; Sat, 22 Apr 2006 02:46:51 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3M2kpM4085584 for ; Sat, 22 Apr 2006 02:46:51 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3M2kp6s085581 for perforce@freebsd.org; Sat, 22 Apr 2006 02:46:51 GMT (envelope-from jb@freebsd.org) Date: Sat, 22 Apr 2006 02:46:51 GMT Message-Id: <200604220246.k3M2kp6s085581@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 95852 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Apr 2006 02:46:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=95852 Change 95852 by jb@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)