Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_gtaskqueue.c
Show First 20 Lines • Show All 669 Lines • ▼ Show 20 Lines | struct taskqgroup_cpu { | ||||
struct gtaskqueue *tgc_taskq; | struct gtaskqueue *tgc_taskq; | ||||
int tgc_cnt; | int tgc_cnt; | ||||
int tgc_cpu; | int tgc_cpu; | ||||
}; | }; | ||||
struct taskqgroup { | struct taskqgroup { | ||||
struct taskqgroup_cpu tqg_queue[MAXCPU]; | struct taskqgroup_cpu tqg_queue[MAXCPU]; | ||||
struct mtx tqg_lock; | struct mtx tqg_lock; | ||||
void (*adjust_func)(void*); | |||||
char * tqg_name; | char * tqg_name; | ||||
int tqg_adjusting; | int tqg_adjusting; | ||||
int tqg_stride; | int tqg_stride; | ||||
int tqg_cnt; | int tqg_cnt; | ||||
int tqg_flags; | |||||
}; | }; | ||||
#define TQG_NEED_ADJUST 0x1 | |||||
#define TQG_ADJUSTED 0x2 | |||||
struct taskq_bind_task { | struct taskq_bind_task { | ||||
struct gtask bt_task; | struct gtask bt_task; | ||||
int bt_cpuid; | int bt_cpuid; | ||||
}; | }; | ||||
static void | static void | ||||
taskqgroup_cpu_create(struct taskqgroup *qgroup, int idx, int cpu, bool intr, int pri) | taskqgroup_cpu_create(struct taskqgroup *qgroup, int idx, int cpu, bool intr, int pri) | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
cpuset_t mask; | cpuset_t mask; | ||||
int qid; | int qid; | ||||
gtask->gt_uniq = uniq; | gtask->gt_uniq = uniq; | ||||
gtask->gt_name = name; | gtask->gt_name = name; | ||||
gtask->gt_irq = irq; | gtask->gt_irq = irq; | ||||
gtask->gt_cpu = -1; | gtask->gt_cpu = -1; | ||||
mtx_lock(&qgroup->tqg_lock); | mtx_lock(&qgroup->tqg_lock); | ||||
qgroup->tqg_flags |= TQG_NEED_ADJUST; | |||||
mtx_unlock(&qgroup->tqg_lock); | |||||
if (tqg_smp_started && !(qgroup->tqg_flags & TQG_ADJUSTED)) | |||||
qgroup->adjust_func(NULL); | |||||
mtx_lock(&qgroup->tqg_lock); | |||||
qid = taskqgroup_find(qgroup, uniq); | qid = taskqgroup_find(qgroup, uniq); | ||||
qgroup->tqg_queue[qid].tgc_cnt++; | qgroup->tqg_queue[qid].tgc_cnt++; | ||||
LIST_INSERT_HEAD(&qgroup->tqg_queue[qid].tgc_tasks, gtask, gt_list); | LIST_INSERT_HEAD(&qgroup->tqg_queue[qid].tgc_tasks, gtask, gt_list); | ||||
gtask->gt_taskqueue = qgroup->tqg_queue[qid].tgc_taskq; | gtask->gt_taskqueue = qgroup->tqg_queue[qid].tgc_taskq; | ||||
if (irq != -1 && tqg_smp_started) { | if (irq != -1 && tqg_smp_started) { | ||||
gtask->gt_cpu = qgroup->tqg_queue[qid].tgc_cpu; | gtask->gt_cpu = qgroup->tqg_queue[qid].tgc_cpu; | ||||
CPU_ZERO(&mask); | CPU_ZERO(&mask); | ||||
CPU_SET(qgroup->tqg_queue[qid].tgc_cpu, &mask); | CPU_SET(qgroup->tqg_queue[qid].tgc_cpu, &mask); | ||||
▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
taskqgroup_adjust(struct taskqgroup *qgroup, int cnt, int stride, bool ithread, int pri) | taskqgroup_adjust(struct taskqgroup *qgroup, int cnt, int stride, bool ithread, int pri) | ||||
{ | { | ||||
int error; | int error; | ||||
mtx_lock(&qgroup->tqg_lock); | mtx_lock(&qgroup->tqg_lock); | ||||
error = _taskqgroup_adjust(qgroup, cnt, stride, ithread, pri); | error = _taskqgroup_adjust(qgroup, cnt, stride, ithread, pri); | ||||
mtx_unlock(&qgroup->tqg_lock); | |||||
return (error); | |||||
} | |||||
void | |||||
taskqgroup_set_adjust(struct taskqgroup *qgroup, void (*adjust_func)(void*)) | |||||
{ | |||||
qgroup-> adjust_func = adjust_func; | |||||
} | |||||
int | |||||
taskqgroup_adjust_once(struct taskqgroup *qgroup, int cnt, int stride, bool ithread, int pri) | |||||
{ | |||||
int error = 0; | |||||
mtx_lock(&qgroup->tqg_lock); | |||||
if ((qgroup->tqg_flags & (TQG_ADJUSTED|TQG_NEED_ADJUST)) == TQG_NEED_ADJUST) { | |||||
qgroup->tqg_flags |= TQG_ADJUSTED; | |||||
error = _taskqgroup_adjust(qgroup, cnt, stride, ithread, pri); | |||||
MPASS(error == 0); | |||||
} | |||||
mtx_unlock(&qgroup->tqg_lock); | mtx_unlock(&qgroup->tqg_lock); | ||||
return (error); | return (error); | ||||
} | } | ||||
struct taskqgroup * | struct taskqgroup * | ||||
taskqgroup_create(char *name) | taskqgroup_create(char *name) | ||||
{ | { | ||||
Show All 15 Lines |