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

Function _taskqueue_start_threads

freebsd/kern/subr_taskqueue.c:671–737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

669
670#ifndef FSTACK
671static int
672_taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
673 cpuset_t *mask, struct proc *p, const char *name, va_list ap)
674{
675 char ktname[MAXCOMLEN + 1];
676 struct thread *td;
677 struct taskqueue *tq;
678 int i, error;
679
680 if (count <= 0)
681 return (EINVAL);
682
683 vsnprintf(ktname, sizeof(ktname), name, ap);
684 tq = *tqp;
685
686 tq->tq_threads = malloc(sizeof(struct thread *) * count, M_TASKQUEUE,
687 M_NOWAIT | M_ZERO);
688 if (tq->tq_threads == NULL) {
689 printf("%s: no memory for %s threads\n", __func__, ktname);
690 return (ENOMEM);
691 }
692
693 for (i = 0; i < count; i++) {
694 if (count == 1)
695 error = kthread_add(taskqueue_thread_loop, tqp, p,
696 &tq->tq_threads[i], RFSTOPPED, 0, "%s", ktname);
697 else
698 error = kthread_add(taskqueue_thread_loop, tqp, p,
699 &tq->tq_threads[i], RFSTOPPED, 0,
700 "%s_%d", ktname, i);
701 if (error) {
702 /* should be ok to continue, taskqueue_free will dtrt */
703 printf("%s: kthread_add(%s): error %d", __func__,
704 ktname, error);
705 tq->tq_threads[i] = NULL; /* paranoid */
706 } else
707 tq->tq_tcount++;
708 }
709 if (tq->tq_tcount == 0) {
710 free(tq->tq_threads, M_TASKQUEUE);
711 tq->tq_threads = NULL;
712 return (ENOMEM);
713 }
714 for (i = 0; i < count; i++) {
715 if (tq->tq_threads[i] == NULL)
716 continue;
717 td = tq->tq_threads[i];
718 if (mask) {
719 error = cpuset_setthread(td->td_tid, mask);
720 /*
721 * Failing to pin is rarely an actual fatal error;
722 * it'll just affect performance.
723 */
724 if (error)
725 printf("%s: curthread=%llu: can't pin; "
726 "error=%d\n",
727 __func__,
728 (unsigned long long) td->td_tid,

Callers 3

taskqueue_start_threadsFunction · 0.85

Calls 8

vsnprintfFunction · 0.85
mallocFunction · 0.85
cpuset_setthreadFunction · 0.85
printfFunction · 0.70
kthread_addFunction · 0.70
freeFunction · 0.70
sched_prioFunction · 0.70
sched_addFunction · 0.70

Tested by

no test coverage detected