lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 4 Oct 2013 16:56:25 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Thomas Gleixner <tglx@...utronix.de>, rostedt@...dmis.org
Cc:	linux-kernel@...r.kernel.org
Subject: wait-simple stuff

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;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ