| 464 | /* Acquire reference to vmspace owned by another process. */ |
| 465 | |
| 466 | struct vmspace * |
| 467 | vmspace_acquire_ref(struct proc *p) |
| 468 | { |
| 469 | struct vmspace *vm; |
| 470 | |
| 471 | PROC_VMSPACE_LOCK(p); |
| 472 | vm = p->p_vmspace; |
| 473 | if (vm == NULL || !refcount_acquire_if_not_zero(&vm->vm_refcnt)) { |
| 474 | PROC_VMSPACE_UNLOCK(p); |
| 475 | return (NULL); |
| 476 | } |
| 477 | if (vm != p->p_vmspace) { |
| 478 | PROC_VMSPACE_UNLOCK(p); |
| 479 | vmspace_free(vm); |
| 480 | return (NULL); |
| 481 | } |
| 482 | PROC_VMSPACE_UNLOCK(p); |
| 483 | return (vm); |
| 484 | } |
| 485 | |
| 486 | /* |
| 487 | * Switch between vmspaces in an AIO kernel process. |
no test coverage detected