* Switch between vmspaces in an AIO kernel process. * * The new vmspace is either the vmspace of a user process obtained * from an active AIO request or the initial vmspace of the AIO kernel * process (when it is idling). Because user processes will block to * drain any active AIO requests before proceeding in exit() or * execve(), the reference count for vmspaces from AIO requests can * n
| 499 | * vmspace_acquire_ref() above. |
| 500 | */ |
| 501 | void |
| 502 | vmspace_switch_aio(struct vmspace *newvm) |
| 503 | { |
| 504 | struct vmspace *oldvm; |
| 505 | |
| 506 | /* XXX: Need some way to assert that this is an aio daemon. */ |
| 507 | |
| 508 | KASSERT(refcount_load(&newvm->vm_refcnt) > 0, |
| 509 | ("vmspace_switch_aio: newvm unreferenced")); |
| 510 | |
| 511 | oldvm = curproc->p_vmspace; |
| 512 | if (oldvm == newvm) |
| 513 | return; |
| 514 | |
| 515 | /* |
| 516 | * Point to the new address space and refer to it. |
| 517 | */ |
| 518 | curproc->p_vmspace = newvm; |
| 519 | refcount_acquire(&newvm->vm_refcnt); |
| 520 | |
| 521 | /* Activate the new mapping. */ |
| 522 | pmap_activate(curthread); |
| 523 | |
| 524 | vmspace_free(oldvm); |
| 525 | } |
| 526 | |
| 527 | void |
| 528 | _vm_map_lock(vm_map_t map, const char *file, int line) |
no test coverage detected