Skip to content

Commit

Permalink
Use exclusive threads to optimize work wait queue
Browse files Browse the repository at this point in the history
When a single work item is dispatched we only need to wake up one
thread to service it.  The current taskq implementation uses
non-exclusive processes in the work wait queue, so every thread in the
queue gets woken up when __taskq_dispatch() calls wake_up().  This
overhead can become non-negligible as the number of threads in the
queue increases, particularly when a large number of short work items
are being dispatched.  For example, this scenario appears to have led
to poor unlink performance in ZFS as described in Issues
openzfs/zfs#458 and openzfs/zfs#258.  To optimize this case, use
add_wait_queue_exclusive() to add threads to the work queue so only
one is woken up at a time.
  • Loading branch information
nedbass committed Jan 14, 2012
1 parent 0b14b9f commit 0396495
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion module/spl/spl-taskq.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ taskq_thread(void *args)

while (!kthread_should_stop()) {

add_wait_queue(&tq->tq_work_waitq, &wait);
add_wait_queue_exclusive(&tq->tq_work_waitq, &wait);
if (list_empty(&tq->tq_pend_list) &&
list_empty(&tq->tq_prio_list)) {
spin_unlock_irqrestore(&tq->tq_lock, tq->tq_lock_flags);
Expand Down

0 comments on commit 0396495

Please sign in to comment.