Whamcloud - gitweb
LU-12686 lnet: change ln_mt_waitq to a completion. 74/35874/2
authorMr NeilBrown <neilb@suse.com>
Thu, 22 Aug 2019 04:58:12 +0000 (14:58 +1000)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Sep 2019 23:04:51 +0000 (23:04 +0000)
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 <neilb@suse.com>
Change-Id: I10df4b33ee59f579b965e44c022175b8ab007626
Reviewed-on: https://review.whamcloud.com/35874
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <hornc@cray.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/lnet/lib-types.h
lnet/lnet/api-ni.c
lnet/lnet/lib-move.c
lnet/lnet/lib-msg.c
lnet/lnet/router.c

index e0e82b5..b446414 100644 (file)
@@ -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;
index d50c939..3a68ae8 100644 (file)
@@ -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);
 }
 
index e3bad23..1706ef7 100644 (file)
@@ -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);
index 416cf42..fcf021a 100644 (file)
@@ -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
index 9fdfc2a..6daca44 100644 (file)
@@ -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: