From: Ronen Friedman Date: Sat, 17 May 2025 06:04:22 +0000 (-0500) Subject: osd/scrub: remove the 2'nd option for determining 'low load' for scrubbing X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4a0d5ea20acabb522c664b71d702f948098feaaf;p=ceph.git osd/scrub: remove the 2'nd option for determining 'low load' for scrubbing Previously, there were two conditions under which the CPU load was considered low enough to allow scrubbing: - the CPU load was below the configured threshold, or - the load was below a calculated "daily" average, and lower than the 15-min average. That second condition was confusing and surprising, and is now removed. As the scrubber logic no longer requires the 5m & 15m load averages, scrub_load_below_threshold() can use the data gathered by the periodic LoadTracker::update_load_average(). Fixes: https://tracker.ceph.com/issues/71347 Signed-off-by: Ronen Friedman --- diff --git a/src/osd/scrubber/osd_scrub.cc b/src/osd/scrubber/osd_scrub.cc index d119ad754deb9..6ce087ad9546f 100644 --- a/src/osd/scrubber/osd_scrub.cc +++ b/src/osd/scrubber/osd_scrub.cc @@ -294,47 +294,32 @@ std::optional OsdScrub::LoadTracker::update_load_average() double loadavg; if (getloadavg(&loadavg, 1) == 1) { + loadavg_1min = loadavg; daily_loadavg = (daily_loadavg * (n_samples - 1) + loadavg) / n_samples; return 100 * loadavg; } - return std::nullopt; // getloadavg() failed + // getloadavg() failed + loadavg_1min = 0; + return std::nullopt; } bool OsdScrub::LoadTracker::scrub_load_below_threshold() const { - double loadavgs[3]; - if (getloadavg(loadavgs, 3) != 3) { - dout(10) << "couldn't read loadavgs" << dendl; - return false; - } - // allow scrub if below configured threshold - long cpus = sysconf(_SC_NPROCESSORS_ONLN); - double loadavg_per_cpu = cpus > 0 ? loadavgs[0] / cpus : loadavgs[0]; + 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) { dout(20) << fmt::format( - "loadavg per cpu {:.3f} < max {:.3f} = yes", - loadavg_per_cpu, conf->osd_scrub_load_threshold) - << dendl; - return true; - } - - // allow scrub if below daily avg and currently decreasing - if (loadavgs[0] < daily_loadavg && loadavgs[0] < loadavgs[2]) { - dout(20) << fmt::format( - "loadavg {:.3f} < daily_loadavg {:.3f} and < 15m avg " - "{:.3f} = yes", - loadavgs[0], daily_loadavg, loadavgs[2]) + "loadavg per cpu {:.3f} < max {:.3f} (#CPUs: {}) = yes", + loadavg_per_cpu, conf->osd_scrub_load_threshold, cpus) << dendl; return true; } dout(10) << fmt::format( - "loadavg {:.3f} >= max {:.3f} and ( >= daily_loadavg {:.3f} " - "or >= 15m avg {:.3f} ) = no", - loadavgs[0], conf->osd_scrub_load_threshold, daily_loadavg, - loadavgs[2]) + "loadavg {:.3f} >= max {:.3f} (#CPUs: {}) = no", loadavg_1min, + conf->osd_scrub_load_threshold, cpus) << dendl; return false; } diff --git a/src/osd/scrubber/osd_scrub.h b/src/osd/scrubber/osd_scrub.h index b06798c4bef20..a280679f16b02 100644 --- a/src/osd/scrubber/osd_scrub.h +++ b/src/osd/scrubber/osd_scrub.h @@ -205,6 +205,7 @@ class OsdScrub { const ceph::common::ConfigProxy& conf; const std::string log_prefix; double daily_loadavg{0.0}; + double loadavg_1min{0.0}; public: explicit LoadTracker(