Skip to content

Commit

Permalink
mm,compaction: serialize waitqueue_active() checks (for real)
Browse files Browse the repository at this point in the history
Andrea brought to my attention that the L->{L,S} guarantees are
completely bogus for this case.  I was looking at the diagram, from the
offending commit, when that _is_ the race, we had the load reordered
already.

What we need is at least S->L semantics, thus simply use
wq_has_sleeper() to serialize the call for good.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 46acef0 (mm,compaction: serialize waitqueue_active() checks)
Signed-off-by: Davidlohr Bueso <[email protected]>
Reported-by: Andrea Parri <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Davidlohr Bueso authored and torvalds committed Oct 4, 2017
1 parent a1b2289 commit 6818600
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions mm/compaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1999,17 +1999,14 @@ void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
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;

if (!waitqueue_active(&pgdat->kcompactd_wait))
/*
* Pairs with implicit barrier in wait_event_freezable()
* such that wakeups are not missed.
*/
if (!wq_has_sleeper(&pgdat->kcompactd_wait))
return;

if (!kcompactd_node_suitable(pgdat))
Expand Down

0 comments on commit 6818600

Please sign in to comment.