Date: Mon, 3 Jul 2006 14:56:20 GMT From: Howard Su <howardsu@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 100504 for review Message-ID: <200607031456.k63EuKf3098669@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=100504 Change 100504 by howardsu@su_laptop on 2006/07/03 14:55:32 Use FreeBSD zone allocator to support Solaris kmem call Affected files ... .. //depot/projects/dtrace/src/sys/cddl/kern/kmem.c#2 edit .. //depot/projects/dtrace/src/sys/contrib/opensolaris/compat/sys/kmem.h#2 edit Differences ... ==== //depot/projects/dtrace/src/sys/cddl/kern/kmem.c#2 (text+ko) ==== @@ -33,41 +33,3 @@ MALLOC_DECLARE(M_KMEM); MALLOC_DEFINE(M_KMEM, "kmem", "kmem hack"); - -/* XXX Hacks */ - -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_KMEM, M_WAITOK); - p->size = bufsize; - return(p); -} - -void * -kmem_cache_alloc(kmem_cache_t *a, int b) -{ - return (malloc(a->size, M_KMEM, M_WAITOK | M_ZERO)); -} - -void -kmem_cache_free(kmem_cache_t *a, void *b) -{ - free(b, M_KMEM); -} - -void -kmem_cache_destroy(kmem_cache_t *a) -{ - free(a, M_KMEM); -} ==== //depot/projects/dtrace/src/sys/contrib/opensolaris/compat/sys/kmem.h#2 (text+ko) ==== @@ -25,6 +25,7 @@ #define _OPENSOLARIS_COMPAT_SYS_KMEM_H #include <sys/vmem.h> +#include <vm/uma.h> #define KM_SLEEP M_WAITOK #define KM_NOSLEEP M_NOWAIT @@ -33,17 +34,14 @@ #define kmem_alloc(_a,_b) malloc(_a, M_KMEM, _b) #define kmem_free(_a,_b) free(_a, M_KMEM) -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 struct uma_zone kmem_cache_t; +#define kmem_cache_create(_name, _bufsize, _align, _ns0, _ns1, _ns2, _ns3, \ + _ns4, _flags) \ + uma_zcreate(_name, _bufsize, NULL, NULL, NULL, NULL, \ + _align, _flags) +#define kmem_cache_destroy(_a) uma_zdestroy(_a) +#define kmem_cache_alloc(_a, _flags) uma_zalloc(_a, _flags) +#define kmem_cache_free(_a, _b) uma_zfree(_a, _b) #endif /* _OPENSOLARIS_COMPAT_SYS_KMEM_H */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607031456.k63EuKf3098669>