Skip to content

Commit

Permalink
cpuload: Fix wrong idle thread load
Browse files Browse the repository at this point in the history
When the CPU load monitor is started while already running, then the
idle thread last_times[0] is reset to the last 1 second, rather than
since when the CPU load monitor was last started. The remaining threads
are not impacted, since their last_times[i] is reset to zero here.

This results in the idle thread having a lower than real CPU load, with
the remaining CPU time being wrongly attributed as scheduler load.
  • Loading branch information
niklaut authored and jlaitine committed Feb 23, 2024
1 parent 415da09 commit 7ff693f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/modules/logger/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,11 @@ void Logger::print_load_callback(void *user)

void Logger::initialize_load_output(PrintLoadReason reason)
{
// If already in progress, don't try to start again
if (_next_load_print != 0) {
return;
}

init_print_load(&_load);

if (reason == PrintLoadReason::Watchdog) {
Expand Down

0 comments on commit 7ff693f

Please sign in to comment.