: wait: don't resched in prepare_to_wait()
RFC PATCH 1/1 : wait: don't resched in prepare_to_wait()
Does the below make sense?
After prepare to wait, we either call schedule() or find !cond in which case we'll call finish_wait() which contains another preemption check.
--- kernel/wait.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/wait.c +4 -0
@@ -73,7 +73,9 @@ prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)if (list_empty (&wait->task_list))__add_wait_queue (q, wait);set_current_state (state); +preempt_disable ();spin_unlock_irqrestore (&q->lock, flags); +preempt_enable_no_resched (); }EXPORT_SYMBOL (prepare_to_wait);
@@ -87,7 +89,9 @@ prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *wait, int state)if (list_empty (&wait->task_list))__add_wait_queue_tail (q, wait);set_current_state (state); +preempt_disable ();spin_unlock_irqrestore (&q->lock, flags); +preempt_enable_no_resched (); }EXPORT_SYMBOL (prepare_to_wait_exclusive);
kernel/wait.c prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state) · line 78
Quoted 11 lines · Peter Zijlstra
After prepare to wait, we either call
schedule()or find !cond in which case we'll callfinish_wait()which contains another preemption check.kernel/wait.c +2
-0@@ -73,7 +73,9 @@ prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)if (list_empty (&wait->task_list))__add_wait_queue (q, wait);set_current_state (state); +preempt_disable ();spin_unlock_irqrestore (&q->lock, flags); +preempt_enable_no_resched ();
But this only helps if the task gets TIF_NEED_RESCHED while it was in spin_lock_irqsave() section, right? This window should be very small unless we have the contention.
Or do you have something else in mind?
Oleg.
Quoted 17 lines · Oleg Nesterov
kernel/wait.c prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state) · line 78
Quoted 11 lines · Peter Zijlstra
After prepare to wait, we either call
schedule()or find !cond in which case we'll callfinish_wait()which contains another preemption check.kernel/wait.c +2
-0@@ -73,7 +73,9 @@ prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)if (list_empty (&wait->task_list))__add_wait_queue (q, wait);set_current_state (state); +preempt_disable ();spin_unlock_irqrestore (&q->lock, flags); +preempt_enable_no_resched ();But this only helps if the task gets
TIF_NEED_RESCHEDwhile it was inspin_lock_irqsave()section, right? This window should be very small unless we have the contention.
Quoted 1 line
Or do you have something else in mind?
No, that was exactly it, we then get preempted only to go to sleep right afterwards, which would cause a schedule anyway.
So its avoiding a schedule.