Commit 729e8b87 authored by Lars Ellenberg's avatar Lars Ellenberg Committed by Jens Axboe

drbd: reduce lock contention in drbd_worker

The worker may now dequeue work items in batches.
This should reduce lock contention during busy periods.
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent abde9cc6
...@@ -2026,8 +2026,6 @@ static void wait_for_work(struct drbd_connection *connection, struct list_head * ...@@ -2026,8 +2026,6 @@ static void wait_for_work(struct drbd_connection *connection, struct list_head *
prepare_to_wait(&connection->sender_work.q_wait, &wait, TASK_INTERRUPTIBLE); prepare_to_wait(&connection->sender_work.q_wait, &wait, TASK_INTERRUPTIBLE);
spin_lock_irq(&connection->resource->req_lock); spin_lock_irq(&connection->resource->req_lock);
spin_lock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */ spin_lock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */
/* dequeue single item only,
* we still use drbd_queue_work_front() in some places */
if (!list_empty(&connection->sender_work.q)) if (!list_empty(&connection->sender_work.q))
list_splice_tail_init(&connection->sender_work.q, work_list); list_splice_tail_init(&connection->sender_work.q, work_list);
spin_unlock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */ spin_unlock(&connection->sender_work.q_lock); /* FIXME get rid of this one? */
...@@ -2114,7 +2112,7 @@ int drbd_worker(struct drbd_thread *thi) ...@@ -2114,7 +2112,7 @@ int drbd_worker(struct drbd_thread *thi)
if (get_t_state(thi) != RUNNING) if (get_t_state(thi) != RUNNING)
break; break;
while (!list_empty(&work_list)) { if (!list_empty(&work_list)) {
w = list_first_entry(&work_list, struct drbd_work, list); w = list_first_entry(&work_list, struct drbd_work, list);
list_del_init(&w->list); list_del_init(&w->list);
update_worker_timing_details(connection, w->cb); update_worker_timing_details(connection, w->cb);
...@@ -2130,12 +2128,12 @@ int drbd_worker(struct drbd_thread *thi) ...@@ -2130,12 +2128,12 @@ int drbd_worker(struct drbd_thread *thi)
update_worker_timing_details(connection, do_unqueued_work); update_worker_timing_details(connection, do_unqueued_work);
do_unqueued_work(connection); do_unqueued_work(connection);
} }
while (!list_empty(&work_list)) { if (!list_empty(&work_list)) {
w = list_first_entry(&work_list, struct drbd_work, list); w = list_first_entry(&work_list, struct drbd_work, list);
list_del_init(&w->list); list_del_init(&w->list);
update_worker_timing_details(connection, w->cb); update_worker_timing_details(connection, w->cb);
w->cb(w, 1); w->cb(w, 1);
} } else
dequeue_work_batch(&connection->sender_work, &work_list); dequeue_work_batch(&connection->sender_work, &work_list);
} while (!list_empty(&work_list) || test_bit(DEVICE_WORK_PENDING, &connection->flags)); } while (!list_empty(&work_list) || test_bit(DEVICE_WORK_PENDING, &connection->flags));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment