* [RFC][PATCH]: wait: don't resched in prepare_to_wait()
@ 2009-03-06 14:39 Peter Zijlstra
2009-03-06 15:41 ` Oleg Nesterov
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2009-03-06 14:39 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, Oleg Nesterov, Nick Piggin; +Cc: lkml
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.
Not-signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/wait.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/kernel/wait.c b/kernel/wait.c
index 42a2dbc..7b866ab 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH]: wait: don't resched in prepare_to_wait()
2009-03-06 14:39 [RFC][PATCH]: wait: don't resched in prepare_to_wait() Peter Zijlstra
@ 2009-03-06 15:41 ` Oleg Nesterov
2009-03-06 15:47 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2009-03-06 15:41 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Ingo Molnar, Thomas Gleixner, Nick Piggin, lkml
On 03/06, Peter Zijlstra wrote:
>
> After prepare to wait, we either call schedule() or find !cond in which
> case we'll call finish_wait() which contains another preemption check.
>
> @@ -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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC][PATCH]: wait: don't resched in prepare_to_wait()
2009-03-06 15:41 ` Oleg Nesterov
@ 2009-03-06 15:47 ` Peter Zijlstra
0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2009-03-06 15:47 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Ingo Molnar, Thomas Gleixner, Nick Piggin, lkml
On Fri, 2009-03-06 at 16:41 +0100, Oleg Nesterov wrote:
> On 03/06, Peter Zijlstra wrote:
> >
> > After prepare to wait, we either call schedule() or find !cond in which
> > case we'll call finish_wait() which contains another preemption check.
> >
> > @@ -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?
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-06 15:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-06 14:39 [RFC][PATCH]: wait: don't resched in prepare_to_wait() Peter Zijlstra
2009-03-06 15:41 ` Oleg Nesterov
2009-03-06 15:47 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).