diff options
author | Ubuntu <[email protected]> | 2016-10-28 21:23:30 +0000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-11-02 10:34:19 -0700 |
commit | cbba7146676dd145f373bcbe4f4f435d9100ddbb (patch) | |
tree | 18c5dc6f88302280af42323eedcb47797f9a3fc3 /module | |
parent | 1b457bcbe502eb29333a34b0518c1dca0e2ee974 (diff) |
Add TASKQID_INVALID and TASKQID_INITIAL macros
Add the TASKQID_INVALID and TASKQID_INITIAL macros and update the
taskq implementation and test cases to use them. This is solely
for the purposes of readability and introduces no functional change.
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module')
-rw-r--r-- | module/spl/spl-taskq.c | 18 | ||||
-rw-r--r-- | module/splat/splat-mutex.c | 30 | ||||
-rw-r--r-- | module/splat/splat-rwlock.c | 5 | ||||
-rw-r--r-- | module/splat/splat-taskq.c | 26 |
4 files changed, 43 insertions, 36 deletions
diff --git a/module/spl/spl-taskq.c b/module/spl/spl-taskq.c index 320ad3914..b362bef54 100644 --- a/module/spl/spl-taskq.c +++ b/module/spl/spl-taskq.c @@ -190,7 +190,7 @@ task_done(taskq_t *tq, taskq_ent_t *t) list_del_init(&t->tqent_list); if (tq->tq_nalloc <= tq->tq_minalloc) { - t->tqent_id = 0; + t->tqent_id = TASKQID_INVALID; t->tqent_func = NULL; t->tqent_arg = NULL; t->tqent_flags = 0; @@ -276,7 +276,7 @@ taskq_lowest_id(taskq_t *tq) if (!list_empty(&tq->tq_active_list)) { tqt = list_entry(tq->tq_active_list.next, taskq_thread_t, tqt_active_list); - ASSERT(tqt->tqt_id != 0); + ASSERT(tqt->tqt_id != TASKQID_INVALID); lowest_id = MIN(lowest_id, tqt->tqt_id); } @@ -548,7 +548,7 @@ taskqid_t taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t flags) { taskq_ent_t *t; - taskqid_t rc = 0; + taskqid_t rc = TASKQID_INVALID; unsigned long irqflags; ASSERT(tq); @@ -611,7 +611,7 @@ taskqid_t taskq_dispatch_delay(taskq_t *tq, task_func_t func, void *arg, uint_t flags, clock_t expire_time) { - taskqid_t rc = 0; + taskqid_t rc = TASKQID_INVALID; taskq_ent_t *t; unsigned long irqflags; @@ -667,7 +667,7 @@ taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags, /* Taskq being destroyed and all tasks drained */ if (!(tq->tq_flags & TASKQ_ACTIVE)) { - t->tqent_id = 0; + t->tqent_id = TASKQID_INVALID; goto out; } @@ -941,7 +941,7 @@ taskq_thread(void *args) taskq_thread_spawn(tq)) seq_tasks = 0; - tqt->tqt_id = 0; + tqt->tqt_id = TASKQID_INVALID; tqt->tqt_flags = 0; wake_up_all(&tq->tq_wait_waitq); } else { @@ -975,7 +975,7 @@ taskq_thread_create(taskq_t *tq) INIT_LIST_HEAD(&tqt->tqt_thread_list); INIT_LIST_HEAD(&tqt->tqt_active_list); tqt->tqt_tq = tq; - tqt->tqt_id = 0; + tqt->tqt_id = TASKQID_INVALID; tqt->tqt_thread = spl_kthread_create(taskq_thread, tqt, "%s", tq->tq_name); @@ -1037,8 +1037,8 @@ taskq_create(const char *name, int nthreads, pri_t pri, tq->tq_maxalloc = maxalloc; tq->tq_nalloc = 0; tq->tq_flags = (flags | TASKQ_ACTIVE); - tq->tq_next_id = 1; - tq->tq_lowest_id = 1; + tq->tq_next_id = TASKQID_INITIAL; + tq->tq_lowest_id = TASKQID_INITIAL; INIT_LIST_HEAD(&tq->tq_free_list); INIT_LIST_HEAD(&tq->tq_pend_list); INIT_LIST_HEAD(&tq->tq_prio_list); diff --git a/module/splat/splat-mutex.c b/module/splat/splat-mutex.c index 86bef8ee3..d39551354 100644 --- a/module/splat/splat-mutex.c +++ b/module/splat/splat-mutex.c @@ -81,7 +81,8 @@ splat_mutex_test1(struct file *file, void *arg) { mutex_priv_t *mp; taskq_t *tq; - int id, rc = 0; + taskqid_t id; + int rc = 0; mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL); if (mp == NULL) @@ -105,8 +106,8 @@ splat_mutex_test1(struct file *file, void *arg) * function will indicate this status in the passed private data. */ mp->mp_rc = -EINVAL; - id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP); - if (id == 0) { + id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP); + if (id == TASKQID_INVALID) { mutex_exit(&mp->mp_mtx); splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s", "taskq_dispatch() failed\n"); @@ -120,8 +121,8 @@ splat_mutex_test1(struct file *file, void *arg) /* Task function successfully acquired mutex, very bad! */ if (mp->mp_rc != -EBUSY) { splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, - "mutex_trylock() incorrectly succeeded when " - "the mutex was held, %d/%d\n", id, mp->mp_rc); + "mutex_trylock() incorrectly succeeded when " + "the mutex was held, %d/%d\n", (int)id, mp->mp_rc); rc = -EINVAL; goto out; } else { @@ -136,8 +137,8 @@ splat_mutex_test1(struct file *file, void *arg) * can be verified by checking the private data. */ mp->mp_rc = -EINVAL; - id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP); - if (id == 0) { + id = taskq_dispatch(tq, splat_mutex_test1_func, mp, TQ_SLEEP); + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s", "taskq_dispatch() failed\n"); rc = -EINVAL; @@ -149,8 +150,8 @@ splat_mutex_test1(struct file *file, void *arg) /* Task function failed to acquire mutex, very bad! */ if (mp->mp_rc != 0) { splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, - "mutex_trylock() incorrectly failed when " - "the mutex was not held, %d/%d\n", id, mp->mp_rc); + "mutex_trylock() incorrectly failed when the mutex " + "was not held, %d/%d\n", (int)id, mp->mp_rc); rc = -EINVAL; } else { splat_vprint(file, SPLAT_MUTEX_TEST1_NAME, "%s", @@ -188,6 +189,7 @@ splat_mutex_test2(struct file *file, void *arg) { mutex_priv_t *mp; taskq_t *tq; + taskqid_t id; int i, rc = 0; mp = (mutex_priv_t *)kmalloc(sizeof(*mp), GFP_KERNEL); @@ -218,7 +220,8 @@ splat_mutex_test2(struct file *file, void *arg) * mutex is implemented right this will never happy, that's a pass. */ for (i = 0; i < SPLAT_MUTEX_TEST_COUNT; i++) { - if (!taskq_dispatch(tq, splat_mutex_test2_func, mp, TQ_SLEEP)) { + id = taskq_dispatch(tq, splat_mutex_test2_func, mp, TQ_SLEEP); + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_MUTEX_TEST2_NAME, "Failed to queue task %d\n", i); rc = -EINVAL; @@ -260,6 +263,7 @@ splat_mutex_test3(struct file *file, void *arg) { mutex_priv_t mp; taskq_t *tq; + taskqid_t id; int rc = 0; mp.mp_magic = SPLAT_MUTEX_TEST_MAGIC; @@ -283,7 +287,8 @@ splat_mutex_test3(struct file *file, void *arg) goto out_exit; } - if (taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP) == 0) { + id = taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP); + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Failed to " "dispatch function '%s' to taskq\n", sym2str(splat_mutex_owned)); @@ -310,7 +315,8 @@ splat_mutex_test3(struct file *file, void *arg) goto out; } - if (taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP) == 0) { + id = taskq_dispatch(tq, splat_mutex_owned, &mp, TQ_SLEEP); + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_MUTEX_TEST3_NAME, "Failed to " "dispatch function '%s' to taskq\n", sym2str(splat_mutex_owned)); diff --git a/module/splat/splat-rwlock.c b/module/splat/splat-rwlock.c index 4576f20c7..87bc0c1c0 100644 --- a/module/splat/splat-rwlock.c +++ b/module/splat/splat-rwlock.c @@ -348,7 +348,8 @@ splat_rwlock_test2(struct file *file, void *arg) * rwlock is implemented right this will never happy, that's a pass. */ for (i = 0; i < tq_count; i++) { - if (!taskq_dispatch(tq,splat_rwlock_test2_func,rwp,TQ_SLEEP)) { + if (taskq_dispatch(tq, splat_rwlock_test2_func, rwp, + TQ_SLEEP) == TASKQID_INVALID) { splat_vprint(file, SPLAT_RWLOCK_TEST2_NAME, "Failed to queue task %d\n", i); rc = -EINVAL; @@ -469,7 +470,7 @@ splat_rwlock_test4_type(taskq_t *tq, rw_priv_t *rwp, int expected_rc, rw_enter(&rwp->rw_rwlock, holder_type); id = taskq_dispatch(tq, splat_rwlock_test4_func, rwp, TQ_SLEEP); - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(rwp->rw_file, SPLAT_RWLOCK_TEST4_NAME, "%s", "taskq_dispatch() failed\n"); rc = -EINVAL; diff --git a/module/splat/splat-taskq.c b/module/splat/splat-taskq.c index f26f828d9..665126bdd 100644 --- a/module/splat/splat-taskq.c +++ b/module/splat/splat-taskq.c @@ -160,7 +160,7 @@ splat_taskq_test1_impl(struct file *file, void *arg, boolean_t prealloc) &tq_arg, TQ_SLEEP); } - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST1_NAME, "Taskq '%s' function '%s' dispatch failed\n", tq_arg.name, sym2str(splat_taskq_test13_func)); @@ -296,7 +296,7 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) { tq_args[i], TQ_SLEEP); } - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq '%s/%d' function '%s' dispatch " "failed\n", tq_args[i]->name, tq_args[i]->id, @@ -318,7 +318,7 @@ splat_taskq_test2_impl(struct file *file, void *arg, boolean_t prealloc) { tq_args[i], TQ_SLEEP); } - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST2_NAME, "Taskq " "'%s/%d' function '%s' dispatch failed\n", tq_args[i]->name, tq_args[i]->id, @@ -420,7 +420,7 @@ splat_taskq_test3_impl(struct file *file, void *arg, boolean_t prealloc) tq_arg, TQ_SLEEP); } - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST3_NAME, "Taskq '%s' function '%s' dispatch failed\n", tq_arg->name, sym2str(splat_taskq_test13_func)); @@ -525,7 +525,7 @@ splat_taskq_test4_common(struct file *file, void *arg, int minalloc, &tq_arg, TQ_SLEEP); } - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST4_NAME, "Taskq '%s' function '%s' dispatch " "%d failed\n", tq_arg.name, @@ -741,7 +741,7 @@ splat_taskq_test5_impl(struct file *file, void *arg, boolean_t prealloc) &tq_id[i], TQ_SLEEP); } - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST5_NAME, "Taskq '%s' function '%s' dispatch failed\n", tq_arg.name, sym2str(splat_taskq_test5_func)); @@ -905,7 +905,7 @@ splat_taskq_test6_impl(struct file *file, void *arg, boolean_t prealloc) &tq_id[i], tflags); } - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST6_NAME, "Taskq '%s' function '%s' dispatch failed\n", tq_arg.name, sym2str(splat_taskq_test6_func)); @@ -983,7 +983,7 @@ splat_taskq_test7_func(void *arg) tq_arg, TQ_SLEEP); } - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(tq_arg->file, SPLAT_TASKQ_TEST7_NAME, "Taskq '%s' function '%s' dispatch failed " "(depth = %u)\n", tq_arg->name, @@ -1121,7 +1121,7 @@ splat_taskq_throughput(struct file *file, void *arg, const char *name, &tq_arg, TQ_SLEEP, tqes[i]); id = tqes[i]->tqent_id; - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, name, "Taskq '%s' function '%s' " "dispatch %d failed\n", tq_arg.name, sym2str(splat_taskq_throughput_func), i); @@ -1235,7 +1235,7 @@ splat_taskq_test9(struct file *file, void *arg) id = taskq_dispatch_delay(tq, splat_taskq_test9_func, tq_arg, TQ_SLEEP, ddi_get_lbolt() + rnd); - if (id == 0) { + if (id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST9_NAME, "Taskq '%s' delay dispatch failed\n", SPLAT_TASKQ_TEST9_NAME); @@ -1344,7 +1344,7 @@ splat_taskq_test10(struct file *file, void *arg) tq_arg, TQ_SLEEP, ddi_get_lbolt() + rnd); } - if (tq_arg->id == 0) { + if (tq_arg->id == TASKQID_INVALID) { splat_vprint(file, SPLAT_TASKQ_TEST10_NAME, "Taskq '%s' dispatch failed\n", SPLAT_TASKQ_TEST10_NAME); @@ -1473,8 +1473,8 @@ splat_taskq_test11(struct file *file, void *arg) dynamic.tv_sec, dynamic.tv_nsec); /* A 10x increase in runtime is used to indicate a core problem. */ - if ((dynamic.tv_sec * NANOSEC + dynamic.tv_nsec) > - ((normal.tv_sec * NANOSEC + normal.tv_nsec) * 10)) + if (((int64_t)dynamic.tv_sec * NANOSEC + (int64_t)dynamic.tv_nsec) > + (((int64_t)normal.tv_sec * NANOSEC + (int64_t)normal.tv_nsec) * 10)) error = -ETIME; return (error); |