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

Function vslock

freebsd/vm/vm_glue.c:173–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173int
174vslock(void *addr, size_t len)
175{
176 vm_offset_t end, last, start;
177 vm_size_t npages;
178 int error;
179
180 last = (vm_offset_t)addr + len;
181 start = trunc_page((vm_offset_t)addr);
182 end = round_page(last);
183 if (last < (vm_offset_t)addr || end < (vm_offset_t)addr)
184 return (EINVAL);
185 npages = atop(end - start);
186 if (npages > vm_page_max_user_wired)
187 return (ENOMEM);
188 error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end,
189 VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
190 if (error == KERN_SUCCESS) {
191 curthread->td_vslock_sz += len;
192 return (0);
193 }
194
195 /*
196 * Return EFAULT on error to match copy{in,out}() behaviour
197 * rather than returning ENOMEM like mlock() would.
198 */
199 return (EFAULT);
200}
201
202void
203vsunlock(void *addr, size_t len)

Callers 2

ipfw_ctl3Function · 0.50
sysctl_wire_old_bufferFunction · 0.50

Calls 1

vm_map_wireFunction · 0.85

Tested by

no test coverage detected