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
Revert "sys/pm_layered: pm_(un)block add attribute optimize(3)" #19155
Conversation
…ens hotpath" This reverts commit 5447203.
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.
@kfessel what difference doesn -O3
even make here?
I can't think of that many different ways to optimize this.
I would assume most optimizations came from the proper alignment?
|
bors merge |
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
Already running a review |
18477: gnrc_static: add static network configuration r=miri64 a=benpicco 19155: Revert "sys/pm_layered: pm_(un)block add attribute optimize(3)" r=benpicco a=Teufelchen1 Revert "sys/pm_layered: pm_(un)block add attribute optimize(3) -shortens hotpath" This reverts commit 5447203. ### Contribution description Compiling `examples/gnrc_networking_mac` using `TOOLCHAIN=llvm` yields the following error: ``` RIOT/sys/pm_layered/pm.c:77:16: error: unknown attribute 'optimize' ignored [-Werror,-Wunknown-attributes] __attribute__((optimize(3))) ``` As indicated, this is because the attribute `optimize` is GCC only and not present in LLVM. Compare the manpages of [GCC](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html) and [LLVM](https://clang.llvm.org/docs/AttributeReference.html). ### Testing procedure Since this should only affect performance and not behavior, no special testing is needed. I am not aware of any tests in RIOT which could verify that assumption. ### Issues/PRs references Introduced in #18846 There is another instance of this attribute being used in[ shell_lock.c](https://github.com/RIOT-OS/RIOT/blob/6fb340d654ac8da07759cb9199c6aaa478589aa7/sys/shell_lock/shell_lock.c#L80). Since the usage is security related, I omit it from this PR. Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com> Co-authored-by: Teufelchen1 <bennet.blischke@haw-hamburg.de>
bors cancel (This should allow another PR to hop onto the merge train 🚂 🚋 🚋 🚋) |
Canceled. |
Already running a review |
18477: gnrc_static: add static network configuration r=miri64 a=benpicco 19155: Revert "sys/pm_layered: pm_(un)block add attribute optimize(3)" r=maribu a=Teufelchen1 Revert "sys/pm_layered: pm_(un)block add attribute optimize(3) -shortens hotpath" This reverts commit 5447203. ### Contribution description Compiling `examples/gnrc_networking_mac` using `TOOLCHAIN=llvm` yields the following error: ``` RIOT/sys/pm_layered/pm.c:77:16: error: unknown attribute 'optimize' ignored [-Werror,-Wunknown-attributes] __attribute__((optimize(3))) ``` As indicated, this is because the attribute `optimize` is GCC only and not present in LLVM. Compare the manpages of [GCC](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html) and [LLVM](https://clang.llvm.org/docs/AttributeReference.html). ### Testing procedure Since this should only affect performance and not behavior, no special testing is needed. I am not aware of any tests in RIOT which could verify that assumption. ### Issues/PRs references Introduced in #18846 There is another instance of this attribute being used in[ shell_lock.c](https://github.com/RIOT-OS/RIOT/blob/6fb340d654ac8da07759cb9199c6aaa478589aa7/sys/shell_lock/shell_lock.c#L80). Since the usage is security related, I omit it from this PR. Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com> Co-authored-by: Teufelchen1 <bennet.blischke@haw-hamburg.de>
One last try to pack the train: bors cancel |
Canceled. |
bors merge |
Already running a review |
the attribute shortens the hotpath by reordering instructions preferring the common case of not failing the assertion -> less jumps -> less loss of pipeline btw this is not an error but an elevated warning |
Uh sounds like we need #define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0) like Linux, then
|
we could use |
another fix would be not to warn for unknown attributes in clang |
Maybe we should just add Otherwise this likely will be a whack-a-mole game, as we only compile-test with GCC. |
Build succeeded: |
19157: sys/shell_lock: do not call strlen, less jumpy r=kaspar030 a=kfessel ### Contribution description the current `_safe_strcmp` depends on not being optimized and not being inlined (implicitly given by the -O0), this new one does less (would say not since even O3 had compile results that should not return early or show different runtimes for different secrets). the runtime of strlen depend on the length of the string (password) therefor it is removed. `ifs` are very jumpy and depend on the contend of password, this avoids `ifs` sadly clang still compiles some boolean statements to if. with this PR the `__attribute__((optimize("O0")))` should be removable. ### Testing procedure see https://godbolt.org/z/x35b85cEx and run the `<RIOT>/tests/shell_lock` ### Issues/PRs references #19155 made me aware of this function Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
19157: sys/shell_lock: do not call strlen, less jumpy r=benpicco a=kfessel ### Contribution description the current `_safe_strcmp` depends on not being optimized and not being inlined (implicitly given by the -O0), this new one does less (would say not since even O3 had compile results that should not return early or show different runtimes for different secrets). the runtime of strlen depend on the length of the string (password) therefor it is removed. `ifs` are very jumpy and depend on the contend of password, this avoids `ifs` sadly clang still compiles some boolean statements to if. with this PR the `__attribute__((optimize("O0")))` should be removable. ### Testing procedure see https://godbolt.org/z/x35b85cEx and run the `<RIOT>/tests/shell_lock` ### Issues/PRs references #19155 made me aware of this function Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
Revert "sys/pm_layered: pm_(un)block add attribute optimize(3) -shortens hotpath"
This reverts commit 5447203.
Contribution description
Compiling
examples/gnrc_networking_mac
usingTOOLCHAIN=llvm
yields the following error:As indicated, this is because the attribute
optimize
is GCC only and not present in LLVM.Compare the manpages of GCC and LLVM.
Testing procedure
Since this should only affect performance and not behavior, no special testing is needed. I am not aware of any tests in RIOT which could verify that assumption.
Issues/PRs references
Introduced in #18846
There is another instance of this attribute being used in shell_lock.c. Since the usage is security related, I omit it from this PR.