-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subsys: debug: Added full CPU utilization monitor #87658
base: main
Are you sure you want to change the base?
Conversation
koffes
commented
Mar 25, 2025
- Added a module and tests to detect full CPU load
00b1aa1
to
861689e
Compare
This PR resolves #71945. We may need to discuss a bit when it comes to multicore architectures. |
you need to rebase |
I wonder if it would not be lighter and simpler to reuse already existing periodic cpu load logging functionality. Move it to k_timer instead of k_work and add option to report load only if load is above given configurable threshold. When threshold is set then it would report it as LOG_WRN (or printk if logging is disabled). Using current approach requires enabling thread stats which increases code size and that may be an issue for smaller cores (e.g. flpr). |
PR has been rebased. |
@koffes callback might be added as well there and printk can be used instead of LOG_WRN when logging is disabled. Note that when logging is enabled then printk by default goes through logging so it is also not guaranteed to be printed. |
c5bb9da
to
84c052e
Compare
@nordic-krch : re-written based on your comment. Have not changed the printing, as the user can do this in the callback. |
- Added a CPU load callback with threshold - Changed cpu_load to use k_timer instead of k_work Signed-off-by: Kristoffer Rist Skøien <kristoffer.skoien@nordicsemi.no>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok. I've opened #88222 so it will be possible to enable periodic logging but set cpu_load log level below INF and use periodic callback only for tracking if threshold is exceeded.
void high_load_cb(uint8_t percent) | ||
{ | ||
last_cpu_load_percent = percent; | ||
TC_PRINT("percendt %u", percent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TC_PRINT("percendt %u", percent); | |
TC_PRINT("percent %u", percent); |
* | ||
* @retval 0 - Callback registered/cancelled. | ||
* @retval -EINVAL if the threshold is invalid. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant line
/** @brief Optional registration of callback when load is greater or equal to the threshold. | ||
* | ||
* Submitting NULL pointer will cancel the callback. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add parameter description?
@@ -48,6 +49,23 @@ int cpu_load_get(bool reset); | |||
*/ | |||
void cpu_load_log_control(bool enable); | |||
|
|||
/* Optional callback for cpu_load_cb_reg | |||
* | |||
* This will be called from the k_timer expiry_fn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* This will be called from the k_timer expiry_fn. | |
* This will be called from the k_timer expiry_fn used for periodic logging. CONFIG_CPU_LOAD_LOG_PERIODICALLY must be configured to a positive value. |