-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Rehabilitate _current
usage
#83674
Rehabilitate _current
usage
#83674
Conversation
Totally slipped out of my mind, thanks for this PR |
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.
Tentative +1, with the caveat that I'm going to refuse to engage in any resulting arguments. Not a fan of treewide "naming things" changes in general, especially not of treewide naming things reversions. But I do agree that _current is and was always a cleaner name for the concept (though IIRC I gave a +1 to the rename too...)
Mostly a revert of commit b1def71 ("arch: deprecate `_current`"). This commit was part of PR zephyrproject-rtos#80716 whose initial purpose was about providing an architecture specific optimization for _current. The actual deprecation was sneaked in later on without proper discussion. The Zephyr core always used _current before and that was fine. It is quite prevalent as well and the alternative is proving rather verbose. Furthermore, as a concept, the "current thread" is not something that is necessarily architecture specific. Therefore the primary abstraction should not carry the arch_ prefix. Hence this revert. Signed-off-by: Nicolas Pitre <[email protected]>
Define the generic _current directly and get rid of the generic arch_current_get(). The SMP default implementation is now known as z_smp_current_get(). It is no longer inlined which saves significant binary size (about 10% for some random test case I checked). Introduce z_current_thread_set() and use it in place of arch_current_thread_set() for updating the current thread pointer given this is not necessarily an architecture specific operation. The architecture specific optimization, when enabled, should only care about its own things and not have to also update the generic _current_cpu->current copy. Signed-off-by: Nicolas Pitre <[email protected]>
Repeated references to _current won't produce a different result as the executing thread instance is always the same. Use the const attribute to let the compiler know it may reuse a previously obtained value. This offset the penalty for moving z_smp_current_get() out of line and provides yet more binary size reduction. This change is isolated in its own commit to ease bisecting in case some unexpected misbehavior is eventually observed. Signed-off-by: Nicolas Pitre <[email protected]>
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.
Refresh +1, the need for a const attribute is a great catch.
@andyross wrote:
Refresh +1
Forgot to push the "approve" button?
|
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.
yep, i found out I did not like the arch_current_thread() call soon after this was merged and was planning to come back and address this, thanks.
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.
click the button correctly
This is the revert of the (unwarranted IMHO)
_current
deprecation asI suggested in PR #80716. Additional cleanups are also included.