History

wait: add wq_has_single_sleeper helper

rq-qos sits in the io path so we want to take locks as sparingly as possible. To accomplish this we try not to take the waitqueue head lock unless we are sure we need to go to sleep, and we have an optimization to make sure that we don't starve out existing waiters. Since we check if there are existing waiters locklessly we need to be able to update our view of the waitqueue list after we've added ourselves to the waitqueue. Accomplish this by adding this helper to see if there is more than just ourselves on the list.

Josef Bacik committed 7 years ago

Commit a6d81d31 parent b5e02b41 file · +13 −0Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/wait.h+13−0
@@ -126,6 +126,19 @@ static inline int waitqueue_active(struct wait_queue_head *wq_head) · 125 unmodified lines
126126 return !list_empty(&wq_head->head);
127127 }
128128
129+/**
130+ * wq_has_single_sleeper - check if there is only one sleeper
131+ * @wq_head: wait queue head
132+ *
133+ * Returns true of wq_head has only one sleeper on the list.
134+ *
135+ * Please refer to the comment for waitqueue_active.
136+ */
137+static inline bool wq_has_single_sleeper(struct wait_queue_head *wq_head)
138+{
139+ return list_is_singular(&wq_head->head);
140+}
141+
129142 /**
130143 * wq_has_sleeper - check if there are any waiting processes
131144 * @wq_head: wait queue head

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t