sched/wait: Disambiguate wq_entry->task_list and wq_head->task_list naming
So I've noticed a number of instances where it was not obvious from the
code whether ->task_list was for a wait-queue head or a wait-queue entry.
Furthermore, there's a number of wait-queue users where the lists are
not for 'tasks' but other entities (poll tables, etc.), in which case
the 'task_list' name is actively confusing.
To clear this all up, name the wait-queue head and entry list structure
fields unambiguously:
struct wait_queue_head::task_list => ::head
struct wait_queue_entry::task_list => ::entry
For example, this code:
rqw->wait.task_list.next != &wait->task_list
... is was pretty unclear (to me) what it's doing, while now it's written this way:
rqw->wait.head.next != &wait->entry
... which makes it pretty clear that we are iterating a list until we see the head.
Other examples are:
list_for_each_entry_safe(pos, next, &x->task_list, task_list) {
list_for_each_entry(wq, &fence->wait.task_list, task_list) {
... where it's unclear (to me) what we are iterating, and during review it's
hard to tell whether it's trying to walk a wait-queue entry (which would be
a bug), while now it's written as:
list_for_each_entry_safe(pos, next, &x->head, entry) {
list_for_each_entry(wq, &fence->wait.head, entry) {
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 6294897..b289c96 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -26,12 +26,12 @@
unsigned int flags;
void *private;
wait_queue_func_t func;
- struct list_head task_list;
+ struct list_head entry;
};
struct wait_queue_head {
spinlock_t lock;
- struct list_head task_list;
+ struct list_head head;
};
typedef struct wait_queue_head wait_queue_head_t;
@@ -44,14 +44,14 @@
#define __WAITQUEUE_INITIALIZER(name, tsk) { \
.private = tsk, \
.func = default_wake_function, \
- .task_list = { NULL, NULL } }
+ .entry = { NULL, NULL } }
#define DECLARE_WAITQUEUE(name, tsk) \
struct wait_queue_entry name = __WAITQUEUE_INITIALIZER(name, tsk)
#define __WAIT_QUEUE_HEAD_INITIALIZER(name) { \
.lock = __SPIN_LOCK_UNLOCKED(name.lock), \
- .task_list = { &(name).task_list, &(name).task_list } }
+ .head = { &(name).head, &(name).head } }
#define DECLARE_WAIT_QUEUE_HEAD(name) \
struct wait_queue_head name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
@@ -121,7 +121,7 @@
*/
static inline int waitqueue_active(struct wait_queue_head *wq_head)
{
- return !list_empty(&wq_head->task_list);
+ return !list_empty(&wq_head->head);
}
/**
@@ -151,7 +151,7 @@
static inline void __add_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
{
- list_add(&wq_entry->task_list, &wq_head->task_list);
+ list_add(&wq_entry->entry, &wq_head->head);
}
/*
@@ -166,7 +166,7 @@
static inline void __add_wait_queue_entry_tail(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
{
- list_add_tail(&wq_entry->task_list, &wq_head->task_list);
+ list_add_tail(&wq_entry->entry, &wq_head->head);
}
static inline void
@@ -179,7 +179,7 @@
static inline void
__remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq_entry)
{
- list_del(&wq_entry->task_list);
+ list_del(&wq_entry->entry);
}
void __wake_up(struct wait_queue_head *wq_head, unsigned int mode, int nr, void *key);
@@ -952,7 +952,7 @@
struct wait_queue_entry name = { \
.private = current, \
.func = function, \
- .task_list = LIST_HEAD_INIT((name).task_list), \
+ .entry = LIST_HEAD_INIT((name).entry), \
}
#define DEFINE_WAIT(name) DEFINE_WAIT_FUNC(name, autoremove_wake_function)
@@ -961,7 +961,7 @@
do { \
(wait)->private = current; \
(wait)->func = autoremove_wake_function; \
- INIT_LIST_HEAD(&(wait)->task_list); \
+ INIT_LIST_HEAD(&(wait)->entry); \
(wait)->flags = 0; \
} while (0)
diff --git a/include/linux/wait_bit.h b/include/linux/wait_bit.h
index 9cc8211..12b2666 100644
--- a/include/linux/wait_bit.h
+++ b/include/linux/wait_bit.h
@@ -45,8 +45,8 @@
.wq_entry = { \
.private = current, \
.func = wake_bit_function, \
- .task_list = \
- LIST_HEAD_INIT((name).wq_entry.task_list), \
+ .entry = \
+ LIST_HEAD_INIT((name).wq_entry.entry), \
}, \
}