Date: Sun, 7 May 2006 23:10:18 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 96803 for review Message-ID: <200605072310.k47NAIGE080800@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96803 Change 96803 by jb@jb_freebsd2 on 2006/05/07 23:09:38 Move the vmem and kmem hacks out into separate files that can be filled in later with something less hackish. Affected files ... .. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_hacks.c#13 edit .. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_hacks.h#12 edit .. //depot/projects/dtrace/src/sys/cddl/kern/kmem.c#1 add .. //depot/projects/dtrace/src/sys/cddl/kern/vmem.c#1 add .. //depot/projects/dtrace/src/sys/contrib/opensolaris/compat/sys/kmem.h#1 add .. //depot/projects/dtrace/src/sys/contrib/opensolaris/compat/sys/vmem.h#1 add Differences ... ==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_hacks.c#13 (text+ko) ==== @@ -1,69 +1,5 @@ /* 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); -} -kmem_cache_t * -kmem_cache_create( - char *name, /* descriptive name for this cache */ - size_t bufsize, /* size of the objects it manages */ - size_t align, /* required object alignment */ - int (*constructor)(void *, void *, int), /* object constructor */ - void (*destructor)(void *, void *), /* object destructor */ - void (*reclaim)(void *), /* memory reclaim callback */ - void *private, /* pass-thru arg for constr/destr/reclaim */ - vmem_t *vmp, /* vmem source for slab allocation */ - int cflags) /* cache creation flags */ - -{ - kmem_cache_t *p = malloc(sizeof(kmem_cache_t), M_DTRACE, M_WAITOK); - p->size = bufsize; - return(p); -} -void * -kmem_cache_alloc(kmem_cache_t *a, int b) -{ - return (malloc(a->size, M_DTRACE, M_WAITOK | M_ZERO)); -} -void -kmem_cache_free(kmem_cache_t *a, void *b) -{ - free(b, M_DTRACE); -} -void -kmem_cache_destroy(kmem_cache_t *a) -{ - free(a, M_DTRACE); -} - dtrace_cacheid_t dtrace_predcache_id; void *hack_refs[] = ==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_hacks.h#12 (text+ko) ==== @@ -7,17 +7,6 @@ #define CPU curthread #define cpu_id td_oncpu -#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 *); - #define t_dtrace_start td_dtrace_start #define t_dtrace_vtime td_dtrace_vtime #define t_predcache td_predcache @@ -37,11 +26,6 @@ #define crgetuid(_a) _a->cr_uid #define crgetzoneid(_a) 0 #define SNOCD 0 -#define KM_SLEEP M_WAITOK -#define KM_NOSLEEP M_NOWAIT -#define kmem_zalloc(_a,_b) malloc(_a, M_DTRACE, _b | M_ZERO) -#define kmem_alloc(_a,_b) malloc(_a, M_DTRACE, _b) -#define kmem_free(_a,_b) free(_a, M_DTRACE) #define NCPU (mp_maxid + 1) #define delay(_a) DELAY(_a) #define vuprintf vprintf @@ -61,7 +45,6 @@ #define PRIV_PROC_OWNER (1UL << 4) #define PRIV_PROC_ZONE (1UL << 5) #define PRIV_ALL ~0UL -typedef struct pcpu cpu_t; typedef struct __dev_info *dev_info_t; typedef int minor_t; typedef int major_t; @@ -110,18 +93,6 @@ #define PRIV_POLICY_ONLY(cred, priv, all) \ priv_policy_only((cred), (priv), (all)) -typedef struct kmem_cache { - size_t size; -} kmem_cache_t; -kmem_cache_t *kmem_cache_create(char *, size_t, size_t, - int (*)(void *, void *, int), void (*)(void *, void *), - void (*)(void *), void *, vmem_t *, int); -void kmem_cache_destroy(kmem_cache_t *); -void *kmem_cache_alloc(kmem_cache_t *, int); -void kmem_cache_free(kmem_cache_t *, void *); -uint64_t kmem_cache_stat(kmem_cache_t *, char *); -void kmem_cache_reap_now(kmem_cache_t *); - typedef enum kdi_dtrace_set { KDI_DTSET_DTRACE_ACTIVATE, KDI_DTSET_DTRACE_DEACTIVATE,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605072310.k47NAIGE080800>