Whamcloud - gitweb
LU-5415 ldlm: high load because of negative timeout 27/11227/5
authorLi Xi <lixi@ddn.com>
Fri, 25 Jul 2014 03:08:03 +0000 (11:08 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 12 Aug 2014 14:13:59 +0000 (14:13 +0000)
When the time of LRU resizing exceeds waiting period of
recalculation, the ldlm daemon will keep on resizing without any
interval of rest. That will cause high CPU load.

This patch fixes the problem by setting the recalculation timestamp
after LRU resizing finishes rather than before it. What is more, an
interval of one second is enforced between each recalculation.

Signed-off-by: Li Xi <lixi@ddn.com>
Change-Id: I63b1951882754952e8ea8d921f42ddad1e6daa33
Reviewed-on: http://review.whamcloud.com/11227
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ldlm/ldlm_pool.c

index b3eaf1c..522f947 100644 (file)
@@ -480,6 +480,7 @@ static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl)
 static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
 {
         time_t recalc_interval_sec;
 static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
 {
         time_t recalc_interval_sec;
+       int ret;
         ENTRY;
 
         recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
         ENTRY;
 
         recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time;
@@ -500,17 +501,13 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
          * Make sure that pool knows last SLV and Limit from obd.
          */
         ldlm_cli_pool_pop_slv(pl);
          * Make sure that pool knows last SLV and Limit from obd.
          */
         ldlm_cli_pool_pop_slv(pl);
-
-        pl->pl_recalc_time = cfs_time_current_sec();
-        lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
-                            recalc_interval_sec);
        spin_unlock(&pl->pl_lock);
 
         /*
          * Do not cancel locks in case lru resize is disabled for this ns.
          */
         if (!ns_connect_lru_resize(ldlm_pl2ns(pl)))
        spin_unlock(&pl->pl_lock);
 
         /*
          * Do not cancel locks in case lru resize is disabled for this ns.
          */
         if (!ns_connect_lru_resize(ldlm_pl2ns(pl)))
-                RETURN(0);
+               GOTO(out, ret = 0);
 
         /*
          * In the time of canceling locks on client we do not need to maintain
 
         /*
          * In the time of canceling locks on client we do not need to maintain
@@ -518,8 +515,20 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
          * It may be called when SLV has changed much, this is why we do not
          * take into account pl->pl_recalc_time here.
          */
          * It may be called when SLV has changed much, this is why we do not
          * take into account pl->pl_recalc_time here.
          */
-       RETURN(ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC,
-                              LDLM_CANCEL_LRUR));
+       ret = ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC,
+                              LDLM_CANCEL_LRUR);
+
+out:
+       spin_lock(&pl->pl_lock);
+       /*
+        * Time of LRU resizing might be longer than period,
+        * so update after LRU resizing rather than before it.
+        */
+       pl->pl_recalc_time = cfs_time_current_sec();
+       lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
+                           recalc_interval_sec);
+       spin_unlock(&pl->pl_lock);
+       RETURN(ret);
 }
 
 /**
 }
 
 /**
@@ -608,6 +617,14 @@ int ldlm_pool_recalc(struct ldlm_pool *pl)
         }
        recalc_interval_sec = pl->pl_recalc_time - cfs_time_current_sec() +
                              pl->pl_recalc_period;
         }
        recalc_interval_sec = pl->pl_recalc_time - cfs_time_current_sec() +
                              pl->pl_recalc_period;
+       if (recalc_interval_sec <= 0) {
+               /* Prevent too frequent recalculation. */
+               CDEBUG(D_DLMTRACE, "Negative interval(%ld), "
+                      "too short period(%ld)",
+                      recalc_interval_sec,
+                      pl->pl_recalc_period);
+               recalc_interval_sec = 1;
+       }
 
         return recalc_interval_sec;
 }
 
         return recalc_interval_sec;
 }