From patchwork Thu Feb 27 21:14:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410697 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D909817E0 for ; Thu, 27 Feb 2020 21:44:39 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1E2E24690 for ; Thu, 27 Feb 2020 21:44:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1E2E24690 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6A88521FFD4; Thu, 27 Feb 2020 13:35:42 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5F90A21FE2E for ; Thu, 27 Feb 2020 13:20:27 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 2EBD48F16; Thu, 27 Feb 2020 16:18:18 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 2D3FA47C; Thu, 27 Feb 2020 16:18:18 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:14:43 -0500 Message-Id: <1582838290-17243-416-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 415/622] lnet: Sync the start of discovery and monitor threads X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Chris Horn The discovery thread starts up before the monitor thread so it may issue PUTs or GETs before the monitor thread has a chance to initialize its data structures (namely the_lnet.ln_mt_rstq). This can result in an OOPs when we attempt to attach response trackers to MDs. Introduce a completion to synchronize the startup of these threads. WC-bug-id: https://jira.whamcloud.com/browse/LU-12537 Lustre-commit: 9283e2ed6655 ("LU-12537 lnet: Sync the start of discovery and monitor threads") Signed-off-by: Chris Horn Reviewed-on: https://review.whamcloud.com/35478 Reviewed-by: Alexandr Boyko Reviewed-by: Amir Shehata Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- include/linux/lnet/lib-types.h | 5 +++++ net/lnet/lnet/api-ni.c | 3 +++ net/lnet/lnet/lib-move.c | 1 + net/lnet/lnet/peer.c | 11 ++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/linux/lnet/lib-types.h b/include/linux/lnet/lib-types.h index b240361..1009a69 100644 --- a/include/linux/lnet/lib-types.h +++ b/include/linux/lnet/lib-types.h @@ -1161,6 +1161,11 @@ struct lnet { /* recovery eq handler */ struct lnet_handle_eq ln_mt_eqh; + /* + * Completed when the discovery and monitor threads can enter their + * work loops + */ + struct completion ln_started; }; #endif diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c index 65f1f17..aa5ca52 100644 --- a/net/lnet/lnet/api-ni.c +++ b/net/lnet/lnet/api-ni.c @@ -1062,6 +1062,7 @@ struct lnet_libhandle * INIT_LIST_HEAD(&the_lnet.ln_mt_peerNIRecovq); init_waitqueue_head(&the_lnet.ln_dc_waitq); LNetInvalidateEQHandle(&the_lnet.ln_mt_eqh); + init_completion(&the_lnet.ln_started); rc = lnet_descriptor_setup(); if (rc != 0) @@ -2583,6 +2584,8 @@ void lnet_lib_exit(void) mutex_unlock(&the_lnet.ln_api_mutex); + complete_all(&the_lnet.ln_started); + /* wait for all routers to start */ lnet_wait_router_start(); diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c index 9a4c426..413397c 100644 --- a/net/lnet/lnet/lib-move.c +++ b/net/lnet/lnet/lib-move.c @@ -3529,6 +3529,7 @@ void lnet_monitor_thr_stop(void) lnet_build_msg_event(msg, LNET_EVENT_PUT); + wait_for_completion(&the_lnet.ln_started); /* * Must I ACK? If so I'll grab the ack_wmd out of the header and put * it back into the ACK during lnet_finalize() diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c index b0ca1de..49da7a1 100644 --- a/net/lnet/lnet/peer.c +++ b/net/lnet/lnet/peer.c @@ -3258,6 +3258,8 @@ static int lnet_peer_discovery(void *arg) struct lnet_peer *lp; int rc; + wait_for_completion(&the_lnet.ln_started); + CDEBUG(D_NET, "started\n"); for (;;) { @@ -3429,7 +3431,14 @@ void lnet_peer_discovery_stop(void) LASSERT(the_lnet.ln_dc_state == LNET_DC_STATE_RUNNING); the_lnet.ln_dc_state = LNET_DC_STATE_STOPPING; - wake_up(&the_lnet.ln_dc_waitq); + + /* In the LNetNIInit() path we may be stopping discovery before it + * entered its work loop + */ + if (!completion_done(&the_lnet.ln_started)) + complete(&the_lnet.ln_started); + else + wake_up(&the_lnet.ln_dc_waitq); wait_event(the_lnet.ln_dc_waitq, the_lnet.ln_dc_state == LNET_DC_STATE_SHUTDOWN);