]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: move load avg units conversion to the client
authorRonen Friedman <rfriedma@redhat.com>
Tue, 20 May 2025 07:29:04 +0000 (02:29 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Tue, 20 May 2025 10:45:59 +0000 (05:45 -0500)
The OSD calls OsdScrub::update_load_average() to find out the load
average, and notes it down in a performance counter. The system
load average is multipled by 100 (to improve precision). That
multiplication should be on the side of the client, not the
scrub queue service.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/OSD.cc
src/osd/scrubber/osd_scrub.cc
src/osd/scrubber/osd_scrub.h

index c46ce54b202b38a687d7a2a81f0e2886af1109eb..73428c796372a590da04d1b12bec24f4d8ecc6a5 100644 (file)
@@ -6285,12 +6285,9 @@ void OSD::heartbeat_check()
 void OSD::heartbeat()
 {
   ceph_assert(ceph_mutex_is_locked_by_me(heartbeat_lock));
-  dout(30) << "heartbeat" << dendl;
-
-  auto load_for_logger = service.get_scrub_services().update_load_average();
-  if (load_for_logger) {
-    logger->set(l_osd_loadavg, load_for_logger.value());
-  }
+  logger->set(
+      l_osd_loadavg,
+      100.0 * service.get_scrub_services().update_load_average().value_or(0.0));
   dout(30) << "heartbeat checking stats" << dendl;
 
   // refresh peer list and osd stats
index 305d9e768366873ac1e738d14ccb396ae615b556..512071859497e765dca905a210cb8962ac3dd420 100644 (file)
@@ -275,7 +275,7 @@ std::optional<double> OsdScrub::update_load_average()
   if (getloadavg(&loadavg, 1) != 1) {
     return std::nullopt;
   }
-  return 100 * loadavg;
+  return loadavg;
 }
 
 
@@ -299,7 +299,7 @@ bool OsdScrub::scrub_load_below_threshold() const
     return true;
   }
 
-  dout(10) << fmt::format(
+  dout(5) << fmt::format(
                  "loadavg {:.3f} >= max {:.3f} (#CPUs:{}) = no",
                  loadavg_per_cpu, conf->osd_scrub_load_threshold,
                  loadavg_cpu_count)
index 932860c92ff062d10b8b668f72ab8057a743e952..4e510c91182d3ec1b6687053c1e72bcf9881aa5c 100644 (file)
@@ -118,13 +118,13 @@ class OsdScrub {
   [[nodiscard]] bool scrub_time_permit(utime_t t) const;
 
   /**
-   * An external interface into the LoadTracker object. Used by
-   * the OSD tick to update the load data in the logger.
+   * Fetch the 1-minute load average. Used by
+   * the OSD heartbeat handler to update a performance counter.
+   * Also updates the number of CPUs, required internally by the
+   * scrub queue.
    *
-   * \returns 100*(the decaying (running) average of the CPU load
-   *          over the last 24 hours) or nullopt if the load is not
-   *          available.
-   * Note that the multiplication by 100 is required by the logger interface
+   * \returns the 1-minute element of getloadavg() or nullopt
+   *          if the load is not available.
    */
   std::optional<double> update_load_average();