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

Pass core ID to port lock macros #1212

Merged
merged 7 commits into from
Dec 30, 2024

Conversation

felixvanoost
Copy link
Contributor

@felixvanoost felixvanoost commented Dec 21, 2024

Description

Passes the core ID as an argument to the SMP lock macros port{GET/RELEASE}_{TASK/ISR}_LOCK in tasks.c. Since #1206, the functions calling these macros keep track of the core ID, so the port-specific spinlock function implementations can eliminate their internal calls to portGET_CORE_ID() to reduce the number of unnecessary, and generally slow, accesses to a peripheral register. This benefits the following FreeRTOS functions:

Function # of eliminated calls to portGET_CORE_ID()
prvCheckForRunStateChange() 5
vTaskSwitchContext() 4
vTaskEnterCritical() 2
vTaskEnterCriticalFromISR() 1
vTaskExitCritical() 2
vTaskExitCriticalFromISR() 1

I've updated the spinlock definitions for two of the three SMP-compatible ports (F1Kx and RP2040). The XCOREAI port spinlocks are implemented elsewhere in their toolchain so I've just cast the new argument to void.

Test Steps

Timing analysis coming shortly.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

Closes #1204

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

@felixvanoost felixvanoost requested a review from a team as a code owner December 21, 2024 17:38
@jasonpcarroll
Copy link
Member

jasonpcarroll commented Dec 24, 2024

Hi @felixvanoost - sorry for the late response. This looks great! I am going to ping someone with a bit more familiarity with SMP implementation to also take a look. The unit tests will need to be updated, but to save your time, I would wait on the other reviewer before updating them.

Best,

Jason Carroll

Copy link
Member

@chinglee-iot chinglee-iot left a comment

Choose a reason for hiding this comment

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

I have verified this change with the unit test PR, and it works without issues. The PR can be found at FreeRTOS/FreeRTOS#1319.

Please note that this change is not backward compatible. Since all TASK and ISR spinlock port macros need to be implemented recursively, it makes sense to add the xCoreID parameter to these macros.

We should proceed to update the following ports for the port macros change:

portable/ThirdParty/Community-Supported-Ports/GCC/CORTEX_A53_64-bit_UltraScale_MPSoC/portmacro.h
portable/ThirdParty/Community-Supported-Ports/GCC/RP2350_ARM_NTZ/non_secure/portmacro.h
portable/ThirdParty/Community-Supported-Ports/GCC/RP2350_RISC-V/include/portmacro.h
portable/ThirdParty/Partner-Supported-Ports/TI/CORTEX_A53_64-BIT_TI_AM64_SMP/portmacro.h

portable/ThirdParty/xClang/XCOREAI/portmacro.h Outdated Show resolved Hide resolved
chinglee-iot
chinglee-iot previously approved these changes Dec 25, 2024
@felixvanoost
Copy link
Contributor Author

I have verified this change with the unit test PR, and it works without issues. The PR can be found at FreeRTOS/FreeRTOS#1319.

Please note that this change is not backward compatible. Since all TASK and ISR spinlock port macros need to be implemented recursively, it makes sense to add the xCoreID parameter to these macros.

We should proceed to update the following ports for the port macros change:

portable/ThirdParty/Community-Supported-Ports/GCC/CORTEX_A53_64-bit_UltraScale_MPSoC/portmacro.h
portable/ThirdParty/Community-Supported-Ports/GCC/RP2350_ARM_NTZ/non_secure/portmacro.h
portable/ThirdParty/Community-Supported-Ports/GCC/RP2350_RISC-V/include/portmacro.h
portable/ThirdParty/Partner-Supported-Ports/TI/CORTEX_A53_64-BIT_TI_AM64_SMP/portmacro.h

@chinglee-iot I've created PRs in both repos with the corresponding changes. :)

Copy link
Member

@jasonpcarroll jasonpcarroll left a comment

Choose a reason for hiding this comment

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

Sorry could you fix the CMock unit tests?

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
aggarg pushed a commit to FreeRTOS/FreeRTOS that referenced this pull request Dec 30, 2024
@aggarg
Copy link
Member

aggarg commented Dec 30, 2024

Sorry could you fix the CMock unit tests?

@chinglee-iot addressed unit tests in this PR - FreeRTOS/FreeRTOS#1319.

@aggarg aggarg requested a review from jasonpcarroll December 30, 2024 08:03
@aggarg aggarg dismissed jasonpcarroll’s stale review December 30, 2024 08:58

Requested changes has been done.

@aggarg aggarg merged commit f05244a into FreeRTOS:main Dec 30, 2024
17 checks passed
@aggarg
Copy link
Member

aggarg commented Dec 30, 2024

@felixvanoost Thank you for your contribution!

@felixvanoost felixvanoost deleted the pass-core-id-to-port-lock-macros branch December 30, 2024 11:31
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] Pass core ID to SMP port lock functions
5 participants