Skip to content

Commit cf85a00

Browse files
committed
osd/scrub: minimize calls to sysconf() in scrub_load_below_threshold()
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 <[email protected]> (cherry picked from commit 3392bc0)
1 parent 257e529 commit cf85a00

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/osd/scrubber/osd_scrub.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,18 @@ std::optional<double> OsdScrub::LoadTracker::update_load_average()
306306

307307
bool OsdScrub::LoadTracker::scrub_load_below_threshold() const
308308
{
309-
// allow scrub if below configured threshold
309+
// if the 1-min load average - even before dividing by the number of CPUs -
310+
// is below the configured threshold, scrubs are allowed. No need to call
311+
// sysconf().
312+
if (loadavg_1min < conf->osd_scrub_load_threshold) {
313+
dout(20) << fmt::format(
314+
"loadavg {:.3f} < max {:.3f} = yes",
315+
loadavg_1min, conf->osd_scrub_load_threshold)
316+
<< dendl;
317+
return true;
318+
}
319+
320+
// check the load per CPU
310321
const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
311322
const double loadavg_per_cpu = cpus > 0 ? loadavg_1min / cpus : loadavg_1min;
312323
if (loadavg_per_cpu < conf->osd_scrub_load_threshold) {

0 commit comments

Comments
 (0)