2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2000 Doug Rabson
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/param.h>
30 #include <sys/systm.h>
32 #include <sys/cpuset.h>
33 #include <sys/interrupt.h>
34 #include <sys/kernel.h>
35 #include <sys/kthread.h>
36 #include <sys/libkern.h>
37 #include <sys/limits.h>
39 #include <sys/malloc.h>
40 #include <sys/mutex.h>
42 #include <sys/epoch.h>
43 #include <sys/sched.h>
45 #include <sys/taskqueue.h>
46 #include <sys/unistd.h>
47 #include <machine/stdarg.h>
49 static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues");
50 static void *taskqueue_giant_ih;
51 static void *taskqueue_ih;
52 static void taskqueue_fast_enqueue(void *);
53 static void taskqueue_swi_enqueue(void *);
54 static void taskqueue_swi_giant_enqueue(void *);
56 struct taskqueue_busy {
57 struct task *tb_running;
60 LIST_ENTRY(taskqueue_busy) tb_link;
64 STAILQ_HEAD(, task) tq_queue;
65 LIST_HEAD(, taskqueue_busy) tq_active;
69 struct mtx_padalign tq_mutex;
70 taskqueue_enqueue_fn tq_enqueue;
73 struct thread **tq_threads;
77 taskqueue_callback_fn tq_callbacks[TASKQUEUE_NUM_CALLBACKS];
78 void *tq_cb_contexts[TASKQUEUE_NUM_CALLBACKS];
81 #define TQ_FLAGS_ACTIVE (1 << 0)
82 #define TQ_FLAGS_BLOCKED (1 << 1)
83 #define TQ_FLAGS_UNLOCKED_ENQUEUE (1 << 2)
85 #define DT_CALLOUT_ARMED (1 << 0)
86 #define DT_DRAIN_IN_PROGRESS (1 << 1)
91 mtx_lock_spin(&(tq)->tq_mutex); \
93 mtx_lock(&(tq)->tq_mutex); \
95 #define TQ_ASSERT_LOCKED(tq) mtx_assert(&(tq)->tq_mutex, MA_OWNED)
97 #define TQ_UNLOCK(tq) \
100 mtx_unlock_spin(&(tq)->tq_mutex); \
102 mtx_unlock(&(tq)->tq_mutex); \
104 #define TQ_ASSERT_UNLOCKED(tq) mtx_assert(&(tq)->tq_mutex, MA_NOTOWNED)
107 _timeout_task_init(struct taskqueue *queue, struct timeout_task *timeout_task,
108 int priority, task_fn_t func, void *context)
111 TASK_INIT(&timeout_task->t, priority, func, context);
112 callout_init_mtx(&timeout_task->c, &queue->tq_mutex,
113 CALLOUT_RETURNUNLOCKED);
114 timeout_task->q = queue;
119 TQ_SLEEP(struct taskqueue *tq, void *p, const char *wm)
122 return (msleep_spin(p, (struct mtx *)&tq->tq_mutex, wm, 0));
123 return (msleep(p, &tq->tq_mutex, 0, wm, 0));
126 static struct taskqueue_busy *
127 task_get_busy(struct taskqueue *queue, struct task *task)
129 struct taskqueue_busy *tb;
131 TQ_ASSERT_LOCKED(queue);
132 LIST_FOREACH(tb, &queue->tq_active, tb_link) {
133 if (tb->tb_running == task)
139 static struct taskqueue *
140 _taskqueue_create(const char *name, int mflags,
141 taskqueue_enqueue_fn enqueue, void *context,
142 int mtxflags, const char *mtxname __unused)
144 struct taskqueue *queue;
147 tq_name = malloc(TASKQUEUE_NAMELEN, M_TASKQUEUE, mflags | M_ZERO);
151 queue = malloc(sizeof(struct taskqueue), M_TASKQUEUE, mflags | M_ZERO);
153 free(tq_name, M_TASKQUEUE);
157 snprintf(tq_name, TASKQUEUE_NAMELEN, "%s", (name) ? name : "taskqueue");
159 STAILQ_INIT(&queue->tq_queue);
160 LIST_INIT(&queue->tq_active);
161 queue->tq_enqueue = enqueue;
162 queue->tq_context = context;
163 queue->tq_name = tq_name;
164 queue->tq_spin = (mtxflags & MTX_SPIN) != 0;
165 queue->tq_flags |= TQ_FLAGS_ACTIVE;
166 if (enqueue == taskqueue_fast_enqueue ||
167 enqueue == taskqueue_swi_enqueue ||
168 enqueue == taskqueue_swi_giant_enqueue ||
169 enqueue == taskqueue_thread_enqueue)
170 queue->tq_flags |= TQ_FLAGS_UNLOCKED_ENQUEUE;
171 mtx_init(&queue->tq_mutex, tq_name, NULL, mtxflags);
177 taskqueue_create(const char *name, int mflags,
178 taskqueue_enqueue_fn enqueue, void *context)
181 return _taskqueue_create(name, mflags, enqueue, context,
186 taskqueue_set_callback(struct taskqueue *queue,
187 enum taskqueue_callback_type cb_type, taskqueue_callback_fn callback,
191 KASSERT(((cb_type >= TASKQUEUE_CALLBACK_TYPE_MIN) &&
192 (cb_type <= TASKQUEUE_CALLBACK_TYPE_MAX)),
193 ("Callback type %d not valid, must be %d-%d", cb_type,
194 TASKQUEUE_CALLBACK_TYPE_MIN, TASKQUEUE_CALLBACK_TYPE_MAX));
195 KASSERT((queue->tq_callbacks[cb_type] == NULL),
196 ("Re-initialization of taskqueue callback?"));
198 queue->tq_callbacks[cb_type] = callback;
199 queue->tq_cb_contexts[cb_type] = context;
203 * Signal a taskqueue thread to terminate.
206 taskqueue_terminate(struct thread **pp, struct taskqueue *tq)
209 while (tq->tq_tcount > 0 || tq->tq_callouts > 0) {
211 TQ_SLEEP(tq, pp, "tq_destroy");
216 taskqueue_free(struct taskqueue *queue)
220 queue->tq_flags &= ~TQ_FLAGS_ACTIVE;
221 taskqueue_terminate(queue->tq_threads, queue);
222 KASSERT(LIST_EMPTY(&queue->tq_active), ("Tasks still running?"));
223 KASSERT(queue->tq_callouts == 0, ("Armed timeout tasks"));
224 mtx_destroy(&queue->tq_mutex);
225 free(queue->tq_threads, M_TASKQUEUE);
226 free(queue->tq_name, M_TASKQUEUE);
227 free(queue, M_TASKQUEUE);
231 taskqueue_enqueue_locked(struct taskqueue *queue, struct task *task, int flags)
235 struct taskqueue_busy *tb;
237 KASSERT(task->ta_func != NULL, ("enqueueing task with NULL func"));
239 * Ignore canceling task if requested.
241 if (__predict_false((flags & TASKQUEUE_FAIL_IF_CANCELING) != 0)) {
242 tb = task_get_busy(queue, task);
243 if (tb != NULL && tb->tb_canceling) {
250 * Count multiple enqueues.
252 if (task->ta_pending) {
253 if (__predict_false((flags & TASKQUEUE_FAIL_IF_PENDING) != 0)) {
257 if (task->ta_pending < USHRT_MAX)
264 * Optimise cases when all tasks use small set of priorities.
265 * In case of only one priority we always insert at the end.
266 * In case of two tq_hint typically gives the insertion point.
267 * In case of more then two tq_hint should halve the search.
269 prev = STAILQ_LAST(&queue->tq_queue, task, ta_link);
270 if (!prev || prev->ta_priority >= task->ta_priority) {
271 STAILQ_INSERT_TAIL(&queue->tq_queue, task, ta_link);
273 prev = queue->tq_hint;
274 if (prev && prev->ta_priority >= task->ta_priority) {
275 ins = STAILQ_NEXT(prev, ta_link);
278 ins = STAILQ_FIRST(&queue->tq_queue);
280 for (; ins; prev = ins, ins = STAILQ_NEXT(ins, ta_link))
281 if (ins->ta_priority < task->ta_priority)
285 STAILQ_INSERT_AFTER(&queue->tq_queue, prev, task, ta_link);
286 queue->tq_hint = task;
288 STAILQ_INSERT_HEAD(&queue->tq_queue, task, ta_link);
291 task->ta_pending = 1;
292 if ((queue->tq_flags & TQ_FLAGS_UNLOCKED_ENQUEUE) != 0)
294 if ((queue->tq_flags & TQ_FLAGS_BLOCKED) == 0)
295 queue->tq_enqueue(queue->tq_context);
296 if ((queue->tq_flags & TQ_FLAGS_UNLOCKED_ENQUEUE) == 0)
299 /* Return with lock released. */
304 taskqueue_enqueue_flags(struct taskqueue *queue, struct task *task, int flags)
309 res = taskqueue_enqueue_locked(queue, task, flags);
310 /* The lock is released inside. */
316 taskqueue_enqueue(struct taskqueue *queue, struct task *task)
318 return (taskqueue_enqueue_flags(queue, task, 0));
322 taskqueue_timeout_func(void *arg)
324 struct taskqueue *queue;
325 struct timeout_task *timeout_task;
328 queue = timeout_task->q;
329 KASSERT((timeout_task->f & DT_CALLOUT_ARMED) != 0, ("Stray timeout"));
330 timeout_task->f &= ~DT_CALLOUT_ARMED;
331 queue->tq_callouts--;
332 taskqueue_enqueue_locked(timeout_task->q, &timeout_task->t, 0);
333 /* The lock is released inside. */
337 taskqueue_enqueue_timeout_sbt(struct taskqueue *queue,
338 struct timeout_task *timeout_task, sbintime_t sbt, sbintime_t pr, int flags)
343 KASSERT(timeout_task->q == NULL || timeout_task->q == queue,
345 timeout_task->q = queue;
346 res = timeout_task->t.ta_pending;
347 if (timeout_task->f & DT_DRAIN_IN_PROGRESS) {
351 } else if (sbt == 0) {
352 taskqueue_enqueue_locked(queue, &timeout_task->t, 0);
353 /* The lock is released inside. */
355 if ((timeout_task->f & DT_CALLOUT_ARMED) != 0) {
358 queue->tq_callouts++;
359 timeout_task->f |= DT_CALLOUT_ARMED;
361 sbt = -sbt; /* Ignore overflow. */
365 flags |= C_DIRECT_EXEC;
366 if (queue->tq_spin && queue->tq_tcount == 1 &&
367 queue->tq_threads[0] == curthread) {
368 callout_reset_sbt_curcpu(&timeout_task->c, sbt, pr,
369 taskqueue_timeout_func, timeout_task, flags);
371 callout_reset_sbt(&timeout_task->c, sbt, pr,
372 taskqueue_timeout_func, timeout_task, flags);
381 taskqueue_enqueue_timeout(struct taskqueue *queue,
382 struct timeout_task *ttask, int ticks)
385 return (taskqueue_enqueue_timeout_sbt(queue, ttask, ticks * tick_sbt,
390 taskqueue_task_nop_fn(void *context, int pending)
395 * Block until all currently queued tasks in this taskqueue
396 * have begun execution. Tasks queued during execution of
397 * this function are ignored.
400 taskqueue_drain_tq_queue(struct taskqueue *queue)
402 struct task t_barrier;
404 if (STAILQ_EMPTY(&queue->tq_queue))
408 * Enqueue our barrier after all current tasks, but with
409 * the highest priority so that newly queued tasks cannot
410 * pass it. Because of the high priority, we can not use
411 * taskqueue_enqueue_locked directly (which drops the lock
412 * anyway) so just insert it at tail while we have the
415 TASK_INIT(&t_barrier, UCHAR_MAX, taskqueue_task_nop_fn, &t_barrier);
416 STAILQ_INSERT_TAIL(&queue->tq_queue, &t_barrier, ta_link);
417 queue->tq_hint = &t_barrier;
418 t_barrier.ta_pending = 1;
421 * Once the barrier has executed, all previously queued tasks
422 * have completed or are currently executing.
424 while (t_barrier.ta_pending != 0)
425 TQ_SLEEP(queue, &t_barrier, "tq_qdrain");
430 * Block until all currently executing tasks for this taskqueue
431 * complete. Tasks that begin execution during the execution
432 * of this function are ignored.
435 taskqueue_drain_tq_active(struct taskqueue *queue)
437 struct taskqueue_busy *tb;
440 if (LIST_EMPTY(&queue->tq_active))
443 /* Block taskq_terminate().*/
444 queue->tq_callouts++;
446 /* Wait for any active task with sequence from the past. */
449 LIST_FOREACH(tb, &queue->tq_active, tb_link) {
450 if ((int)(tb->tb_seq - seq) <= 0) {
451 TQ_SLEEP(queue, tb->tb_running, "tq_adrain");
456 /* Release taskqueue_terminate(). */
457 queue->tq_callouts--;
458 if ((queue->tq_flags & TQ_FLAGS_ACTIVE) == 0)
459 wakeup_one(queue->tq_threads);
464 taskqueue_block(struct taskqueue *queue)
468 queue->tq_flags |= TQ_FLAGS_BLOCKED;
473 taskqueue_unblock(struct taskqueue *queue)
477 queue->tq_flags &= ~TQ_FLAGS_BLOCKED;
478 if (!STAILQ_EMPTY(&queue->tq_queue))
479 queue->tq_enqueue(queue->tq_context);
484 taskqueue_run_locked(struct taskqueue *queue)
486 struct epoch_tracker et;
487 struct taskqueue_busy tb;
492 KASSERT(queue != NULL, ("tq is NULL"));
493 TQ_ASSERT_LOCKED(queue);
494 tb.tb_running = NULL;
495 LIST_INSERT_HEAD(&queue->tq_active, &tb, tb_link);
496 in_net_epoch = false;
498 while ((task = STAILQ_FIRST(&queue->tq_queue)) != NULL) {
499 STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link);
500 if (queue->tq_hint == task)
501 queue->tq_hint = NULL;
502 pending = task->ta_pending;
503 task->ta_pending = 0;
504 tb.tb_running = task;
505 tb.tb_seq = ++queue->tq_seq;
506 tb.tb_canceling = false;
509 KASSERT(task->ta_func != NULL, ("task->ta_func is NULL"));
510 if (!in_net_epoch && TASK_IS_NET(task)) {
513 } else if (in_net_epoch && !TASK_IS_NET(task)) {
515 in_net_epoch = false;
517 task->ta_func(task->ta_context, pending);
524 LIST_REMOVE(&tb, tb_link);
528 taskqueue_run(struct taskqueue *queue)
532 taskqueue_run_locked(queue);
537 * Only use this function in single threaded contexts. It returns
538 * non-zero if the given task is either pending or running. Else the
539 * task is idle and can be queued again or freed.
542 taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task)
547 retval = task->ta_pending > 0 || task_get_busy(queue, task) != NULL;
554 taskqueue_cancel_locked(struct taskqueue *queue, struct task *task,
557 struct taskqueue_busy *tb;
560 if (task->ta_pending > 0) {
561 STAILQ_REMOVE(&queue->tq_queue, task, task, ta_link);
562 if (queue->tq_hint == task)
563 queue->tq_hint = NULL;
566 *pendp = task->ta_pending;
567 task->ta_pending = 0;
568 tb = task_get_busy(queue, task);
570 tb->tb_canceling = true;
578 taskqueue_cancel(struct taskqueue *queue, struct task *task, u_int *pendp)
583 error = taskqueue_cancel_locked(queue, task, pendp);
590 taskqueue_cancel_timeout(struct taskqueue *queue,
591 struct timeout_task *timeout_task, u_int *pendp)
593 u_int pending, pending1;
597 pending = !!(callout_stop(&timeout_task->c) > 0);
598 error = taskqueue_cancel_locked(queue, &timeout_task->t, &pending1);
599 if ((timeout_task->f & DT_CALLOUT_ARMED) != 0) {
600 timeout_task->f &= ~DT_CALLOUT_ARMED;
601 queue->tq_callouts--;
606 *pendp = pending + pending1;
611 taskqueue_drain(struct taskqueue *queue, struct task *task)
615 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
618 while (task->ta_pending != 0 || task_get_busy(queue, task) != NULL)
619 TQ_SLEEP(queue, task, "tq_drain");
624 taskqueue_drain_all(struct taskqueue *queue)
628 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
631 (void)taskqueue_drain_tq_queue(queue);
632 (void)taskqueue_drain_tq_active(queue);
637 taskqueue_drain_timeout(struct taskqueue *queue,
638 struct timeout_task *timeout_task)
642 * Set flag to prevent timer from re-starting during drain:
645 KASSERT((timeout_task->f & DT_DRAIN_IN_PROGRESS) == 0,
646 ("Drain already in progress"));
647 timeout_task->f |= DT_DRAIN_IN_PROGRESS;
650 callout_drain(&timeout_task->c);
651 taskqueue_drain(queue, &timeout_task->t);
654 * Clear flag to allow timer to re-start:
657 timeout_task->f &= ~DT_DRAIN_IN_PROGRESS;
662 taskqueue_quiesce(struct taskqueue *queue)
668 ret = taskqueue_drain_tq_queue(queue);
670 ret = taskqueue_drain_tq_active(queue);
676 taskqueue_swi_enqueue(void *context)
678 swi_sched(taskqueue_ih, 0);
682 taskqueue_swi_run(void *dummy)
684 taskqueue_run(taskqueue_swi);
688 taskqueue_swi_giant_enqueue(void *context)
690 swi_sched(taskqueue_giant_ih, 0);
694 taskqueue_swi_giant_run(void *dummy)
696 taskqueue_run(taskqueue_swi_giant);
700 _taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
701 cpuset_t *mask, struct proc *p, const char *name, va_list ap)
703 char ktname[MAXCOMLEN + 1];
705 struct taskqueue *tq;
711 vsnprintf(ktname, sizeof(ktname), name, ap);
714 tq->tq_threads = malloc(sizeof(struct thread *) * count, M_TASKQUEUE,
716 if (tq->tq_threads == NULL) {
717 printf("%s: no memory for %s threads\n", __func__, ktname);
721 for (i = 0; i < count; i++) {
723 error = kthread_add(taskqueue_thread_loop, tqp, p,
724 &tq->tq_threads[i], RFSTOPPED, 0, "%s", ktname);
726 error = kthread_add(taskqueue_thread_loop, tqp, p,
727 &tq->tq_threads[i], RFSTOPPED, 0,
730 /* should be ok to continue, taskqueue_free will dtrt */
731 printf("%s: kthread_add(%s): error %d", __func__,
733 tq->tq_threads[i] = NULL; /* paranoid */
737 if (tq->tq_tcount == 0) {
738 free(tq->tq_threads, M_TASKQUEUE);
739 tq->tq_threads = NULL;
742 for (i = 0; i < count; i++) {
743 if (tq->tq_threads[i] == NULL)
745 td = tq->tq_threads[i];
747 error = cpuset_setthread(td->td_tid, mask);
749 * Failing to pin is rarely an actual fatal error;
750 * it'll just affect performance.
753 printf("%s: curthread=%llu: can't pin; "
756 (unsigned long long) td->td_tid,
761 sched_add(td, SRQ_BORING);
768 taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
769 const char *name, ...)
775 error = _taskqueue_start_threads(tqp, count, pri, NULL, NULL, name, ap);
781 taskqueue_start_threads_in_proc(struct taskqueue **tqp, int count, int pri,
782 struct proc *proc, const char *name, ...)
788 error = _taskqueue_start_threads(tqp, count, pri, NULL, proc, name, ap);
794 taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count, int pri,
795 cpuset_t *mask, const char *name, ...)
801 error = _taskqueue_start_threads(tqp, count, pri, mask, NULL, name, ap);
807 taskqueue_run_callback(struct taskqueue *tq,
808 enum taskqueue_callback_type cb_type)
810 taskqueue_callback_fn tq_callback;
812 TQ_ASSERT_UNLOCKED(tq);
813 tq_callback = tq->tq_callbacks[cb_type];
814 if (tq_callback != NULL)
815 tq_callback(tq->tq_cb_contexts[cb_type]);
819 taskqueue_thread_loop(void *arg)
821 struct taskqueue **tqp, *tq;
825 taskqueue_run_callback(tq, TASKQUEUE_CALLBACK_TYPE_INIT);
827 while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0) {
829 taskqueue_run_locked(tq);
831 * Because taskqueue_run() can drop tq_mutex, we need to
832 * check if the TQ_FLAGS_ACTIVE flag wasn't removed in the
833 * meantime, which means we missed a wakeup.
835 if ((tq->tq_flags & TQ_FLAGS_ACTIVE) == 0)
837 TQ_SLEEP(tq, tq, "-");
839 taskqueue_run_locked(tq);
841 * This thread is on its way out, so just drop the lock temporarily
842 * in order to call the shutdown callback. This allows the callback
843 * to look at the taskqueue, even just before it dies.
846 taskqueue_run_callback(tq, TASKQUEUE_CALLBACK_TYPE_SHUTDOWN);
849 /* rendezvous with thread that asked us to terminate */
851 wakeup_one(tq->tq_threads);
857 taskqueue_thread_enqueue(void *context)
859 struct taskqueue **tqp, *tq;
866 TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, NULL,
867 swi_add(NULL, "task queue", taskqueue_swi_run, NULL, SWI_TQ,
868 INTR_MPSAFE, &taskqueue_ih));
870 TASKQUEUE_DEFINE(swi_giant, taskqueue_swi_giant_enqueue, NULL,
871 swi_add(NULL, "Giant taskq", taskqueue_swi_giant_run,
872 NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih));
874 TASKQUEUE_DEFINE_THREAD(thread);
877 taskqueue_create_fast(const char *name, int mflags,
878 taskqueue_enqueue_fn enqueue, void *context)
880 return _taskqueue_create(name, mflags, enqueue, context,
881 MTX_SPIN, "fast_taskqueue");
884 static void *taskqueue_fast_ih;
887 taskqueue_fast_enqueue(void *context)
889 swi_sched(taskqueue_fast_ih, 0);
893 taskqueue_fast_run(void *dummy)
895 taskqueue_run(taskqueue_fast);
898 TASKQUEUE_FAST_DEFINE(fast, taskqueue_fast_enqueue, NULL,
899 swi_add(NULL, "fast taskq", taskqueue_fast_run, NULL,
900 SWI_TQ_FAST, INTR_MPSAFE, &taskqueue_fast_ih));
903 taskqueue_member(struct taskqueue *queue, struct thread *td)
907 for (i = 0, j = 0; ; i++) {
908 if (queue->tq_threads[i] == NULL)
910 if (queue->tq_threads[i] == td) {
914 if (++j >= queue->tq_tcount)