-
Notifications
You must be signed in to change notification settings - Fork 3k
critical sections: remove unnecessary volatile #9231
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
Conversation
Critical section count/state variables are synchronised by IRQ disabling and critical section calls themselves, so do not need to be volatile. This eliminates a couple of unnecessary reads of the counter variable.
@kjbracey-arm, thank you for your changes. |
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.
Good change, it would be interesting to have a mention about volatile uses in the handbook at some point.
Funnily enough that change doesn't change code generated: https://godbolt.org/z/za4blY
The other file is just being done for consistency, and doesn't gain anything because it accesses each variable only once per function. I'm looking through a few other bits of code - getting paranoid about LTO. |
It would be interesting to add the |
My latest bit of paranoia is implementations of (Without LTO, function calls to other compilation units are compiler barriers, which does a lot of lifting. LTO loses that). |
Immediate answer from an old GCC manual:
|
@kjbracey-arm https://bugs.launchpad.net/gcc-arm-embedded/+bug/1722849?comments=all and https://gcc.gnu.org/ml/gcc-help/2017-10/msg00061.html might worth the read. |
Interesting link. Raised a CMSIS issue here about |
CI started |
Test run: FAILEDSummary: 1 of 7 test jobs failed Failed test jobs:
|
We are experiencing CI node failures, few jobs were aborted. We are investigating, will restart the jobs once fixed. cc @ARMmbed/mbed-os-test |
re-running to check if CI issue is resolved |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Description
Critical section count/state variables are synchronised by IRQ disabling and
critical section calls themselves, so do not need to be volatile.
This eliminates a couple of unnecessary reads of the counter variable.
Saves a few bytes of ROM, and a bit of time in speed-critical code.
Pull request type
Reviewers
@scartmell-arm, @c1728p9