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

Function vmem_import

freebsd/kern/subr_vmem.c:906–937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

904}
905
906static int
907vmem_import(vmem_t *vm, vmem_size_t size, vmem_size_t align, int flags)
908{
909 vmem_addr_t addr;
910 int error;
911
912 if (vm->vm_importfn == NULL)
913 return (EINVAL);
914
915 /*
916 * To make sure we get a span that meets the alignment we double it
917 * and add the size to the tail. This slightly overestimates.
918 */
919 if (align != vm->vm_quantum_mask + 1)
920 size = (align * 2) + size;
921 size = roundup(size, vm->vm_import_quantum);
922
923 if (vm->vm_limit != 0 && vm->vm_limit < vm->vm_size + size)
924 return (ENOMEM);
925
926 bt_save(vm);
927 VMEM_UNLOCK(vm);
928 error = (vm->vm_importfn)(vm->vm_arg, size, flags, &addr);
929 VMEM_LOCK(vm);
930 bt_restore(vm);
931 if (error)
932 return (ENOMEM);
933
934 vmem_add1(vm, addr, size, BT_TYPE_SPAN);
935
936 return 0;
937}
938
939/*
940 * vmem_fit: check if a bt can satisfy the given restrictions.

Callers 1

vmem_try_fetchFunction · 0.85

Calls 3

bt_saveFunction · 0.85
bt_restoreFunction · 0.85
vmem_add1Function · 0.85

Tested by

no test coverage detected