Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wait: kill is_sync_wait()

is_sync_wait() is used to distinguish between sync and async waits.
Basically sync waits are the ones initialized with init_waitqueue_entry()
and async ones with init_waitqueue_func_entry(). The sync/async
distinction is used only in prepare_to_wait[_exclusive]() and its only
function is to skip setting the current task state if the wait is async.
This has a few problems.

* No one uses it. None of func_entry users use prepare_to_wait()
functions, so the code path never gets executed.

* The distinction is bogus. Maybe back when func_entry is used only
by aio but it's now also used by epoll and in future possibly by 9p
and poll/select.

* Taking @state as argument and ignoring it silenly depending on how
@wait is initialized is just a bad error-prone API.

* It prevents func_entry waits from using wait->private for no good
reason.

This patch kills is_sync_wait() and the associated code paths from
prepare_to_wait[_exclusive](). As there was no user of these code paths,
this patch doesn't cause any behavior difference.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Tejun Heo and committed by
Linus Torvalds
a25d644f c80cfb04

+2 -21
-9
include/linux/wait.h
··· 108 108 return !list_empty(&q->task_list); 109 109 } 110 110 111 - /* 112 - * Used to distinguish between sync and async io wait context: 113 - * sync i/o typically specifies a NULL wait queue entry or a wait 114 - * queue entry bound to a task (current task) to wake up. 115 - * aio specifies a wait queue entry with an async notification 116 - * callback routine, not associated with any task. 117 - */ 118 - #define is_sync_wait(wait) (!(wait) || ((wait)->private)) 119 - 120 111 extern void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait); 121 112 extern void add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t *wait); 122 113 extern void remove_wait_queue(wait_queue_head_t *q, wait_queue_t *wait);
+2 -12
kernel/wait.c
··· 72 72 spin_lock_irqsave(&q->lock, flags); 73 73 if (list_empty(&wait->task_list)) 74 74 __add_wait_queue(q, wait); 75 - /* 76 - * don't alter the task state if this is just going to 77 - * queue an async wait queue callback 78 - */ 79 - if (is_sync_wait(wait)) 80 - set_current_state(state); 75 + set_current_state(state); 81 76 spin_unlock_irqrestore(&q->lock, flags); 82 77 } 83 78 EXPORT_SYMBOL(prepare_to_wait); ··· 86 91 spin_lock_irqsave(&q->lock, flags); 87 92 if (list_empty(&wait->task_list)) 88 93 __add_wait_queue_tail(q, wait); 89 - /* 90 - * don't alter the task state if this is just going to 91 - * queue an async wait queue callback 92 - */ 93 - if (is_sync_wait(wait)) 94 - set_current_state(state); 94 + set_current_state(state); 95 95 spin_unlock_irqrestore(&q->lock, flags); 96 96 } 97 97 EXPORT_SYMBOL(prepare_to_wait_exclusive);