Whamcloud - gitweb
LU-8307 ldlm: cond_resched in ldlm_bl_thread_main 88/20888/2
authorPatrick Farrell <paf@cray.com>
Mon, 20 Jun 2016 21:15:51 +0000 (16:15 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 May 2017 03:44:08 +0000 (03:44 +0000)
When clearing all of the ldlm LRUs (as Cray does at the end of
a job), a ldlm_bl_work_item is generated for each namespace
and then they are placed on a list for the ldlm_bl threads to
iterate over.

If the number of namespaces greatly exceeds the number of
ldlm_bl threads, a given thread will iterate over many
namespaces without sleeping looking for work.  This can go
on for an extremely long time and result in an RCU stall.

This patch adds a cond_resched() between completing one
work item and looking for the next.  This is a fairly cheap
operation, as it will only schedule if there is an
interrupt waiting, and it will not be called too much -
Even the largest file systems have < 100 namespaces per
ldlm_bl_thread currently.

Signed-off-by: Patrick Farrell <paf@cray.com>
Change-Id: Ic8022faf641ad6ab02462ab376a4bfd510dca14c
Reviewed-on: https://review.whamcloud.com/20888
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Ned Bass <bass6@llnl.gov>
Reviewed-by: Ann Koehler <amk@cray.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ldlm/ldlm_lockd.c

index 651eebe..b29b721 100644 (file)
@@ -2767,6 +2767,11 @@ static int ldlm_bl_thread_main(void *arg)
 
                if (rc == LDLM_ITER_STOP)
                        break;
+
+               /* If there are many namespaces, we will not sleep waiting for
+                * work, and must do a cond_resched to avoid holding the CPU
+                * for too long */
+               cond_resched();
        }
 
        atomic_dec(&blp->blp_num_threads);