Skip to content

pm: Use fixed cpu id in single core case #88144

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

Merged
merged 3 commits into from
Apr 8, 2025

Conversation

nordic-krch
Copy link
Collaborator

@nordic-krch nordic-krch commented Apr 4, 2025

When there are no multiple cores than fixing id to 0 saves few cycles.

Do not call ticks_expiring_sooner if not needed.

This small improvement saves few cycles but surprisingly significantly reduces pm.c code size 416 to 316 bytes in the sample that I've checked.

JordanYates
JordanYates previously approved these changes Apr 4, 2025
@JordanYates
Copy link
Collaborator

Could ROM savings be obtained across other users in the codebase?

#if CONFIG_MP_MAX_NUM_CPUS == 1
#define CPU_ID 0
#else
#define CPU_ID _current_cpu->id
#endif

@nordic-krch
Copy link
Collaborator Author

Added CPU_ID in kernel_structs.h and used it in pm related code. I've briefly looked at generic code and found that in kernel/timeslicing.c there can be some small savings. There are places in arch where _current_cpu->id is used but i did not look into that.
I can post timeslicing PR once this one is merged to keep this PR focused on PM.

In case of a single core it resolves to 0. In many cases it reduces
code size and execution time compared to reading id in runtime.

Signed-off-by: Krzysztof Chruściński <[email protected]>
When there are no multiple cores than fixing id to 0 saves few
cycles.

Signed-off-by: Krzysztof Chruściński <[email protected]>
@github-actions github-actions bot added the platform: ESP32 Espressif ESP32 label Apr 7, 2025
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

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

Nice!

Driver is using local macro to get current CPU ID and it is now
in conflict with generic CPU_ID. Added prefix to avoid conflict.

Signed-off-by: Krzysztof Chruściński <[email protected]>
@kartben kartben merged commit e33606f into zephyrproject-rtos:main Apr 8, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants