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

Function aio_daemon

freebsd/kern/vfs_aio.c:1066–1167  ·  view source on GitHub ↗

* The AIO daemon, most of the actual work is done in aio_process_*, * but the setup (and address space mgmt) is done in this routine. */

Source from the content-addressed store, hash-verified

1064 * but the setup (and address space mgmt) is done in this routine.
1065 */
1066static void
1067aio_daemon(void *_id)
1068{
1069 struct kaiocb *job;
1070 struct aioproc *aiop;
1071 struct kaioinfo *ki;
1072 struct proc *p;
1073 struct vmspace *myvm;
1074 struct thread *td = curthread;
1075 int id = (intptr_t)_id;
1076
1077 /*
1078 * Grab an extra reference on the daemon's vmspace so that it
1079 * doesn't get freed by jobs that switch to a different
1080 * vmspace.
1081 */
1082 p = td->td_proc;
1083 myvm = vmspace_acquire_ref(p);
1084
1085 KASSERT(p->p_textvp == NULL, ("kthread has a textvp"));
1086
1087 /*
1088 * Allocate and ready the aio control info. There is one aiop structure
1089 * per daemon.
1090 */
1091 aiop = uma_zalloc(aiop_zone, M_WAITOK);
1092 aiop->aioproc = p;
1093 aiop->aioprocflags = 0;
1094
1095 /*
1096 * Wakeup parent process. (Parent sleeps to keep from blasting away
1097 * and creating too many daemons.)
1098 */
1099 sema_post(&aio_newproc_sem);
1100
1101 mtx_lock(&aio_job_mtx);
1102 for (;;) {
1103 /*
1104 * Take daemon off of free queue
1105 */
1106 if (aiop->aioprocflags & AIOP_FREE) {
1107 TAILQ_REMOVE(&aio_freeproc, aiop, list);
1108 aiop->aioprocflags &= ~AIOP_FREE;
1109 }
1110
1111 /*
1112 * Check for jobs.
1113 */
1114 while ((job = aio_selectjob(aiop)) != NULL) {
1115 mtx_unlock(&aio_job_mtx);
1116
1117 ki = job->userproc->p_aioinfo;
1118 job->handle_fn(job);
1119
1120 mtx_lock(&aio_job_mtx);
1121 /* Decrement the active job count. */
1122 ki->kaio_active_count--;
1123 }

Callers

nothing calls this directly

Calls 12

vmspace_acquire_refFunction · 0.85
aio_selectjobFunction · 0.85
vmspace_switch_aioFunction · 0.85
mtx_assertFunction · 0.85
free_unrFunction · 0.85
vmspace_freeFunction · 0.85
refcount_loadFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
kproc_exitFunction · 0.70
uma_zallocFunction · 0.50
uma_zfreeFunction · 0.50

Tested by

no test coverage detected