* wait-simple stuff
@ 2013-10-04 14:56 Peter Zijlstra
0 siblings, 0 replies; only message in thread
From: Peter Zijlstra @ 2013-10-04 14:56 UTC (permalink / raw)
To: Thomas Gleixner, rostedt; +Cc: linux-kernel
Hi guys,
Would something like the below break something?
>From a quick read things seems fine for both the simple-waitqueue as the
completions.
Without that lockbreak in I can't see how the kernel would still be
deterministic as you can pile as many tasks as you want on these
waitqueues.
---
kernel/sched/core.c | 4 ++--
kernel/wait-simple.c | 12 +++++++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d2a85b2b58f0..ae2fbef70971 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3496,7 +3496,7 @@ void complete(struct completion *x)
raw_spin_lock_irqsave(&x->wait.lock, flags);
x->done++;
- __swait_wake_locked(&x->wait, TASK_NORMAL, 1);
+ __swait_wake_locked(&x->wait, TASK_NORMAL, 1, &flags);
raw_spin_unlock_irqrestore(&x->wait.lock, flags);
}
EXPORT_SYMBOL(complete);
@@ -3516,7 +3516,7 @@ void complete_all(struct completion *x)
raw_spin_lock_irqsave(&x->wait.lock, flags);
x->done += UINT_MAX/2;
- __swait_wake_locked(&x->wait, TASK_NORMAL, 0);
+ __swait_wake_locked(&x->wait, TASK_NORMAL, 0, &flags);
raw_spin_unlock_irqrestore(&x->wait.lock, flags);
}
EXPORT_SYMBOL(complete_all);
diff --git a/kernel/wait-simple.c b/kernel/wait-simple.c
index 7dfa86d1f654..3a20cbff91dd 100644
--- a/kernel/wait-simple.c
+++ b/kernel/wait-simple.c
@@ -73,12 +73,13 @@ void swait_finish(struct swait_head *head, struct swaiter *w)
EXPORT_SYMBOL(swait_finish);
unsigned int
-__swait_wake_locked(struct swait_head *head, unsigned int state, unsigned int num)
+__swait_wake_locked(struct swait_head *head, unsigned int state,
+ unsigned int num, unsigned long *flags)
{
- struct swaiter *curr, *next;
+ struct swaiter *curr;
int woken = 0;
- list_for_each_entry_safe(curr, next, &head->list, node) {
+ while ((curr = list_first_entry_or_null(&head->list, struct swaiter, node))) {
if (wake_up_state(curr->task, state)) {
__swait_dequeue(curr);
/*
@@ -94,6 +95,11 @@ __swait_wake_locked(struct swait_head *head, unsigned int state, unsigned int nu
if (++woken == num)
break;
}
+
+ if (need_resched()) {
+ raw_spin_unlock_irqrestore(&head->lock, *flags);
+ raw_spin_lock_irqsave(&head->lock, *flags);
+ }
}
return woken;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-10-04 14:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-04 14:56 wait-simple stuff Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®