* + mmcompaction-serialize-waitqueue_active-checks.patch added to -mm tree
@ 2017-01-09 22:34 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2017-01-09 22:34 UTC (permalink / raw)
To: dave, dbueso, vbabka, mm-commits
The patch titled
Subject: mm,compaction: serialize waitqueue_active() checks
has been added to the -mm tree. Its filename is
mmcompaction-serialize-waitqueue_active-checks.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/mmcompaction-serialize-waitqueue_active-checks.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/mmcompaction-serialize-waitqueue_active-checks.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Davidlohr Bueso <dave@stgolabs.net>
Subject: mm,compaction: serialize waitqueue_active() checks
Without a memory barrier, the following race can occur with a high-order
allocation:
wakeup_kcompactd(order == 1) kcompactd()
[L] waitqueue_active(kcompactd_wait)
[S] prepare_to_wait_event(kcompactd_wait)
[L] (kcompactd_max_order == 0)
[S] kcompactd_max_order = order; schedule()
Where the waitqueue_active() check is speculatively re-ordered to before
setting the actual condition (max_order), not seeing the threads that's
going to block; making us miss a wakeup. There are a couple of options to
fix this, including calling wq_has_sleepers() which adds a full barrier,
or unconditionally doing the wake_up_interruptible() and serialize on the
q->lock. However, to make use of the control dependency, we just need to
add L->L guarantees.
While this bug is theoretical, there have been other offenders of the lockless
waitqueue_active() in the past -- this is also documented in the call itself.
Link: http://lkml.kernel.org/r/1483975528-24342-1-git-send-email-dave@stgolabs.net
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/compaction.c | 7 +++++++
1 file changed, 7 insertions(+)
diff -puN mm/compaction.c~mmcompaction-serialize-waitqueue_active-checks mm/compaction.c
--- a/mm/compaction.c~mmcompaction-serialize-waitqueue_active-checks
+++ a/mm/compaction.c
@@ -1966,6 +1966,13 @@ void wakeup_kcompactd(pg_data_t *pgdat,
if (pgdat->kcompactd_max_order < order)
pgdat->kcompactd_max_order = order;
+ /*
+ * Pairs with implicit barrier in wait_event_freezable()
+ * such that wakeups are not missed in the lockless
+ * waitqueue_active() call.
+ */
+ smp_acquire__after_ctrl_dep();
+
if (pgdat->kcompactd_classzone_idx > classzone_idx)
pgdat->kcompactd_classzone_idx = classzone_idx;
_
Patches currently in -mm which might be from dave@stgolabs.net are
m32r-use-generic-currenth.patch
mmcompaction-serialize-waitqueue_active-checks.patch
kernel-exit-compute-current-directly.patch
drivers-tty-compute-current-directly.patch
kernel-locking-compute-current-directly.patch
sched-remove-set_task_state.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-01-09 22:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 22:34 + mmcompaction-serialize-waitqueue_active-checks.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.