MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mallocinit

Function mallocinit

freebsd/kern/kern_malloc.c:1164–1199  ·  view source on GitHub ↗

* Initialize the kernel memory allocator */ ARGSUSED*/

Source from the content-addressed store, hash-verified

1162 */
1163/* ARGSUSED*/
1164static void
1165mallocinit(void *dummy)
1166{
1167 int i;
1168 uint8_t indx;
1169
1170 mtx_init(&malloc_mtx, "malloc", NULL, MTX_DEF);
1171
1172 kmeminit();
1173
1174 if (kmem_zmax < PAGE_SIZE || kmem_zmax > KMEM_ZMAX)
1175 kmem_zmax = KMEM_ZMAX;
1176
1177 for (i = 0, indx = 0; kmemzones[indx].kz_size != 0; indx++) {
1178 int size = kmemzones[indx].kz_size;
1179 const char *name = kmemzones[indx].kz_name;
1180 size_t align;
1181 int subzone;
1182
1183 align = UMA_ALIGN_PTR;
1184 if (powerof2(size) && size > sizeof(void *))
1185 align = MIN(size, PAGE_SIZE) - 1;
1186 for (subzone = 0; subzone < numzones; subzone++) {
1187 kmemzones[indx].kz_zone[subzone] =
1188 uma_zcreate(name, size,
1189#ifdef INVARIANTS
1190 mtrash_ctor, mtrash_dtor, mtrash_init, mtrash_fini,
1191#else
1192 NULL, NULL, NULL, NULL,
1193#endif
1194 align, UMA_ZONE_MALLOC);
1195 }
1196 for (;i <= size; i+= KMEM_ZBASE)
1197 kmemsize[i >> KMEM_ZSHIFT] = indx;
1198 }
1199}
1200SYSINIT(kmem, SI_SUB_KMEM, SI_ORDER_SECOND, mallocinit, NULL);
1201
1202void

Callers

nothing calls this directly

Calls 3

mtx_initFunction · 0.85
kmeminitFunction · 0.85
uma_zcreateFunction · 0.85

Tested by

no test coverage detected