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

Function soaio_kproc_loop

freebsd/kern/sys_socket.c:467–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465 "Maximum lifetime for idle aiod");
466
467static void
468soaio_kproc_loop(void *arg)
469{
470 struct proc *p;
471 struct vmspace *myvm;
472 struct task *task;
473 int error, id, pending;
474
475 id = (intptr_t)arg;
476
477 /*
478 * Grab an extra reference on the daemon's vmspace so that it
479 * doesn't get freed by jobs that switch to a different
480 * vmspace.
481 */
482 p = curproc;
483 myvm = vmspace_acquire_ref(p);
484
485 mtx_lock(&soaio_jobs_lock);
486 MPASS(soaio_starting > 0);
487 soaio_starting--;
488 for (;;) {
489 while (!STAILQ_EMPTY(&soaio_jobs)) {
490 task = STAILQ_FIRST(&soaio_jobs);
491 STAILQ_REMOVE_HEAD(&soaio_jobs, ta_link);
492 soaio_queued--;
493 pending = task->ta_pending;
494 task->ta_pending = 0;
495 mtx_unlock(&soaio_jobs_lock);
496
497 task->ta_func(task->ta_context, pending);
498
499 mtx_lock(&soaio_jobs_lock);
500 }
501 MPASS(soaio_queued == 0);
502
503 if (p->p_vmspace != myvm) {
504 mtx_unlock(&soaio_jobs_lock);
505 vmspace_switch_aio(myvm);
506 mtx_lock(&soaio_jobs_lock);
507 continue;
508 }
509
510 soaio_idle++;
511 error = mtx_sleep(&soaio_idle, &soaio_jobs_lock, 0, "-",
512 soaio_lifetime);
513 soaio_idle--;
514 if (error == EWOULDBLOCK && STAILQ_EMPTY(&soaio_jobs) &&
515 soaio_num_procs > soaio_target_procs)
516 break;
517 }
518 soaio_num_procs--;
519 mtx_unlock(&soaio_jobs_lock);
520 free_unr(soaio_kproc_unr, id);
521 kproc_exit(0);
522}
523
524static void

Callers

nothing calls this directly

Calls 6

vmspace_acquire_refFunction · 0.85
vmspace_switch_aioFunction · 0.85
free_unrFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
kproc_exitFunction · 0.70

Tested by

no test coverage detected