| 692 | } |
| 693 | |
| 694 | void * |
| 695 | malloc_domainset(size_t size, struct malloc_type *mtp, struct domainset *ds, |
| 696 | int flags) |
| 697 | { |
| 698 | struct vm_domainset_iter di; |
| 699 | caddr_t va; |
| 700 | int domain; |
| 701 | int indx; |
| 702 | #ifdef DEBUG_REDZONE |
| 703 | unsigned long osize = size; |
| 704 | #endif |
| 705 | |
| 706 | MPASS((flags & M_EXEC) == 0); |
| 707 | |
| 708 | #ifdef MALLOC_DEBUG |
| 709 | va = NULL; |
| 710 | if (malloc_dbg(&va, &size, mtp, flags) != 0) |
| 711 | return (va); |
| 712 | #endif |
| 713 | |
| 714 | if (__predict_false(size > kmem_zmax)) |
| 715 | return (malloc_large(&size, mtp, DOMAINSET_RR(), flags |
| 716 | DEBUG_REDZONE_ARG)); |
| 717 | |
| 718 | vm_domainset_iter_policy_init(&di, ds, &domain, &flags); |
| 719 | do { |
| 720 | va = malloc_domain(&size, &indx, mtp, domain, flags); |
| 721 | } while (va == NULL && vm_domainset_iter_policy(&di, &domain) == 0); |
| 722 | malloc_type_zone_allocated(mtp, va == NULL ? 0 : size, indx); |
| 723 | if (__predict_false(va == NULL)) { |
| 724 | KASSERT((flags & M_WAITOK) == 0, |
| 725 | ("malloc(M_WAITOK) returned NULL")); |
| 726 | } |
| 727 | #ifdef DEBUG_REDZONE |
| 728 | if (va != NULL) |
| 729 | va = redzone_setup(va, osize); |
| 730 | #endif |
| 731 | return (va); |
| 732 | } |
| 733 | |
| 734 | /* |
| 735 | * Allocate an executable area. |
no test coverage detected