]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: get loadavg per cpu for scrub load threshold check 17718/head
authorkungf <yang.wang@easystack.cn>
Thu, 14 Sep 2017 06:09:30 +0000 (14:09 +0800)
committerkungf <yang.wang@easystack.cn>
Thu, 14 Sep 2017 09:00:23 +0000 (17:00 +0800)
Signed-off-by: kungf <yang.wang@easystack.cn>
src/osd/OSD.cc

index 0dd6155274799147d7cf71475bac2a2c41efaaa8..b530a683d1f41e725b11f107e22b5597d141e0f1 100644 (file)
@@ -13,7 +13,7 @@
  *
  */
 #include "acconfig.h"
-
+#include <unistd.h>
 #include <fstream>
 #include <iostream>
 #include <errno.h>
@@ -7099,8 +7099,10 @@ bool OSD::scrub_load_below_threshold()
   }
 
   // allow scrub if below configured threshold
-  if (loadavgs[0] < cct->_conf->osd_scrub_load_threshold) {
-    dout(20) << __func__ << " loadavg " << loadavgs[0]
+  long cpus = sysconf(_SC_NPROCESSORS_ONLN);
+  double loadavg_per_cpu = cpus > 0 ? loadavgs[0] / cpus : loadavgs[0];
+  if (loadavg_per_cpu < cct->_conf->osd_scrub_load_threshold) {
+    dout(20) << __func__ << " loadavg per cpu " << loadavg_per_cpu
             << " < max " << cct->_conf->osd_scrub_load_threshold
             << " = yes" << dendl;
     return true;