From 103ddb5b3dd250947997ea39b4925c88a97fbc06 Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Tue, 23 Jan 2024 10:50:46 +0100 Subject: [PATCH] cpuload: Fix wrong idle thread load 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. --- src/modules/logger/logger.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index ecb05295d6..f9c3f66800 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -1610,6 +1610,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) {