]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: minimize calls to sysconf() in scrub_load_below_threshold() 63349/head
authorRonen Friedman <rfriedma@redhat.com>
Sat, 17 May 2025 07:17:42 +0000 (02:17 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Mon, 19 May 2025 12:42:21 +0000 (07:42 -0500)
Return an 'all is OK' value if the 1min CPU load - even before being
divided by the number of CPUs - is below the configured threshold.
This is a very common case, and avoids the need to call sysconf()
to get the number of CPUs.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
(cherry picked from commit 3392bc0f506768b6b3e2d65d549fa2e3b704fd6e)

src/osd/scrubber/osd_scrub.cc

index 6ce087ad9546ffd4dea8b404d426d7393ca85918..f730198fe524a570e6f3eb2ef3728b8a4a68d491 100644 (file)
@@ -306,7 +306,18 @@ std::optional<double> OsdScrub::LoadTracker::update_load_average()
 
 bool OsdScrub::LoadTracker::scrub_load_below_threshold() const
 {
-  // allow scrub if below configured threshold
+  // if the 1-min load average - even before dividing by the number of CPUs -
+  // is below the configured threshold, scrubs are allowed. No need to call
+  // sysconf().
+  if (loadavg_1min < conf->osd_scrub_load_threshold) {
+    dout(20) << fmt::format(
+                   "loadavg {:.3f} < max {:.3f} = yes",
+                   loadavg_1min, conf->osd_scrub_load_threshold)
+            << dendl;
+    return true;
+  }
+
+  // check the load per CPU
   const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
   const double loadavg_per_cpu = cpus > 0 ? loadavg_1min / cpus : loadavg_1min;
   if (loadavg_per_cpu < conf->osd_scrub_load_threshold) {