Implement taskqueue_start_threads_cpuset().
This is a more generic version of taskqueue_start_threads_pinned() which only supports a single cpuid. This originally came from John Baldwin <jhb@> who implemented it as part of a push towards NUMA awareness in drivers. I started implementing something similar for RSS and NUMA, then found he already did it. I'd like to axe taskqueue_start_threads_pinned() so it doesn't become part of a longer-term API. (Read: hps@ wants to MFC things, and if I don't do this soon, he'll MFC what's here. :-) I have a follow-up commit which converts the intel drivers over to using the cpuset version of this function, so we can eventually nuke the the pinned version. Tested: * igb, ixgbe Obtained from: jhbbsd
This commit is contained in:
parent
1c8e60edbd
commit
bfa102cae1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=278879
@ -571,8 +571,9 @@ taskqueue_swi_giant_run(void *dummy)
|
||||
|
||||
static int
|
||||
_taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
|
||||
cpuset_t *mask, const char *ktname)
|
||||
cpuset_t *mask, const char *name, va_list ap)
|
||||
{
|
||||
char ktname[MAXCOMLEN + 1];
|
||||
struct thread *td;
|
||||
struct taskqueue *tq;
|
||||
int i, error;
|
||||
@ -580,6 +581,7 @@ _taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
|
||||
if (count <= 0)
|
||||
return (EINVAL);
|
||||
|
||||
vsnprintf(ktname, sizeof(ktname), name, ap);
|
||||
tq = *tqp;
|
||||
|
||||
tq->tq_threads = malloc(sizeof(struct thread *) * count, M_TASKQUEUE,
|
||||
@ -635,27 +637,35 @@ int
|
||||
taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
|
||||
const char *name, ...)
|
||||
{
|
||||
char ktname[MAXCOMLEN + 1];
|
||||
va_list ap;
|
||||
int error;
|
||||
|
||||
va_start(ap, name);
|
||||
vsnprintf(ktname, sizeof(ktname), name, ap);
|
||||
error = _taskqueue_start_threads(tqp, count, pri, NULL, name, ap);
|
||||
va_end(ap);
|
||||
return (error);
|
||||
}
|
||||
|
||||
return (_taskqueue_start_threads(tqp, count, pri, NULL, ktname));
|
||||
int
|
||||
taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count, int pri,
|
||||
cpuset_t *mask, const char *name, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int error;
|
||||
|
||||
va_start(ap, name);
|
||||
error = _taskqueue_start_threads(tqp, count, pri, mask, name, ap);
|
||||
va_end(ap);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
taskqueue_start_threads_pinned(struct taskqueue **tqp, int count, int pri,
|
||||
int cpu_id, const char *name, ...)
|
||||
{
|
||||
char ktname[MAXCOMLEN + 1];
|
||||
va_list ap;
|
||||
cpuset_t mask;
|
||||
|
||||
va_start(ap, name);
|
||||
vsnprintf(ktname, sizeof(ktname), name, ap);
|
||||
va_end(ap);
|
||||
va_list ap;
|
||||
int error;
|
||||
|
||||
/*
|
||||
* In case someone passes in NOCPU, just fall back to the
|
||||
@ -666,8 +676,11 @@ taskqueue_start_threads_pinned(struct taskqueue **tqp, int count, int pri,
|
||||
CPU_SET(cpu_id, &mask);
|
||||
}
|
||||
|
||||
return (_taskqueue_start_threads(tqp, count, pri,
|
||||
cpu_id == NOCPU ? NULL : &mask, ktname));
|
||||
va_start(ap, name);
|
||||
error = _taskqueue_start_threads(tqp, count, pri,
|
||||
cpu_id == NOCPU ? NULL : &mask, name, ap);
|
||||
va_end(ap);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <sys/queue.h>
|
||||
#include <sys/_task.h>
|
||||
#include <sys/_callout.h>
|
||||
#include <sys/_cpuset.h>
|
||||
|
||||
struct taskqueue;
|
||||
struct thread;
|
||||
@ -71,6 +72,8 @@ struct taskqueue *taskqueue_create(const char *name, int mflags,
|
||||
void *context);
|
||||
int taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
|
||||
const char *name, ...) __printflike(4, 5);
|
||||
int taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count,
|
||||
int pri, cpuset_t *mask, const char *name, ...) __printflike(5, 6);
|
||||
int taskqueue_start_threads_pinned(struct taskqueue **tqp, int count,
|
||||
int pri, int cpu_id, const char *name,
|
||||
...) __printflike(5, 6);
|
||||
|
Loading…
Reference in New Issue
Block a user