diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 6647027..a7b8b8f 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -112,6 +112,8 @@ static uma_zone_t slabrefzone; /* With refcounters (for UMA_ZONE_REFCNT) */ */ static uma_zone_t hashzone; +static uma_zone_t cachezone; + /* The boot-time adjusted value for cache line alignment. */ static int uma_align_cache = 64 - 1; @@ -1502,6 +1504,8 @@ zone_ctor(void *mem, int size, void *udata, int flags) return (0); } + zone->uz_cpu = zone_alloc_item(cachezone, NULL, M_WAITOK | M_ZERO); + zone->uz_count_max = BUCKET_SIZE_THRESHOLD / zone->uz_size; if (keg->uk_flags & UMA_ZONE_MAXBUCKET) zone->uz_count_max = BUCKET_MAX; @@ -1736,8 +1740,7 @@ uma_startup(void *bootmem, int boot_pages) printf("Creating uma zone headers zone and keg.\n"); #endif args.name = "UMA Zones"; - args.size = sizeof(struct uma_zone) + - (sizeof(struct uma_cache) * (mp_maxid + 1)); + args.size = sizeof(struct uma_zone); args.ctor = zone_ctor; args.dtor = zone_dtor; args.uminit = zero_init; @@ -1785,6 +1788,11 @@ uma_startup(void *bootmem, int boot_pages) NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZFLAG_INTERNAL); + cachezone = uma_zcreate("UMA Caches", + sizeof(struct uma_cache) * (mp_maxid + 1), + NULL, NULL, NULL, NULL, + UMA_ALIGN_CACHE, UMA_ZFLAG_INTERNAL); + bucket_init(); #if defined(UMA_MD_SMALL_ALLOC) && !defined(UMA_MD_SMALL_ALLOC_NEEDS_VM) diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h index 6d81e3d..71367b5 100644 --- a/sys/vm/uma_int.h +++ b/sys/vm/uma_int.h @@ -332,11 +332,7 @@ struct uma_zone { uint16_t uz_count; /* Highest value ub_ptr can have */ uint16_t uz_count_max; /* Highest value uz_count can have */ - /* - * This HAS to be the last item because we adjust the zone size - * based on NCPU and then allocate the space for the zones. - */ - struct uma_cache uz_cpu[1]; /* Per cpu caches */ + struct uma_cache *uz_cpu; /* Per cpu caches */ }; /*