Skip to content

Commit

Permalink
cpu bind
Browse files Browse the repository at this point in the history
Signed-off-by: George Amanakis <gamanakis@gmail.com>
  • Loading branch information
gamanakis committed Dec 16, 2019
1 parent 58d2361 commit b9bad20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
14 changes: 4 additions & 10 deletions module/spl/spl-taskq.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
#include <sys/kmem.h>
#include <sys/tsd.h>

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");


int spl_taskq_thread_dynamic = 1;
module_param(spl_taskq_thread_dynamic, int, 0644);
MODULE_PARM_DESC(spl_taskq_thread_dynamic, "Allow dynamic taskq threads");
Expand Down Expand Up @@ -978,6 +973,7 @@ static taskq_thread_t *
taskq_thread_create(taskq_t *tq)
{
static int last_used_cpu = 0;
int cpu[4] = {0,1,6,7};
taskq_thread_t *tqt;

tqt = kmem_alloc(sizeof (*tqt), KM_PUSHPAGE);
Expand All @@ -993,10 +989,8 @@ taskq_thread_create(taskq_t *tq)
return (NULL);
}

if (spl_taskq_thread_bind) {
last_used_cpu = (last_used_cpu + 1) % num_online_cpus();
kthread_bind(tqt->tqt_thread, last_used_cpu);
}
last_used_cpu = (last_used_cpu + 1) % 4;
kthread_bind(tqt->tqt_thread, cpu[last_used_cpu]);

if (spl_taskq_thread_priority)
set_user_nice(tqt->tqt_thread, PRIO_TO_NICE(tq->tq_pri));
Expand Down Expand Up @@ -1026,7 +1020,7 @@ taskq_create(const char *name, int nthreads, pri_t pri,
ASSERT(nthreads >= 0);
nthreads = MIN(nthreads, 100);
nthreads = MAX(nthreads, 0);
nthreads = MAX((num_online_cpus() * nthreads) / 100, 1);
nthreads = MAX((4U * nthreads) / 100, 1);
}

tq = kmem_alloc(sizeof (*tq), KM_PUSHPAGE);
Expand Down
5 changes: 5 additions & 0 deletions module/spl/spl-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func,
thread_priv_t *tp;
struct task_struct *tsk;
char *p;
static int last_used_cpu = 0;
int cpu[4] = {0,1,6,7};

/* Option pp is simply ignored */
/* Variable stack size unsupported */
Expand Down Expand Up @@ -123,6 +125,9 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func,
if (IS_ERR(tsk))
return (NULL);

last_used_cpu = (last_used_cpu + 1) % 4;
kthread_bind(tsk, cpu[last_used_cpu]);

wake_up_process(tsk);
return ((kthread_t *)tsk);
}
Expand Down

0 comments on commit b9bad20

Please sign in to comment.