From b81bcc6c6f0c54c48e908eccb13adc620582881e Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Thu, 22 Aug 2019 14:58:12 +1000 Subject: [PATCH 1/1] LU-12686 lnet: change ln_mt_waitq to a completion. ln_mt_waitq is only waited on by a call to wait_event_interruptible_timeout(..., false, timeout); As 'false' is never 'true', this will always wait for the full timeout to expire. So the waitq is effectively pointless. To acheive the apparent intent of the waitq, change it to a completion. The completion adds a 'done' flag to a waitq so we can wait until a timeout or until a wakeup is requested. With this, a longer timeout would could be used, but that is left to a later patch. Signed-off-by: Mr NeilBrown Change-Id: I10df4b33ee59f579b965e44c022175b8ab007626 Reviewed-on: https://review.whamcloud.com/35874 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Chris Horn Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lnet/include/lnet/lib-types.h | 4 ++-- lnet/lnet/api-ni.c | 2 +- lnet/lnet/lib-move.c | 12 ++++++++---- lnet/lnet/lib-msg.c | 2 +- lnet/lnet/router.c | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index e0e82b5..b446414 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -1126,10 +1126,10 @@ struct lnet { bool ln_nis_from_mod_params; /* - * waitq for the monitor thread. The monitor thread takes care of + * completion for the monitor thread. The monitor thread takes care of * checking routes, timedout messages and resending messages. */ - wait_queue_head_t ln_mt_waitq; + struct completion ln_mt_wait_complete; /* per-cpt resend queues */ struct list_head **ln_mt_resendqs; diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index d50c939..3a68ae8 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -546,7 +546,7 @@ lnet_init_locks(void) spin_lock_init(&the_lnet.ln_eq_wait_lock); spin_lock_init(&the_lnet.ln_msg_resend_lock); init_waitqueue_head(&the_lnet.ln_eq_waitq); - init_waitqueue_head(&the_lnet.ln_mt_waitq); + init_completion(&the_lnet.ln_mt_wait_complete); mutex_init(&the_lnet.ln_lnd_mutex); } diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index e3bad23..1706ef7 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -3542,9 +3542,13 @@ lnet_monitor_thread(void *arg) min((unsigned int) alive_router_check_interval / lnet_current_net_count, lnet_transaction_timeout / 2)); - wait_event_interruptible_timeout(the_lnet.ln_mt_waitq, - false, - cfs_time_seconds(interval)); + wait_for_completion_interruptible_timeout( + &the_lnet.ln_mt_wait_complete, + cfs_time_seconds(interval)); + /* Must re-init the completion before testing anything, + * including ln_mt_state. + */ + reinit_completion(&the_lnet.ln_mt_wait_complete); } /* Shutting down */ @@ -3809,7 +3813,7 @@ void lnet_monitor_thr_stop(void) lnet_net_unlock(LNET_LOCK_EX); /* tell the monitor thread that we're shutting down */ - wake_up(&the_lnet.ln_mt_waitq); + complete(&the_lnet.ln_mt_wait_complete); /* block until monitor thread signals that it's done */ down(&the_lnet.ln_mt_signal); diff --git a/lnet/lnet/lib-msg.c b/lnet/lnet/lib-msg.c index 416cf42..fcf021a 100644 --- a/lnet/lnet/lib-msg.c +++ b/lnet/lnet/lib-msg.c @@ -637,7 +637,7 @@ lnet_resend_msg_locked(struct lnet_msg *msg) list_add_tail(&msg->msg_list, the_lnet.ln_mt_resendqs[msg->msg_tx_cpt]); - wake_up(&the_lnet.ln_mt_waitq); + complete(&the_lnet.ln_mt_wait_complete); } int diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index 9fdfc2a..6daca44 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -706,7 +706,7 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, LIBCFS_FREE(rnet, sizeof(*rnet)); /* kick start the monitor thread to handle the added route */ - wake_up(&the_lnet.ln_mt_waitq); + complete(&the_lnet.ln_mt_wait_complete); return rc; } @@ -1458,7 +1458,7 @@ lnet_rtrpools_alloc(int im_a_router) lnet_net_lock(LNET_LOCK_EX); the_lnet.ln_routing = 1; lnet_net_unlock(LNET_LOCK_EX); - wake_up(&the_lnet.ln_mt_waitq); + complete(&the_lnet.ln_mt_wait_complete); return 0; failed: -- 1.8.3.1