Skip to content
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

Add port-optimised task selection for ARMv8-M #703

Merged

Conversation

jefftenney
Copy link
Contributor

@jefftenney jefftenney commented Jul 12, 2023

Add port-optimised task selection for ARMv8-M

Description

Add port-optimised task selection for ARMv8-M, patterned after the existing implementation on ARMv7-M. Include a compile-time error for baseline implementations of ARMv8-M like CM23 (without the "main" extension described in the Architecture Reference Manual) attempting to use configPORT_OPTIMISED_TASK_SELECTION. Those CPUs do not support the clz instruction used in the implementation of port-optimised task selection.

During the migration of this feature from ARMv7-M to ARMv8-M, the helper function ucPortCountLeadingZeros() became ulPortCountLeadingZeros() (returning a uint32_t, not a uint8_t) to stop forcing the compiler to generate an unnecessary uxtb instruction to clear out the upper 24 bits of the register. The clz instruction always writes a full 32-bit value to the destination register.

Test Steps

Copy the port files from this PR into a local clone of the full FreeRTOS distribution. Then:

  • Build CM33 demo app (NXP LPC55S69) in IAR with and without configPORT_OPTIMISED_TASK_SELECTION. Verify build is successful. Review generated file task.s for use/non-use of clz in vTaskSwitchContext().
  • Build CM33 demo app (NXP LPC55S69) in GCC with and without configPORT_OPTIMISED_TASK_SELECTION. Verify build is successful.
  • Build CM23 demo app (Nuvoton M2351) with configPORT_OPTIMISED_TASK_SELECTION set to 1 and verify error is generated during compilation.

Copy the port and kernel files from this PR into a local clone of https://github.com/jefftenney/LPTIM-Tick-U5/ (for STM32U585, CM33). Then:

  • Build and run with configPORT_OPTIMISED_TASK_SELECTION set to 1. Use debugger to verify use of clz in disassembly for vTaskSwitchContext().
  • Verify correct operation of application.

Checklist:

[X] I have tested my changes. No regression in existing tests.
[X] I have modified and/or added unit-tests to cover the code changes in this Pull Request. (N/A)

Related Issues

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jefftenney jefftenney requested a review from a team as a code owner July 12, 2023 15:48
@codecov
Copy link

codecov bot commented Jul 14, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.08 🎉

Comparison is base (71662b5) 94.35% compared to head (2d50d8c) 94.43%.

❗ Current head 2d50d8c differs from pull request most recent head d53ec5f. Consider uploading reports for the commit d53ec5f to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #703      +/-   ##
==========================================
+ Coverage   94.35%   94.43%   +0.08%     
==========================================
  Files           6        6              
  Lines        2428     2428              
  Branches      596      596              
==========================================
+ Hits         2291     2293       +2     
+ Misses         87       85       -2     
  Partials       50       50              
Flag Coverage Δ
unittests 94.43% <ø> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jefftenney
Copy link
Contributor Author

Also tested this on https://github.com/FreeRTOS/iot-reference-stm32u5 just now and it works.

@aggarg aggarg merged commit b375458 into FreeRTOS:main Jul 19, 2023
11 checks passed
@jefftenney
Copy link
Contributor Author

@aggarg Great catch on the default setting. Thanks!

@jefftenney jefftenney deleted the ARMv8-M-port-optimised-task-selection branch July 19, 2023 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Port optimized task selection on Cortex M33
4 participants