Skip to content

Conversation

@koffes
Copy link
Contributor

@koffes koffes commented Dec 4, 2025

Using the high CPU load monitoring feature, print a message using printk when the CPU load exceeds a defined threshold.

OCT-3414

@koffes koffes requested a review from a team as a code owner December 4, 2025 15:28
Copilot AI review requested due to automatic review settings December 4, 2025 15:28
@koffes koffes requested a review from a team as a code owner December 4, 2025 15:28
@NordicBuilder NordicBuilder added the doc-required PR must not be merged without tech writer approval. label Dec 4, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds high CPU load monitoring to the nRF5340 Audio application by integrating Zephyr's CPU load subsystem. When CPU usage exceeds 98%, a callback prints a warning message using printk instead of the logging subsystem to ensure the message is displayed even when high-priority threads monopolize CPU time.

  • Added CPU load monitoring with a 98% threshold and callback handler
  • Configured CPU load subsystem with periodic logging every 5 seconds
  • Updated release notes to document the new high CPU load monitoring feature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
applications/nrf5340_audio/src/utils/peripherals.c Implements CPU load callback that prints warning when load exceeds 98%
applications/nrf5340_audio/prj.conf Enables CPU load subsystem and configures periodic logging
doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst Documents the new high CPU load callback feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 4, 2025

CI Information

To view the history of this post, click the 'edited' button above
Build number: 7

Inputs:

Sources:

sdk-nrf: PR head: 94b8a82f372d54ee11a180dd16fa0e76d948d19c

more details

sdk-nrf:

PR head: 94b8a82f372d54ee11a180dd16fa0e76d948d19c
merge base: 82a3ccb278339c89996fd4bc90e4cc6dba6e9649
target head (main): 82a3ccb278339c89996fd4bc90e4cc6dba6e9649
Diff

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (3)
applications
│  ├── nrf5340_audio
│  │  ├── prj.conf
│  │  ├── src
│  │  │  ├── utils
│  │  │  │  │ peripherals.c
doc
│  ├── nrf
│  │  ├── releases_and_maturity
│  │  │  ├── releases
│  │  │  │  │ release-notes-changelog.rst

Outputs:

Toolchain

Version: 43683a87ea
Build docker image: docker-dtr.nordicsemi.no/sw-production/ncs-build:43683a87ea_5ea73affbf

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain - Skipped: existing toolchain is used
  • ✅ Build twister
    • sdk-nrf test count: 12
  • ✅ Integration tests
    • ✅ test-sdk-audio
Disabled integration tests
    • test-fw-nrfconnect-nrf_lrcs_mosh
    • test-fw-nrfconnect-nrf_lrcs_positioning
    • desktop52_verification
    • test_ble_nrf_config
    • test-fw-nrfconnect-apps
    • test-fw-nrfconnect-ble_mesh
    • test-fw-nrfconnect-ble_samples
    • test-fw-nrfconnect-chip
    • test-fw-nrfconnect-fem
    • test-fw-nrfconnect-nfc
    • test-fw-nrfconnect-nrf-iot_cloud
    • test-fw-nrfconnect-nrf-iot_libmodem-nrf
    • test-fw-nrfconnect-nrf-iot_lwm2m
    • test-fw-nrfconnect-nrf-iot_samples
    • test-fw-nrfconnect-nrf-iot_thingy91
    • test-fw-nrfconnect-nrf-iot_zephyr_lwm2m
    • test-fw-nrfconnect-nrf_crypto
    • test-fw-nrfconnect-ps-main
    • test-fw-nrfconnect-rpc
    • test-fw-nrfconnect-rs
    • test-fw-nrfconnect-tfm
    • test-fw-nrfconnect-thread-main
    • test-low-level
    • test-sdk-dfu
    • test-sdk-find-my
    • test-sdk-mcuboot
    • test-sdk-wifi
    • test-secdom-samples-public

Note: This message is automatically posted and updated by the CI

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

You can find the documentation preview for this PR here.

Preview links for modified nRF Connect SDK documents:

https://ncsdoc.z6.web.core.windows.net/PR-26101/nrf/releases_and_maturity/releases/release-notes-changelog.html

Comment on lines 184 to 187
* Added:
* High CPU load callback using the Zephyr CPU load subsystem.
The callback uses a printk, as the logging subsystem will be scheduled out if higher priority threads take all CPU time.
This will make it easier to debug high CPU load situations in the application.
Copy link
Contributor

@peknis peknis Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Added:
* High CPU load callback using the Zephyr CPU load subsystem.
The callback uses a printk, as the logging subsystem will be scheduled out if higher priority threads take all CPU time.
This will make it easier to debug high CPU load situations in the application.
* Added high CPU load callback using the Zephyr CPU load subsystem.
The callback uses a :c:func:`printk` function, as the logging subsystem is scheduled out if higher priority threads take all CPU time.
This makes debugging high CPU load situations easier in the application.

@koffes koffes force-pushed the OCT-3414-activate-high-cpu-load-monitor branch from e71f64e to e7b8f51 Compare December 5, 2025 09:57
@koffes koffes requested review from alexsven and peknis December 5, 2025 09:58
@koffes koffes force-pushed the OCT-3414-activate-high-cpu-load-monitor branch from e7b8f51 to 08fa00d Compare December 5, 2025 10:01
Copilot AI review requested due to automatic review settings December 5, 2025 10:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@peknis peknis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok after fixing the issues pointed out by Copilot.

@koffes koffes force-pushed the OCT-3414-activate-high-cpu-load-monitor branch from 08fa00d to a974eed Compare December 5, 2025 11:26
Copilot AI review requested due to automatic review settings December 11, 2025 12:04
@koffes koffes force-pushed the OCT-3414-activate-high-cpu-load-monitor branch from a974eed to 19df3f7 Compare December 11, 2025 12:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(peripherals, CONFIG_PERIPHERALS_LOG_LEVEL);

static struct board_version board_rev;
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number 98 lacks explanation. Add a comment describing why this specific threshold was chosen (e.g., indicating near-saturation CPU load requiring attention).

Suggested change
static struct board_version board_rev;
static struct board_version board_rev;
/* Threshold for high CPU load (in percent). 98% indicates near-saturation and requires attention. */

Copilot uses AI. Check for mistakes.
@koffes koffes force-pushed the OCT-3414-activate-high-cpu-load-monitor branch from 19df3f7 to e75f5c6 Compare December 12, 2025 09:20
Using the high CPU load monitoring feature, print a message using printk
when the CPU load exceeds a defined threshold.

OCT-3414

Signed-off-by: Kristoffer Skøien <[email protected]>
@koffes koffes force-pushed the OCT-3414-activate-high-cpu-load-monitor branch from e75f5c6 to 94b8a82 Compare December 12, 2025 09:23
Copilot AI review requested due to automatic review settings December 12, 2025 09:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Disable LOG_PRINTK to ensure printk messages are displayed even under high CPU load,
# by preventing them from being processed by the logging subsystem.
CONFIG_LOG_PRINTK=n
CONFIG_CPU_LOAD_LOG_PERIODICALLY=5000
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on line 83 mentions 'Log high CPU load using printk', but CONFIG_CPU_LOAD_LOG_PERIODICALLY controls periodic CPU load logging through the logging subsystem, not the high CPU load callback. Consider adding a comment explaining that this enables periodic CPU load statistics logging every 5000ms, separate from the high load threshold callback.

Copilot uses AI. Check for mistakes.
Comment on lines 21 to +25
LOG_MODULE_REGISTER(peripherals, CONFIG_PERIPHERALS_LOG_LEVEL);

static struct board_version board_rev;
#define CPU_LOAD_HIGH_THRESHOLD_PERCENT 98

Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making CPU_LOAD_HIGH_THRESHOLD_PERCENT configurable via Kconfig instead of hardcoding it. This would allow different threshold values for different builds without modifying source code, improving maintainability and flexibility.

Suggested change
LOG_MODULE_REGISTER(peripherals, CONFIG_PERIPHERALS_LOG_LEVEL);
static struct board_version board_rev;
#define CPU_LOAD_HIGH_THRESHOLD_PERCENT 98
#include <zephyr/kernel.h>
LOG_MODULE_REGISTER(peripherals, CONFIG_PERIPHERALS_LOG_LEVEL);
static struct board_version board_rev;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-required PR must not be merged without tech writer approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants