Make struct grouptask gt_name member a char array
Previously, it was just a pointer which was copied, but some callers pass in a stack variable which will go out of scope. Add GROUPTASK_NAMELEN macro (32) and snprintf() the name into it, using "grouptask" if name is NULL. We can now safely include gtask->gt_name in console messages. Reviewed by: sbruno Approved by: sbruno (mentor) Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D12449
This commit is contained in:
parent
f4d2154e0c
commit
d57a78580e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323944
@ -666,7 +666,7 @@ taskqgroup_attach(struct taskqgroup *qgroup, struct grouptask *gtask,
|
||||
int qid, error;
|
||||
|
||||
gtask->gt_uniq = uniq;
|
||||
gtask->gt_name = name;
|
||||
snprintf(gtask->gt_name, GROUPTASK_NAMELEN, "%s", name ? name : "grouptask");
|
||||
gtask->gt_irq = irq;
|
||||
gtask->gt_cpu = -1;
|
||||
mtx_lock(&qgroup->tqg_lock);
|
||||
@ -703,7 +703,7 @@ taskqgroup_attach_deferred(struct taskqgroup *qgroup, struct grouptask *gtask)
|
||||
error = intr_setaffinity(gtask->gt_irq, CPU_WHICH_IRQ, &mask);
|
||||
mtx_lock(&qgroup->tqg_lock);
|
||||
if (error)
|
||||
printf("%s: setaffinity failed: %d\n", __func__, error);
|
||||
printf("%s: %s setaffinity failed: %d\n", __func__, gtask->gt_name, error);
|
||||
|
||||
}
|
||||
qgroup->tqg_queue[qid].tgc_cnt++;
|
||||
@ -724,7 +724,7 @@ taskqgroup_attach_cpu(struct taskqgroup *qgroup, struct grouptask *gtask,
|
||||
|
||||
qid = -1;
|
||||
gtask->gt_uniq = uniq;
|
||||
gtask->gt_name = name;
|
||||
snprintf(gtask->gt_name, GROUPTASK_NAMELEN, "%s", name ? name : "grouptask");
|
||||
gtask->gt_irq = irq;
|
||||
gtask->gt_cpu = cpu;
|
||||
mtx_lock(&qgroup->tqg_lock);
|
||||
@ -736,7 +736,7 @@ taskqgroup_attach_cpu(struct taskqgroup *qgroup, struct grouptask *gtask,
|
||||
}
|
||||
if (qid == -1) {
|
||||
mtx_unlock(&qgroup->tqg_lock);
|
||||
printf("%s: qid not found for %s cpu=%d\n", __func__, name, cpu);
|
||||
printf("%s: qid not found for %s cpu=%d\n", __func__, gtask->gt_name, cpu);
|
||||
return (EINVAL);
|
||||
}
|
||||
} else
|
||||
@ -775,7 +775,7 @@ taskqgroup_attach_cpu_deferred(struct taskqgroup *qgroup, struct grouptask *gtas
|
||||
}
|
||||
if (qid == -1) {
|
||||
mtx_unlock(&qgroup->tqg_lock);
|
||||
printf("%s: qid not found for cpu=%d\n", __func__, cpu);
|
||||
printf("%s: qid not found for %s cpu=%d\n", __func__, gtask->gt_name, cpu);
|
||||
return (EINVAL);
|
||||
}
|
||||
qgroup->tqg_queue[qid].tgc_cnt++;
|
||||
@ -805,7 +805,7 @@ taskqgroup_detach(struct taskqgroup *qgroup, struct grouptask *gtask)
|
||||
if (qgroup->tqg_queue[i].tgc_taskq == gtask->gt_taskqueue)
|
||||
break;
|
||||
if (i == qgroup->tqg_cnt)
|
||||
panic("taskqgroup_detach: task not in group\n");
|
||||
panic("taskqgroup_detach: task %s not in group\n", gtask->gt_name);
|
||||
qgroup->tqg_queue[i].tgc_cnt--;
|
||||
LIST_REMOVE(gtask, gt_list);
|
||||
mtx_unlock(&qgroup->tqg_lock);
|
||||
|
@ -65,7 +65,8 @@ struct grouptask {
|
||||
void *gt_taskqueue;
|
||||
LIST_ENTRY(grouptask) gt_list;
|
||||
void *gt_uniq;
|
||||
char *gt_name;
|
||||
#define GROUPTASK_NAMELEN 32
|
||||
char gt_name[GROUPTASK_NAMELEN];
|
||||
int16_t gt_irq;
|
||||
int16_t gt_cpu;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user