FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/cpuset.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/libkern.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/epoch.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/taskqueue.h>
#include <sys/unistd.h>
#include <machine/stdarg.h>
Go to the source code of this file.
Data Structures | |
struct | taskqueue_busy |
struct | taskqueue |
Macros | |
#define | TQ_FLAGS_ACTIVE (1 << 0) |
#define | TQ_FLAGS_BLOCKED (1 << 1) |
#define | TQ_FLAGS_UNLOCKED_ENQUEUE (1 << 2) |
#define | DT_CALLOUT_ARMED (1 << 0) |
#define | DT_DRAIN_IN_PROGRESS (1 << 1) |
#define | TQ_LOCK(tq) |
#define | TQ_ASSERT_LOCKED(tq) mtx_assert(&(tq)->tq_mutex, MA_OWNED) |
#define | TQ_UNLOCK(tq) |
#define | TQ_ASSERT_UNLOCKED(tq) mtx_assert(&(tq)->tq_mutex, MA_NOTOWNED) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | MALLOC_DEFINE (M_TASKQUEUE, "taskqueue", "Task Queues") |
static void | taskqueue_fast_enqueue (void *) |
static void | taskqueue_swi_enqueue (void *) |
static void | taskqueue_swi_giant_enqueue (void *) |
void | _timeout_task_init (struct taskqueue *queue, struct timeout_task *timeout_task, int priority, task_fn_t func, void *context) |
static __inline int | TQ_SLEEP (struct taskqueue *tq, void *p, const char *wm) |
static struct taskqueue * | _taskqueue_create (const char *name, int mflags, taskqueue_enqueue_fn enqueue, void *context, int mtxflags, const char *mtxname __unused) |
struct taskqueue * | taskqueue_create (const char *name, int mflags, taskqueue_enqueue_fn enqueue, void *context) |
void | taskqueue_set_callback (struct taskqueue *queue, enum taskqueue_callback_type cb_type, taskqueue_callback_fn callback, void *context) |
static void | taskqueue_terminate (struct thread **pp, struct taskqueue *tq) |
void | taskqueue_free (struct taskqueue *queue) |
static int | taskqueue_enqueue_locked (struct taskqueue *queue, struct task *task) |
int | taskqueue_enqueue (struct taskqueue *queue, struct task *task) |
static void | taskqueue_timeout_func (void *arg) |
int | taskqueue_enqueue_timeout_sbt (struct taskqueue *queue, struct timeout_task *timeout_task, sbintime_t sbt, sbintime_t pr, int flags) |
int | taskqueue_enqueue_timeout (struct taskqueue *queue, struct timeout_task *ttask, int ticks) |
static void | taskqueue_task_nop_fn (void *context, int pending) |
static int | taskqueue_drain_tq_queue (struct taskqueue *queue) |
static int | taskqueue_drain_tq_active (struct taskqueue *queue) |
void | taskqueue_block (struct taskqueue *queue) |
void | taskqueue_unblock (struct taskqueue *queue) |
static void | taskqueue_run_locked (struct taskqueue *queue) |
void | taskqueue_run (struct taskqueue *queue) |
static int | task_is_running (struct taskqueue *queue, struct task *task) |
int | taskqueue_poll_is_busy (struct taskqueue *queue, struct task *task) |
static int | taskqueue_cancel_locked (struct taskqueue *queue, struct task *task, u_int *pendp) |
int | taskqueue_cancel (struct taskqueue *queue, struct task *task, u_int *pendp) |
int | taskqueue_cancel_timeout (struct taskqueue *queue, struct timeout_task *timeout_task, u_int *pendp) |
void | taskqueue_drain (struct taskqueue *queue, struct task *task) |
void | taskqueue_drain_all (struct taskqueue *queue) |
void | taskqueue_drain_timeout (struct taskqueue *queue, struct timeout_task *timeout_task) |
void | taskqueue_quiesce (struct taskqueue *queue) |
static void | taskqueue_swi_run (void *dummy) |
static void | taskqueue_swi_giant_run (void *dummy) |
static int | _taskqueue_start_threads (struct taskqueue **tqp, int count, int pri, cpuset_t *mask, struct proc *p, const char *name, va_list ap) |
int | taskqueue_start_threads (struct taskqueue **tqp, int count, int pri, const char *name,...) |
int | taskqueue_start_threads_in_proc (struct taskqueue **tqp, int count, int pri, struct proc *proc, const char *name,...) |
int | taskqueue_start_threads_cpuset (struct taskqueue **tqp, int count, int pri, cpuset_t *mask, const char *name,...) |
static void | taskqueue_run_callback (struct taskqueue *tq, enum taskqueue_callback_type cb_type) |
void | taskqueue_thread_loop (void *arg) |
void | taskqueue_thread_enqueue (void *context) |
TASKQUEUE_DEFINE (swi, taskqueue_swi_enqueue, NULL, swi_add(NULL, "task queue", taskqueue_swi_run, NULL, SWI_TQ, INTR_MPSAFE, &taskqueue_ih)) | |
TASKQUEUE_DEFINE (swi_giant, taskqueue_swi_giant_enqueue, NULL, swi_add(NULL, "Giant taskq", taskqueue_swi_giant_run, NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih)) | |
TASKQUEUE_DEFINE_THREAD (thread) | |
struct taskqueue * | taskqueue_create_fast (const char *name, int mflags, taskqueue_enqueue_fn enqueue, void *context) |
static void | taskqueue_fast_run (void *dummy) |
TASKQUEUE_FAST_DEFINE (fast, taskqueue_fast_enqueue, NULL, swi_add(NULL, "fast taskq", taskqueue_fast_run, NULL, SWI_TQ_FAST, INTR_MPSAFE, &taskqueue_fast_ih)) | |
int | taskqueue_member (struct taskqueue *queue, struct thread *td) |
Variables | |
static void * | taskqueue_giant_ih |
static void * | taskqueue_ih |
static void * | taskqueue_fast_ih |
#define DT_CALLOUT_ARMED (1 << 0) |
Definition at line 87 of file subr_taskqueue.c.
#define DT_DRAIN_IN_PROGRESS (1 << 1) |
Definition at line 88 of file subr_taskqueue.c.
#define TQ_ASSERT_LOCKED | ( | tq | ) | mtx_assert(&(tq)->tq_mutex, MA_OWNED) |
Definition at line 97 of file subr_taskqueue.c.
#define TQ_ASSERT_UNLOCKED | ( | tq | ) | mtx_assert(&(tq)->tq_mutex, MA_NOTOWNED) |
Definition at line 106 of file subr_taskqueue.c.
#define TQ_FLAGS_ACTIVE (1 << 0) |
Definition at line 83 of file subr_taskqueue.c.
#define TQ_FLAGS_BLOCKED (1 << 1) |
Definition at line 84 of file subr_taskqueue.c.
#define TQ_FLAGS_UNLOCKED_ENQUEUE (1 << 2) |
Definition at line 85 of file subr_taskqueue.c.
#define TQ_LOCK | ( | tq | ) |
Definition at line 90 of file subr_taskqueue.c.
#define TQ_UNLOCK | ( | tq | ) |
Definition at line 99 of file subr_taskqueue.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 129 of file subr_taskqueue.c.
References free(), malloc(), name, snprintf(), taskqueue_fast_enqueue(), taskqueue_swi_enqueue(), taskqueue_swi_giant_enqueue(), taskqueue_thread_enqueue(), TQ_FLAGS_ACTIVE, and TQ_FLAGS_UNLOCKED_ENQUEUE.
Referenced by taskqueue_create(), and taskqueue_create_fast().
|
static |
Definition at line 665 of file subr_taskqueue.c.
References count, cpuset_setthread(), free(), kthread_add(), malloc(), mask, name, printf(), sched_add(), sched_prio(), taskqueue_thread_loop(), and vsnprintf().
Referenced by taskqueue_start_threads(), taskqueue_start_threads_cpuset(), and taskqueue_start_threads_in_proc().
void _timeout_task_init | ( | struct taskqueue * | queue, |
struct timeout_task * | timeout_task, | ||
int | priority, | ||
task_fn_t | func, | ||
void * | context | ||
) |
Definition at line 109 of file subr_taskqueue.c.
References priority.
|
static |
|
static |
Definition at line 497 of file subr_taskqueue.c.
References taskqueue_busy::tb_running, and TQ_ASSERT_LOCKED.
Referenced by taskqueue_cancel_locked(), taskqueue_drain(), and taskqueue_poll_is_busy().
void taskqueue_block | ( | struct taskqueue * | queue | ) |
Definition at line 425 of file subr_taskqueue.c.
References TQ_FLAGS_BLOCKED, TQ_LOCK, and TQ_UNLOCK.
int taskqueue_cancel | ( | struct taskqueue * | queue, |
struct task * | task, | ||
u_int * | pendp | ||
) |
Definition at line 543 of file subr_taskqueue.c.
References taskqueue_cancel_locked(), TQ_LOCK, and TQ_UNLOCK.
|
static |
Definition at line 527 of file subr_taskqueue.c.
References task_is_running().
Referenced by taskqueue_cancel(), and taskqueue_cancel_timeout().
int taskqueue_cancel_timeout | ( | struct taskqueue * | queue, |
struct timeout_task * | timeout_task, | ||
u_int * | pendp | ||
) |
Definition at line 555 of file subr_taskqueue.c.
References DT_CALLOUT_ARMED, taskqueue_cancel_locked(), TQ_LOCK, and TQ_UNLOCK.
Referenced by clock_unregister().
struct taskqueue * taskqueue_create | ( | const char * | name, |
int | mflags, | ||
taskqueue_enqueue_fn | enqueue, | ||
void * | context | ||
) |
Definition at line 166 of file subr_taskqueue.c.
References _taskqueue_create(), and name.
Referenced by firmware_modevent().
struct taskqueue * taskqueue_create_fast | ( | const char * | name, |
int | mflags, | ||
taskqueue_enqueue_fn | enqueue, | ||
void * | context | ||
) |
Definition at line 842 of file subr_taskqueue.c.
References _taskqueue_create(), and name.
TASKQUEUE_DEFINE | ( | swi | , |
taskqueue_swi_enqueue | , | ||
NULL | , | ||
swi_add(NULL, "task queue", taskqueue_swi_run, NULL, SWI_TQ, INTR_MPSAFE, &taskqueue_ih) | |||
) |
TASKQUEUE_DEFINE | ( | swi_giant | , |
taskqueue_swi_giant_enqueue | , | ||
NULL | , | ||
swi_add(NULL, "Giant taskq", taskqueue_swi_giant_run, NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih) | |||
) |
TASKQUEUE_DEFINE_THREAD | ( | thread | ) |
void taskqueue_drain | ( | struct taskqueue * | queue, |
struct task * | task | ||
) |
Definition at line 576 of file subr_taskqueue.c.
References task_is_running(), TQ_LOCK, TQ_SLEEP(), and TQ_UNLOCK.
Referenced by aio_proc_rundown(), firmware_modevent(), taskqueue_drain_timeout(), and thread_reap_barrier().
void taskqueue_drain_all | ( | struct taskqueue * | queue | ) |
Definition at line 589 of file subr_taskqueue.c.
References taskqueue_drain_tq_active(), taskqueue_drain_tq_queue(), TQ_LOCK, and TQ_UNLOCK.
void taskqueue_drain_timeout | ( | struct taskqueue * | queue, |
struct timeout_task * | timeout_task | ||
) |
Definition at line 602 of file subr_taskqueue.c.
References DT_DRAIN_IN_PROGRESS, taskqueue_drain(), TQ_LOCK, and TQ_UNLOCK.
Referenced by clock_unregister().
|
static |
Definition at line 396 of file subr_taskqueue.c.
References taskqueue_busy::tb_running, taskqueue_busy::tb_seq, TQ_FLAGS_ACTIVE, TQ_SLEEP(), and wakeup_one().
Referenced by taskqueue_drain_all(), and taskqueue_quiesce().
|
static |
Definition at line 361 of file subr_taskqueue.c.
References taskqueue_task_nop_fn(), and TQ_SLEEP().
Referenced by taskqueue_drain_all(), and taskqueue_quiesce().
int taskqueue_enqueue | ( | struct taskqueue * | queue, |
struct task * | task | ||
) |
Definition at line 277 of file subr_taskqueue.c.
References res, taskqueue_enqueue_locked(), and TQ_LOCK.
Referenced by aio_bio_done_notify(), aio_kick_nowait(), cpufreq_attach(), destroy_dev_sched_cbl(), do_unlink(), firmware_get_flags(), firmware_modevent(), firmware_mountroot(), firmware_put(), kqueue_schedtask(), lf_wakeup_lock(), power_pm_suspend(), prison_free(), prison_proc_free(), shutdown_nice(), soaio_enqueue(), thread_reap_barrier(), thread_reap_callout_cb(), umtx_shm_object_terminated(), unp_discard(), and vmem_periodic_kick().
|
static |
Definition at line 220 of file subr_taskqueue.c.
References TQ_FLAGS_BLOCKED, TQ_FLAGS_UNLOCKED_ENQUEUE, and TQ_UNLOCK.
Referenced by taskqueue_enqueue(), taskqueue_enqueue_timeout_sbt(), and taskqueue_timeout_func().
int taskqueue_enqueue_timeout | ( | struct taskqueue * | queue, |
struct timeout_task * | ttask, | ||
int | ticks | ||
) |
Definition at line 342 of file subr_taskqueue.c.
References taskqueue_enqueue_timeout_sbt(), tick_sbt, and ticks.
Referenced by deferred_unmount_enqueue(), and uipc_detach().
int taskqueue_enqueue_timeout_sbt | ( | struct taskqueue * | queue, |
struct timeout_task * | timeout_task, | ||
sbintime_t | sbt, | ||
sbintime_t | pr, | ||
int | flags | ||
) |
Definition at line 304 of file subr_taskqueue.c.
References DT_CALLOUT_ARMED, DT_DRAIN_IN_PROGRESS, flags, pr, res, taskqueue_enqueue_locked(), taskqueue_timeout_func(), TQ_LOCK, and TQ_UNLOCK.
Referenced by resettodr(), and taskqueue_enqueue_timeout().
TASKQUEUE_FAST_DEFINE | ( | fast | , |
taskqueue_fast_enqueue | , | ||
NULL | , | ||
swi_add(NULL, "fast taskq", taskqueue_fast_run, NULL, SWI_TQ_FAST, INTR_MPSAFE, &taskqueue_fast_ih) | |||
) |
|
static |
Definition at line 852 of file subr_taskqueue.c.
References swi_sched(), and taskqueue_fast_ih.
Referenced by _taskqueue_create().
|
static |
Definition at line 858 of file subr_taskqueue.c.
References taskqueue_run().
void taskqueue_free | ( | struct taskqueue * | queue | ) |
Definition at line 205 of file subr_taskqueue.c.
References free(), taskqueue_terminate(), and TQ_LOCK.
Referenced by firmware_modevent().
int taskqueue_member | ( | struct taskqueue * | queue, |
struct thread * | td | ||
) |
Definition at line 868 of file subr_taskqueue.c.
Referenced by dounmount(), unp_remove_dead_ref(), and unp_restore_undead_ref().
int taskqueue_poll_is_busy | ( | struct taskqueue * | queue, |
struct task * | task | ||
) |
Definition at line 515 of file subr_taskqueue.c.
References task_is_running(), TQ_LOCK, and TQ_UNLOCK.
void taskqueue_quiesce | ( | struct taskqueue * | queue | ) |
Definition at line 627 of file subr_taskqueue.c.
References taskqueue_drain_tq_active(), taskqueue_drain_tq_queue(), TQ_LOCK, and TQ_UNLOCK.
Referenced by kqueue_drain_schedtask().
void taskqueue_run | ( | struct taskqueue * | queue | ) |
Definition at line 488 of file subr_taskqueue.c.
References taskqueue_run_locked(), TQ_LOCK, and TQ_UNLOCK.
Referenced by taskqueue_fast_run(), taskqueue_swi_giant_run(), and taskqueue_swi_run().
|
inlinestatic |
Definition at line 772 of file subr_taskqueue.c.
References TQ_ASSERT_UNLOCKED.
Referenced by taskqueue_thread_loop().
|
static |
Definition at line 445 of file subr_taskqueue.c.
References taskqueue_busy::tb_running, taskqueue_busy::tb_seq, TQ_ASSERT_LOCKED, TQ_LOCK, TQ_UNLOCK, and wakeup().
Referenced by taskqueue_run(), and taskqueue_thread_loop().
void taskqueue_set_callback | ( | struct taskqueue * | queue, |
enum taskqueue_callback_type | cb_type, | ||
taskqueue_callback_fn | callback, | ||
void * | context | ||
) |
Definition at line 175 of file subr_taskqueue.c.
References callback.
int taskqueue_start_threads | ( | struct taskqueue ** | tqp, |
int | count, | ||
int | pri, | ||
const char * | name, | ||
... | |||
) |
Definition at line 733 of file subr_taskqueue.c.
References _taskqueue_start_threads(), count, and name.
Referenced by firmware_modevent().
int taskqueue_start_threads_cpuset | ( | struct taskqueue ** | tqp, |
int | count, | ||
int | pri, | ||
cpuset_t * | mask, | ||
const char * | name, | ||
... | |||
) |
Definition at line 759 of file subr_taskqueue.c.
References _taskqueue_start_threads(), count, mask, and name.
int taskqueue_start_threads_in_proc | ( | struct taskqueue ** | tqp, |
int | count, | ||
int | pri, | ||
struct proc * | proc, | ||
const char * | name, | ||
... | |||
) |
Definition at line 746 of file subr_taskqueue.c.
References _taskqueue_start_threads(), count, and name.
|
static |
Definition at line 641 of file subr_taskqueue.c.
References swi_sched(), and taskqueue_ih.
Referenced by _taskqueue_create().
|
static |
Definition at line 653 of file subr_taskqueue.c.
References swi_sched(), and taskqueue_giant_ih.
Referenced by _taskqueue_create().
|
static |
Definition at line 659 of file subr_taskqueue.c.
References taskqueue_run().
|
static |
Definition at line 647 of file subr_taskqueue.c.
References taskqueue_run().
|
static |
Definition at line 351 of file subr_taskqueue.c.
Referenced by taskqueue_drain_tq_queue().
|
static |
Definition at line 195 of file subr_taskqueue.c.
References TQ_SLEEP(), and wakeup().
Referenced by taskqueue_free().
void taskqueue_thread_enqueue | ( | void * | context | ) |
Definition at line 822 of file subr_taskqueue.c.
References wakeup_any().
Referenced by _taskqueue_create(), firmware_modevent(), and taskqgroup_cpu_create().
void taskqueue_thread_loop | ( | void * | arg | ) |
Definition at line 784 of file subr_taskqueue.c.
References kthread_exit(), taskqueue_run_callback(), taskqueue_run_locked(), TQ_FLAGS_ACTIVE, TQ_LOCK, TQ_SLEEP(), TQ_UNLOCK, and wakeup_one().
Referenced by _taskqueue_start_threads().
|
static |
Definition at line 289 of file subr_taskqueue.c.
References DT_CALLOUT_ARMED, and taskqueue_enqueue_locked().
Referenced by taskqueue_enqueue_timeout_sbt().
void taskqueue_unblock | ( | struct taskqueue * | queue | ) |
Definition at line 434 of file subr_taskqueue.c.
|
static |
Definition at line 121 of file subr_taskqueue.c.
References mtx.
Referenced by taskqueue_drain(), taskqueue_drain_tq_active(), taskqueue_drain_tq_queue(), taskqueue_terminate(), and taskqueue_thread_loop().
|
static |
Definition at line 849 of file subr_taskqueue.c.
Referenced by taskqueue_fast_enqueue().
|
static |
Definition at line 53 of file subr_taskqueue.c.
Referenced by taskqueue_swi_giant_enqueue().
|
static |
Definition at line 54 of file subr_taskqueue.c.
Referenced by taskqueue_swi_enqueue().