summaryrefslogtreecommitdiffstats
path: root/module/spl/spl-taskq.c
diff options
context:
space:
mode:
authorAndrey Vesnovaty <[email protected]>2013-08-28 05:09:25 +0300
committerBrian Behlendorf <[email protected]>2014-04-25 15:29:18 -0700
commit703371d8c734bc2cc6350f1bca014f08245dcc69 (patch)
tree593c5e83bacee874a2fa25b1745a711fd5f30edf /module/spl/spl-taskq.c
parentae16ed992bd0ef5a55b04d9edaaa6456674315f9 (diff)
Evenly distribute the taskq threads across available CPUs
The problem is described in commit aeeb4e0c0ae75b99ebbaa3056f0afc8e12949532. However, instead of disabling the binding to CPU altogether we just keep the last CPU index across calls to taskq_create() and thus achieve even distribution of the taskq threads across all available CPUs. The implementation based on assumption that task queues initialization performed in serial manner. Signed-off-by: Andrey Vesnovaty <[email protected]> Signed-off-by: Andrey Vesnovaty <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #336
Diffstat (limited to 'module/spl/spl-taskq.c')
-rw-r--r--module/spl/spl-taskq.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/module/spl/spl-taskq.c b/module/spl/spl-taskq.c
index 48feb1d22..0cb2ceeaf 100644
--- a/module/spl/spl-taskq.c
+++ b/module/spl/spl-taskq.c
@@ -34,6 +34,10 @@
#define SS_DEBUG_SUBSYS SS_TASKQ
+int spl_taskq_thread_bind = 0;
+module_param(spl_taskq_thread_bind, int, 0644);
+MODULE_PARM_DESC(spl_taskq_thread_bind, "Bind taskq thread to CPU by default");
+
/* Global system-wide dynamic task queue available for all consumers */
taskq_t *system_taskq;
EXPORT_SYMBOL(system_taskq);
@@ -781,6 +785,7 @@ taskq_t *
taskq_create(const char *name, int nthreads, pri_t pri,
int minalloc, int maxalloc, uint_t flags)
{
+ static int last_used_cpu = 0;
taskq_t *tq;
taskq_thread_t *tqt;
int rc = 0, i, j = 0;
@@ -843,6 +848,10 @@ taskq_create(const char *name, int nthreads, pri_t pri,
"%s/%d", name, i);
if (tqt->tqt_thread) {
list_add(&tqt->tqt_thread_list, &tq->tq_thread_list);
+ if (spl_taskq_thread_bind) {
+ last_used_cpu = (last_used_cpu + 1) % num_online_cpus();
+ kthread_bind(tqt->tqt_thread, last_used_cpu);
+ }
set_user_nice(tqt->tqt_thread, PRIO_TO_NICE(pri));
wake_up_process(tqt->tqt_thread);
j++;