Uh oh!
There was an error while loading. Please reload this page.
[RFC] core: assure alignment is only done on power of 2 values - #3671
Conversation
paulstelian97
commented
Dec 7, 2020
Are the failures related to the PR or is the CI crazy? |
lgirdwood
commented
Dec 7, 2020
@paulstelian97 CI looks wrong - this could be due to maintenance so I will rerun. |
lgirdwood
commented
Dec 7, 2020
SOFCI TEST |
lgirdwood
commented
Dec 15, 2020
@lyakh I've merged some PRs so henec the conflicts - best to rebase and check on your return. |
7ae9f3f to
8996147Compare
lgirdwood
left a comment
There was a problem hiding this comment.
Can you put more context in the commit message telling us what this is fixing today. i.e. where are non powers of two being used today.
lyakh
commented
Jan 4, 2021
@lgirdwood that's exactly the purpose of this PR - to identify any such occurrences. So far I'm not aware of any but since until now SOF alignment supported non power of 2 values, I propose to put compilation guards for any such calls. So far I'm not aware of any. I'll extend the commit message. |
lgirdwood
left a comment
There was a problem hiding this comment.
More comments on why GCC and XCC are different here.
There was a problem hiding this comment.
why is this different for XCC, need to state this delta in the comments.
There was a problem hiding this comment.
@lgirdwood comment added, conflict resolved. However I don't like all qemu targets failing (at least before). Let's wait for the new test to finish and if failures are still there, who can help get some debugging information from those failures?
74fa586 to
201c479CompareAlignment should always be done on powers of 2. Enforcing this rule also allows the use of binary AND for alignment instead of much slower division. Also add compile-time checks where possible. At the moment no non-power-of-2 alignment cases are known in SOF, but a complete verification is difficult, therefore we add compile- and runtime checks, enabled by default for now. After a period of time (one or two releases) this verification option can be converted to an off by default configuration parameter. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
lgirdwood
commented
Jan 8, 2021
@lyakh all passing now. |
The use of GCC statement-expressions in ALIGN means these macros cannot be used to initialize statics anymore. This broke See quick and dirty compilation fix with more details in marc-hb@unalign-sue |
marc-hb
commented
Jan 14, 2021
Would C11 Is C11 too high of a requirement? |
Simpler yes, as flexible as before: no. Naive question: why not just change the "ALIGN API" to have a 2-exponent argument instead? I mean like this: -#define ALIGN_UP_INTERNAL(val, align) (((val) + ( align) - 1) & ~(( align) - 1))+#define ALIGN_UP2_INTERNAL(val, align) (((val) + (1 << align) - 1) & ~((1 << align) - 1))Since you performed a rename and search/replace anyway. No need for any assert anymore, this is correct by construction. Just for fun PS, in 2007: https://lkml.org/lkml/2007/1/10/165
|
marc-hb
commented
Jan 15, 2021
I found the ALIGN_UP_COMPILE macro without any non standard GCC statement-expression and meant for static initializers. However memory.h files are also included in assembly and in linker files, so it was not enough. Tentative fix in |
Alignment should always be done on powers of 2. Enforcing this rule also allows the use of binary AND for alignment instead of much slower division. Also add compile-time checks where possible.