Skip to content

Commit c68c2a5

Browse files
committed
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 <[email protected]> (cherry picked from commit 948e042)
1 parent 7d48f5a commit c68c2a5

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

src/osd/OSD.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6274,12 +6274,9 @@ void OSD::heartbeat_check()
62746274
void OSD::heartbeat()
62756275
{
62766276
ceph_assert(ceph_mutex_is_locked_by_me(heartbeat_lock));
6277-
dout(30) << "heartbeat" << dendl;
6278-
6279-
auto load_for_logger = service.get_scrub_services().update_load_average();
6280-
if (load_for_logger) {
6281-
logger->set(l_osd_loadavg, load_for_logger.value());
6282-
}
6277+
logger->set(
6278+
l_osd_loadavg,
6279+
100.0 * service.get_scrub_services().update_load_average().value_or(0.0));
62836280
dout(30) << "heartbeat checking stats" << dendl;
62846281

62856282
// refresh peer list and osd stats

src/osd/scrubber/osd_scrub.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ std::optional<double> OsdScrub::update_load_average()
275275
if (getloadavg(&loadavg, 1) != 1) {
276276
return std::nullopt;
277277
}
278-
return 100 * loadavg;
278+
return loadavg;
279279
}
280280

281281

@@ -299,7 +299,7 @@ bool OsdScrub::scrub_load_below_threshold() const
299299
return true;
300300
}
301301

302-
dout(10) << fmt::format(
302+
dout(5) << fmt::format(
303303
"loadavg {:.3f} >= max {:.3f} (#CPUs:{}) = no",
304304
loadavg_per_cpu, conf->osd_scrub_load_threshold,
305305
loadavg_cpu_count)

src/osd/scrubber/osd_scrub.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ class OsdScrub {
118118
[[nodiscard]] bool scrub_time_permit(utime_t t) const;
119119

120120
/**
121-
* An external interface into the LoadTracker object. Used by
122-
* the OSD tick to update the load data in the logger.
121+
* Fetch the 1-minute load average. Used by
122+
* the OSD heartbeat handler to update a performance counter.
123+
* Also updates the number of CPUs, required internally by the
124+
* scrub queue.
123125
*
124-
* \returns 100*(the decaying (running) average of the CPU load
125-
* over the last 24 hours) or nullopt if the load is not
126-
* available.
127-
* Note that the multiplication by 100 is required by the logger interface
126+
* \returns the 1-minute element of getloadavg() or nullopt
127+
* if the load is not available.
128128
*/
129129
std::optional<double> update_load_average();
130130

0 commit comments

Comments
 (0)