-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/cortexm_common: add inlined header only def for irq_% #13999
Conversation
This is something I have wanted to see for a long time :-) It is good to do this one arch at a time. I would also like to see the return value to be lets call it Every platform I am aware of guarantees to disable and restore IRQs in one CPU cycle. As at most a word can be read/written in a cycle, this gives us the word as upper limit for the IRQ state. The AVR platform would greatly profit if it would be both (But changing the return type is something that deserves its own PR. Especially as a lot of callers have to be updated.) |
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.
Looks good codewise. I have one suggestion inline. (And maybe you could also sneak in a bugfix? See inline.)
Rebased. |
c9f0db7
to
f3dfb74
Compare
Will trigger murdock once to see If I missed an arch. |
Code looks good to me. I think you can squash. (Also: The missing |
95201ba
to
7a94b18
Compare
Squashed. I triggered tests as well for good measure. |
Missed a |
7a94b18
to
3ea0b4f
Compare
I wouldn't mind a second review/ACK here, as this PR has a high impact. |
Yep I agree! |
@kaspar030 or @bergzand might be able to take a look at this one as well? |
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.
Some late comments.
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.
My ACK is still valid
irq_% are not inlined by the compiler which leads to it branching to a function that actually implement a single machine instruction. Inlining these functions makes the call more efficient as well as saving some bytes in ROM.
__set_PRIMASK(state) had been directly inlined to avoid a hardfault that occured when branching after waking up from sleep with DBG_STANDBY, DBG_STOP or DBG_SLEEP set in DBG_CR. The hardfault occured when returning from the branch to irq_restore, since the function is now inlined the branch does not happen either. Refer to RIOT-OS#14015 for more details.
1bec2be
to
b5e4224
Compare
Build failed because there was no space left on worker https://ci.riot-os.org/RIOT-OS/RIOT/13999/b5e4224a6fe2de4aca35d90af5e76d5b6a5bf519/output/compile/tests/mtd_mapper/stk3600:gnu.txt |
All green again @kaspar030 ! |
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.
ACK.
Thanks for the review @kaspar030 @maribu! |
Thanks for the PR. This is huge improvement (at least without LTO) :-) |
Contribution description
irq_% are not inlined by the compiler which leads to it branching
to a function that actually implement a single machine instruction.
Inlining these functions makes the call more efficient as well as
saving some bytes in ROM.
This could probably be done for more arch, but I wanted to first do
it for a single arch first.
Testing procedure
All applications should still work
check footprint difference,
BUILD_IN_DOCKER=1 BOARD=<board>make -C examples/gnrc_networking
iotlab-m3 cortexm3:
samr21-xpro cortexm0:
nrf52dk cortexm4:
Issues/PRs references
Came up a while ago in #11919