Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751497AbdINAJY (ORCPT ); Wed, 13 Sep 2017 20:09:24 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:47594 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751173AbdINAJV (ORCPT ); Wed, 13 Sep 2017 20:09:21 -0400 From: Davidlohr Bueso To: akpm@linux-foundation.org Cc: vbabka@suse.cz, parri.andrea@gmail.com, dave@stgolabs.net, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH] mm,compaction: serialize waitqueue_active() checks (for real) Date: Wed, 13 Sep 2017 17:09:08 -0700 Message-Id: <20170914000908.713-1-dave@stgolabs.net> X-Mailer: git-send-email 2.12.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1452 Lines: 44 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. Fixes: 46acef048a6 (mm,compaction: serialize waitqueue_active() checks) Reported-by: Andrea Parri Signed-off-by: Davidlohr Bueso --- mm/compaction.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index fb548e4c7bd4..d1ad2cf6c758 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -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)) -- 2.12.0