Author: adrian
Date: Tue Feb 17 02:35:06 2015
New Revision: 278879
URL: https://svnweb.freebsd.org/changeset/base/278879

Log:
  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

Modified:
  head/sys/kern/subr_taskqueue.c
  head/sys/sys/taskqueue.h

Modified: head/sys/kern/subr_taskqueue.c
==============================================================================
--- head/sys/kern/subr_taskqueue.c      Tue Feb 17 01:45:38 2015        
(r278878)
+++ head/sys/kern/subr_taskqueue.c      Tue Feb 17 02:35:06 2015        
(r278879)
@@ -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 taskqueu
        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 (_taskqueue_start_threads(tqp, count, pri, NULL, ktname));
+       return (error);
 }
 
 int
-taskqueue_start_threads_pinned(struct taskqueue **tqp, int count, int pri,
-    int cpu_id, const char *name, ...)
+taskqueue_start_threads_cpuset(struct taskqueue **tqp, int count, int pri,
+    cpuset_t *mask, const char *name, ...)
 {
-       char ktname[MAXCOMLEN + 1];
        va_list ap;
-       cpuset_t mask;
+       int error;
 
        va_start(ap, name);
-       vsnprintf(ktname, sizeof(ktname), name, ap);
+       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, ...)
+{
+       cpuset_t mask;
+       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 ta
                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

Modified: head/sys/sys/taskqueue.h
==============================================================================
--- head/sys/sys/taskqueue.h    Tue Feb 17 01:45:38 2015        (r278878)
+++ head/sys/sys/taskqueue.h    Tue Feb 17 02:35:06 2015        (r278879)
@@ -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
                                    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);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to