mm,compaction: serialize waitqueue_active() checks (for real)
Subsystems (2)
PATCH 1/1 mm,compaction: serialize waitqueue_active() checks (for real)
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.
--- mm/compaction.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
mm/compaction.c +5 -6
@@ -1999,17 +1999,16 @@ 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))
Signature · 1 line
2.12.0
Quoted 6 lines · Davidlohr Bueso
(quoted diff) +0
-5- /* - * 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();
sorry, forgot to delete this. Here's v2.
-----8<----------------------------------------------------- [PATCH v2] mm,compaction: serialize waitqueue_active() checks (for real)
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.
---mm/compaction.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
mm/compaction.c +0 -0
@@ -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))
Signature · 1 line
2.12.0