From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>, rostedt@goodmis.org
Cc: linux-kernel@vger.kernel.org
Subject: wait-simple stuff
Date: Fri, 4 Oct 2013 16:56:25 +0200 [thread overview]
Message-ID: <20131004145625.GN3081@twins.programming.kicks-ass.net> (raw)
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;
}
reply other threads:[~2013-10-04 14:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131004145625.GN3081@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®