| 669 | |
| 670 | #ifndef FSTACK |
| 671 | static 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, |
no test coverage detected