* Zone header ctor. This initializes all fields, locks, etc. * * Arguments/Returns follow uma_ctor specifications * udata Actually uma_zctor_args */
| 2611 | * udata Actually uma_zctor_args |
| 2612 | */ |
| 2613 | static int |
| 2614 | zone_ctor(void *mem, int size, void *udata, int flags) |
| 2615 | { |
| 2616 | struct uma_zone_count cnt; |
| 2617 | struct uma_zctor_args *arg = udata; |
| 2618 | uma_zone_domain_t zdom; |
| 2619 | uma_zone_t zone = mem; |
| 2620 | uma_zone_t z; |
| 2621 | uma_keg_t keg; |
| 2622 | int i; |
| 2623 | |
| 2624 | bzero(zone, size); |
| 2625 | zone->uz_name = arg->name; |
| 2626 | zone->uz_ctor = arg->ctor; |
| 2627 | zone->uz_dtor = arg->dtor; |
| 2628 | zone->uz_init = NULL; |
| 2629 | zone->uz_fini = NULL; |
| 2630 | zone->uz_sleeps = 0; |
| 2631 | zone->uz_bucket_size = 0; |
| 2632 | zone->uz_bucket_size_min = 0; |
| 2633 | zone->uz_bucket_size_max = BUCKET_MAX; |
| 2634 | zone->uz_flags = (arg->flags & UMA_ZONE_SMR); |
| 2635 | zone->uz_warning = NULL; |
| 2636 | /* The domain structures follow the cpu structures. */ |
| 2637 | zone->uz_bucket_max = ULONG_MAX; |
| 2638 | timevalclear(&zone->uz_ratecheck); |
| 2639 | |
| 2640 | /* Count the number of duplicate names. */ |
| 2641 | cnt.name = arg->name; |
| 2642 | cnt.count = 0; |
| 2643 | zone_foreach(zone_count, &cnt); |
| 2644 | zone->uz_namecnt = cnt.count; |
| 2645 | ZONE_CROSS_LOCK_INIT(zone); |
| 2646 | |
| 2647 | for (i = 0; i < vm_ndomains; i++) { |
| 2648 | zdom = ZDOM_GET(zone, i); |
| 2649 | ZDOM_LOCK_INIT(zone, zdom, (arg->flags & UMA_ZONE_MTXCLASS)); |
| 2650 | STAILQ_INIT(&zdom->uzd_buckets); |
| 2651 | } |
| 2652 | |
| 2653 | #ifdef INVARIANTS |
| 2654 | if (arg->uminit == trash_init && arg->fini == trash_fini) |
| 2655 | zone->uz_flags |= UMA_ZFLAG_TRASH | UMA_ZFLAG_CTORDTOR; |
| 2656 | #endif |
| 2657 | |
| 2658 | /* |
| 2659 | * This is a pure cache zone, no kegs. |
| 2660 | */ |
| 2661 | if (arg->import) { |
| 2662 | KASSERT((arg->flags & UMA_ZFLAG_CACHE) != 0, |
| 2663 | ("zone_ctor: Import specified for non-cache zone.")); |
| 2664 | zone->uz_flags = arg->flags; |
| 2665 | zone->uz_size = arg->size; |
| 2666 | zone->uz_import = arg->import; |
| 2667 | zone->uz_release = arg->release; |
| 2668 | zone->uz_arg = arg->arg; |
| 2669 | #ifdef NUMA |
| 2670 | /* |
no test coverage detected