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

Function vmem_init

freebsd/kern/subr_vmem.c:1235–1283  ·  view source on GitHub ↗

* vmem_init: Initializes vmem arena. */

Source from the content-addressed store, hash-verified

1233 * vmem_init: Initializes vmem arena.
1234 */
1235vmem_t *
1236vmem_init(vmem_t *vm, const char *name, vmem_addr_t base, vmem_size_t size,
1237 vmem_size_t quantum, vmem_size_t qcache_max, int flags)
1238{
1239 vmem_size_t i;
1240
1241 MPASS(quantum > 0);
1242 MPASS((quantum & (quantum - 1)) == 0);
1243
1244 bzero(vm, sizeof(*vm));
1245
1246 VMEM_CONDVAR_INIT(vm, name);
1247 VMEM_LOCK_INIT(vm, name);
1248 vm->vm_nfreetags = 0;
1249 LIST_INIT(&vm->vm_freetags);
1250 strlcpy(vm->vm_name, name, sizeof(vm->vm_name));
1251 vm->vm_quantum_mask = quantum - 1;
1252 vm->vm_quantum_shift = flsl(quantum) - 1;
1253 vm->vm_nbusytag = 0;
1254 vm->vm_size = 0;
1255 vm->vm_limit = 0;
1256 vm->vm_inuse = 0;
1257 qc_init(vm, qcache_max);
1258
1259 TAILQ_INIT(&vm->vm_seglist);
1260 vm->vm_cursor.bt_start = vm->vm_cursor.bt_size = 0;
1261 vm->vm_cursor.bt_type = BT_TYPE_CURSOR;
1262 TAILQ_INSERT_TAIL(&vm->vm_seglist, &vm->vm_cursor, bt_seglist);
1263
1264 for (i = 0; i < VMEM_MAXORDER; i++)
1265 LIST_INIT(&vm->vm_freelist[i]);
1266
1267 memset(&vm->vm_hash0, 0, sizeof(vm->vm_hash0));
1268 vm->vm_hashsize = VMEM_HASHSIZE_MIN;
1269 vm->vm_hashlist = vm->vm_hash0;
1270
1271 if (size != 0) {
1272 if (vmem_add(vm, base, size, flags) != 0) {
1273 vmem_destroy1(vm);
1274 return NULL;
1275 }
1276 }
1277
1278 mtx_lock(&vmem_list_lock);
1279 LIST_INSERT_HEAD(&vmem_list, vm, vm_alllist);
1280 mtx_unlock(&vmem_list_lock);
1281
1282 return vm;
1283}
1284
1285/*
1286 * vmem_create: create an arena.

Callers 4

vmem_createFunction · 0.85
vm_ksubmap_initFunction · 0.85
memguard_initFunction · 0.85
kmem_initFunction · 0.85

Calls 9

bzeroFunction · 0.85
qc_initFunction · 0.85
memsetFunction · 0.85
vmem_addFunction · 0.85
vmem_destroy1Function · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
strlcpyFunction · 0.50
flslFunction · 0.50

Tested by

no test coverage detected