diff options
author | Jeff Roberson <jeff@FreeBSD.org> | 2002-04-30 04:26:34 +0000 |
---|---|---|
committer | Jeff Roberson <jeff@FreeBSD.org> | 2002-04-30 04:26:34 +0000 |
commit | 2cc35ff9c638b66bdc02de8f003c3d246b3cbba1 (patch) | |
tree | b4c7a4980a19a06cb96cd168f9300c8333294037 /sys/vm/uma_core.c | |
parent | 883ee9463e685cfad944f63eb5c8c800f96d80ca (diff) | |
download | src-2cc35ff9c638b66bdc02de8f003c3d246b3cbba1.tar.gz src-2cc35ff9c638b66bdc02de8f003c3d246b3cbba1.zip |
Move the implementation of M_ZERO into UMA so that it can be passed to
uma_zalloc and friends. Remove this functionality from the malloc wrapper.
Document this change in uma.h and adjust variable names in uma_core.
Notes
Notes:
svn path=/head/; revision=95766
Diffstat (limited to 'sys/vm/uma_core.c')
-rw-r--r-- | sys/vm/uma_core.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 2bb8f15ea5f8..53c1d5994dbd 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -1290,7 +1290,7 @@ uma_zdestroy(uma_zone_t zone) /* See uma.h */ void * -uma_zalloc_arg(uma_zone_t zone, void *udata, int wait) +uma_zalloc_arg(uma_zone_t zone, void *udata, int flags) { void *item; uma_cache_t cache; @@ -1323,6 +1323,8 @@ zalloc_start: CPU_UNLOCK(zone, cpu); if (zone->uz_ctor) zone->uz_ctor(item, zone->uz_size, udata); + if (flags & M_ZERO) + bzero(item, zone->uz_size); return (item); } else if (cache->uc_freebucket) { /* @@ -1389,7 +1391,7 @@ zalloc_start: if (bucket == NULL) bucket = uma_zalloc_internal(bucketzone, - NULL, wait, NULL); + NULL, flags, NULL); if (bucket != NULL) { #ifdef INVARIANTS @@ -1397,7 +1399,7 @@ zalloc_start: #endif bucket->ub_ptr = -1; - if (uma_zalloc_internal(zone, udata, wait, bucket)) + if (uma_zalloc_internal(zone, udata, flags, bucket)) goto zalloc_restart; else uma_zfree_internal(bucketzone, bucket, NULL, 0); @@ -1410,7 +1412,7 @@ zalloc_start: printf("uma_zalloc_arg: Bucketzone returned NULL\n"); #endif - return (uma_zalloc_internal(zone, udata, wait, NULL)); + return (uma_zalloc_internal(zone, udata, flags, NULL)); } /* @@ -1419,7 +1421,7 @@ zalloc_start: * Arguments * zone The zone to alloc for. * udata The data to be passed to the constructor. - * wait M_WAITOK or M_NOWAIT. + * flags M_WAITOK, M_NOWAIT, M_ZERO. * bucket The bucket to fill or NULL * * Returns @@ -1434,7 +1436,7 @@ zalloc_start: */ static void * -uma_zalloc_internal(uma_zone_t zone, void *udata, int wait, uma_bucket_t bucket) +uma_zalloc_internal(uma_zone_t zone, void *udata, int flags, uma_bucket_t bucket) { uma_slab_t slab; u_int8_t freei; @@ -1503,7 +1505,7 @@ new_slab: zone->uz_pages >= zone->uz_maxpages) { zone->uz_flags |= UMA_ZFLAG_FULL; - if (wait & M_WAITOK) + if (flags & M_WAITOK) msleep(zone, &zone->uz_lock, PVM, "zonelimit", 0); else goto alloc_fail; @@ -1512,7 +1514,7 @@ new_slab: } zone->uz_recurse++; - slab = slab_zalloc(zone, wait); + slab = slab_zalloc(zone, flags); zone->uz_recurse--; /* * We might not have been able to get a slab but another cpu @@ -1565,7 +1567,8 @@ new_slab: if (bucket != NULL) { /* Try to keep the buckets totally full, but don't block */ if (bucket->ub_ptr < zone->uz_count) { - wait = M_NOWAIT; + flags |= M_NOWAIT; + flags &= ~M_WAITOK; goto new_slab; } else zone->uz_fills--; @@ -1574,8 +1577,11 @@ new_slab: ZONE_UNLOCK(zone); /* Only construct at this time if we're not filling a bucket */ - if (bucket == NULL && zone->uz_ctor != NULL) + if (bucket == NULL && zone->uz_ctor != NULL) { zone->uz_ctor(item, zone->uz_size, udata); + if (flags & M_ZERO) + bzero(item, zone->uz_size); + } return (item); |