]> git.proxmox.com Git - mirror_spl-debian.git/commitdiff
Add basic support for TASKQ_THREADS_CPU_PCT taskq flag which is
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 9 Jul 2009 17:07:52 +0000 (10:07 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 9 Jul 2009 17:07:52 +0000 (10:07 -0700)
used to scale the number of threads based on the number of online
CPUs.  As CPUs are added/removed we should rescale the thread
count appropriately, but currently this is only done at create.

include/sys/taskq.h
module/spl/spl-taskq.c

index 0b86231031f47983268ebbd1590690ca4a772424..603fde680db7c4b68edda791ba2ab41d3ecd74d1 100644 (file)
@@ -44,6 +44,7 @@ extern "C" {
 #define TASKQ_PREPOPULATE       0x00000001
 #define TASKQ_CPR_SAFE          0x00000002
 #define TASKQ_DYNAMIC           0x00000004
+#define TASKQ_THREADS_CPU_PCT   0x00000008
 
 typedef unsigned long taskqid_t;
 typedef void (task_func_t)(void *);
index 5960761f4a41406fba99e2b7635c2fee1ee61ad0..7575aa3b07b21ee7b52f88c46309106094869d02 100644 (file)
@@ -375,6 +375,15 @@ __taskq_create(const char *name, int nthreads, pri_t pri,
         ASSERT(maxalloc <= INT_MAX);
         ASSERT(!(flags & (TASKQ_CPR_SAFE | TASKQ_DYNAMIC))); /* Unsupported */
 
+       /* Scale the number of threads using nthreads as a percentage */
+       if (flags & TASKQ_THREADS_CPU_PCT) {
+               ASSERT(nthreads <= 100);
+               ASSERT(nthreads >= 0);
+               nthreads = MIN(nthreads, 100);
+               nthreads = MAX(nthreads, 0);
+               nthreads = MAX((num_online_cpus() * nthreads) / 100, 1);
+       }
+
         tq = kmem_alloc(sizeof(*tq), KM_SLEEP);
         if (tq == NULL)
                 RETURN(NULL);