From 948e0426b3527d9ab1c92b7a8b90ba6f4bec8043 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Tue, 20 May 2025 02:29:04 -0500 Subject: [PATCH] osd: move load avg units conversion to the client 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 --- src/osd/OSD.cc | 9 +++------ src/osd/scrubber/osd_scrub.cc | 4 ++-- src/osd/scrubber/osd_scrub.h | 12 ++++++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index c46ce54b202b3..73428c796372a 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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 diff --git a/src/osd/scrubber/osd_scrub.cc b/src/osd/scrubber/osd_scrub.cc index 305d9e7683668..512071859497e 100644 --- a/src/osd/scrubber/osd_scrub.cc +++ b/src/osd/scrubber/osd_scrub.cc @@ -275,7 +275,7 @@ std::optional 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) diff --git a/src/osd/scrubber/osd_scrub.h b/src/osd/scrubber/osd_scrub.h index 932860c92ff06..4e510c91182d3 100644 --- a/src/osd/scrubber/osd_scrub.h +++ b/src/osd/scrubber/osd_scrub.h @@ -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 update_load_average(); -- 2.39.5