Home Home > GIT Browse > SLE12-SP3-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavidlohr Bueso <dbueso@suse.de>2019-02-18 12:48:17 -0800
committerDavidlohr Bueso <dbueso@suse.de>2019-02-18 12:48:24 -0800
commit5442adacb276e856b9dc7cdf4b7946a865889bcd (patch)
treec93242a3a6340a4c6b1aa4c2990ea47aeca300c6
parentcbe95a3701d8c3a4c5f459d7af01b63862c8f666 (diff)
sched/wake_q: Fix wakeup ordering for wake_q (bsc#1050549).
-rw-r--r--patches.fixes/0002-sched-wake_q-Fix-wakeup-ordering-for-wake_q.patch97
-rw-r--r--series.conf1
2 files changed, 98 insertions, 0 deletions
diff --git a/patches.fixes/0002-sched-wake_q-Fix-wakeup-ordering-for-wake_q.patch b/patches.fixes/0002-sched-wake_q-Fix-wakeup-ordering-for-wake_q.patch
new file mode 100644
index 0000000000..4fbd93ab49
--- /dev/null
+++ b/patches.fixes/0002-sched-wake_q-Fix-wakeup-ordering-for-wake_q.patch
@@ -0,0 +1,97 @@
+From 63f8f1ba3f28d32883e39f8f6be26fb3f0658d96 Mon Sep 17 00:00:00 2001
+From: Peter Zijlstra <peterz@infradead.org>
+Date: Mon, 18 Feb 2019 09:14:51 -0800
+Subject: [PATCH 2/2] sched/wake_q: Fix wakeup ordering for wake_q
+Git-commit: 4c4e3731564c8945ac5ac90fc2a1e1f21cb79c92
+Patch-mainline: v5.0-rc4
+References: bsc#1050549
+
+Notable cmpxchg() does not provide ordering when it fails, however
+wake_q_add() requires ordering in this specific case too. Without this
+it would be possible for the concurrent wakeup to not observe our
+prior state.
+
+Andrea Parri provided:
+
+ C wake_up_q-wake_q_add
+
+ {
+ int next = 0;
+ int y = 0;
+ }
+
+ P0(int *next, int *y)
+ {
+ int r0;
+
+ /* in wake_up_q() */
+
+ WRITE_ONCE(*next, 1); /* node->next = NULL */
+ smp_mb(); /* implied by wake_up_process() */
+ r0 = READ_ONCE(*y);
+ }
+
+ P1(int *next, int *y)
+ {
+ int r1;
+
+ /* in wake_q_add() */
+
+ WRITE_ONCE(*y, 1); /* wake_cond = true */
+ smp_mb__before_atomic();
+ r1 = cmpxchg_relaxed(next, 1, 2);
+ }
+
+ exists (0:r0=0 /\ 1:r1=0)
+
+ This "exists" clause cannot be satisfied according to the LKMM:
+
+ Test wake_up_q-wake_q_add Allowed
+ States 3
+ 0:r0=0; 1:r1=1;
+ 0:r0=1; 1:r1=0;
+ 0:r0=1; 1:r1=1;
+ No
+ Witnesses
+ Positive: 0 Negative: 3
+ Condition exists (0:r0=0 /\ 1:r1=0)
+ Observation wake_up_q-wake_q_add Never 0 3
+
+Reported-by: Yongji Xie <elohimes@gmail.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Cc: Davidlohr Bueso <dave@stgolabs.net>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: Waiman Long <longman@redhat.com>
+Cc: Will Deacon <will.deacon@arm.com>
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
+
+
+---
+ kernel/sched/core.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/kernel/sched/core.c b/kernel/sched/core.c
+index 5f68564cf53d..b5f7fd0b5938 100644
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -609,10 +609,11 @@ void wake_q_add(struct wake_q_head *head, struct task_struct *task)
+ * its already queued (either by us or someone else) and will get the
+ * wakeup due to that.
+ *
+- * This cmpxchg() implies a full barrier, which pairs with the write
+- * barrier implied by the wakeup in wake_up_q().
++ * In order to ensure that a pending wakeup will observe our pending
++ * state, even in the failed case, an explicit smp_mb() must be used.
+ */
+- if (cmpxchg(&node->next, NULL, WAKE_Q_TAIL))
++ smp_mb__before_atomic();
++ if (cmpxchg_relaxed(&node->next, NULL, WAKE_Q_TAIL))
+ return;
+
+ get_task_struct(task);
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 37dc1ec966..196d23c39a 100644
--- a/series.conf
+++ b/series.conf
@@ -24252,6 +24252,7 @@
patches.fixes/acpi-nfit-block-function-zero-dsms.patch
patches.fixes/acpi-nfit-fix-command-supported-detection.patch
patches.fixes/0001-sched-wake_q-Document-wake_q_add.patch
+ patches.fixes/0002-sched-wake_q-Fix-wakeup-ordering-for-wake_q.patch
patches.arch/x86-pkeys-properly-copy-pkey-state-at-fork
patches.drivers/iommu-amd-call-free_iova_fast-with-pfn-in-map_sg
patches.drivers/iommu-amd-unmap-all-mapped-pages-in-error-path-of-map_sg