Improved logging of gtaskqueue failues

Check the return code of intr_setaffinity() and log any errors
it returns. When a qid is not located, log an error before returning
failure.  Also, use __func__ rather than hardcoding the function name

Reviewed by:	sbruno
Approved by:	sbruno (mentor)
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D12436
This commit is contained in:
Stephen Hurd 2017-09-21 21:14:48 +00:00
parent 005fdbbc69
commit 326aacb0e3

View File

@ -663,7 +663,7 @@ taskqgroup_attach(struct taskqgroup *qgroup, struct grouptask *gtask,
void *uniq, int irq, char *name) void *uniq, int irq, char *name)
{ {
cpuset_t mask; cpuset_t mask;
int qid; int qid, error;
gtask->gt_uniq = uniq; gtask->gt_uniq = uniq;
gtask->gt_name = name; gtask->gt_name = name;
@ -679,7 +679,9 @@ taskqgroup_attach(struct taskqgroup *qgroup, struct grouptask *gtask,
CPU_ZERO(&mask); CPU_ZERO(&mask);
CPU_SET(qgroup->tqg_queue[qid].tgc_cpu, &mask); CPU_SET(qgroup->tqg_queue[qid].tgc_cpu, &mask);
mtx_unlock(&qgroup->tqg_lock); mtx_unlock(&qgroup->tqg_lock);
intr_setaffinity(irq, CPU_WHICH_IRQ, &mask); error = intr_setaffinity(irq, CPU_WHICH_IRQ, &mask);
if (error)
printf("%s: setaffinity failed: %d\n", __func__, error);
} else } else
mtx_unlock(&qgroup->tqg_lock); mtx_unlock(&qgroup->tqg_lock);
} }
@ -688,7 +690,7 @@ static void
taskqgroup_attach_deferred(struct taskqgroup *qgroup, struct grouptask *gtask) taskqgroup_attach_deferred(struct taskqgroup *qgroup, struct grouptask *gtask)
{ {
cpuset_t mask; cpuset_t mask;
int qid, cpu; int qid, cpu, error;
mtx_lock(&qgroup->tqg_lock); mtx_lock(&qgroup->tqg_lock);
qid = taskqgroup_find(qgroup, gtask->gt_uniq); qid = taskqgroup_find(qgroup, gtask->gt_uniq);
@ -698,9 +700,11 @@ taskqgroup_attach_deferred(struct taskqgroup *qgroup, struct grouptask *gtask)
CPU_ZERO(&mask); CPU_ZERO(&mask);
CPU_SET(cpu, &mask); CPU_SET(cpu, &mask);
intr_setaffinity(gtask->gt_irq, CPU_WHICH_IRQ, &mask); error = intr_setaffinity(gtask->gt_irq, CPU_WHICH_IRQ, &mask);
mtx_lock(&qgroup->tqg_lock); mtx_lock(&qgroup->tqg_lock);
if (error)
printf("%s: setaffinity failed: %d\n", __func__, error);
} }
qgroup->tqg_queue[qid].tgc_cnt++; qgroup->tqg_queue[qid].tgc_cnt++;
@ -716,7 +720,7 @@ taskqgroup_attach_cpu(struct taskqgroup *qgroup, struct grouptask *gtask,
void *uniq, int cpu, int irq, char *name) void *uniq, int cpu, int irq, char *name)
{ {
cpuset_t mask; cpuset_t mask;
int i, qid; int i, qid, error;
qid = -1; qid = -1;
gtask->gt_uniq = uniq; gtask->gt_uniq = uniq;
@ -732,6 +736,7 @@ taskqgroup_attach_cpu(struct taskqgroup *qgroup, struct grouptask *gtask,
} }
if (qid == -1) { if (qid == -1) {
mtx_unlock(&qgroup->tqg_lock); mtx_unlock(&qgroup->tqg_lock);
printf("%s: qid not found for %s cpu=%d\n", __func__, name, cpu);
return (EINVAL); return (EINVAL);
} }
} else } else
@ -744,8 +749,11 @@ taskqgroup_attach_cpu(struct taskqgroup *qgroup, struct grouptask *gtask,
CPU_ZERO(&mask); CPU_ZERO(&mask);
CPU_SET(cpu, &mask); CPU_SET(cpu, &mask);
if (irq != -1 && tqg_smp_started) if (irq != -1 && tqg_smp_started) {
intr_setaffinity(irq, CPU_WHICH_IRQ, &mask); error = intr_setaffinity(irq, CPU_WHICH_IRQ, &mask);
if (error)
printf("%s: setaffinity failed: %d\n", __func__, error);
}
return (0); return (0);
} }
@ -753,7 +761,7 @@ static int
taskqgroup_attach_cpu_deferred(struct taskqgroup *qgroup, struct grouptask *gtask) taskqgroup_attach_cpu_deferred(struct taskqgroup *qgroup, struct grouptask *gtask)
{ {
cpuset_t mask; cpuset_t mask;
int i, qid, irq, cpu; int i, qid, irq, cpu, error;
qid = -1; qid = -1;
irq = gtask->gt_irq; irq = gtask->gt_irq;
@ -767,6 +775,7 @@ taskqgroup_attach_cpu_deferred(struct taskqgroup *qgroup, struct grouptask *gtas
} }
if (qid == -1) { if (qid == -1) {
mtx_unlock(&qgroup->tqg_lock); mtx_unlock(&qgroup->tqg_lock);
printf("%s: qid not found for %s cpu=%d\n", __func__, name, cpu);
return (EINVAL); return (EINVAL);
} }
qgroup->tqg_queue[qid].tgc_cnt++; qgroup->tqg_queue[qid].tgc_cnt++;
@ -778,8 +787,11 @@ taskqgroup_attach_cpu_deferred(struct taskqgroup *qgroup, struct grouptask *gtas
CPU_ZERO(&mask); CPU_ZERO(&mask);
CPU_SET(cpu, &mask); CPU_SET(cpu, &mask);
if (irq != -1) if (irq != -1) {
intr_setaffinity(irq, CPU_WHICH_IRQ, &mask); error = intr_setaffinity(irq, CPU_WHICH_IRQ, &mask);
if (error)
printf("%s: setaffinity failed: %d\n", __func__, error);
}
return (0); return (0);
} }
@ -815,7 +827,7 @@ taskqgroup_binder(void *ctx)
thread_unlock(curthread); thread_unlock(curthread);
if (error) if (error)
printf("taskqgroup_binder: setaffinity failed: %d\n", printf("%s: setaffinity failed: %d\n", __func__,
error); error);
free(gtask, M_DEVBUF); free(gtask, M_DEVBUF);
} }
@ -858,7 +870,7 @@ _taskqgroup_adjust(struct taskqgroup *qgroup, int cnt, int stride)
return (EINVAL); return (EINVAL);
} }
if (qgroup->tqg_adjusting) { if (qgroup->tqg_adjusting) {
printf("taskqgroup_adjust failed: adjusting\n"); printf("%s failed: adjusting\n", __func__);
return (EBUSY); return (EBUSY);
} }
qgroup->tqg_adjusting = 1; qgroup->tqg_adjusting = 1;