-
Notifications
You must be signed in to change notification settings - Fork 349
[RFC] core: assure alignment is only done on power of 2 values #3671
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
|
Are the failures related to the PR or is the CI crazy? |
|
@paulstelian97 CI looks wrong - this could be due to maintenance so I will rerun. |
|
SOFCI TEST |
|
@lyakh I've merged some PRs so henec the conflicts - best to rebase and check on your return. |
7ae9f3f to
8996147
Compare
lgirdwood
left a comment
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.
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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments on why GCC and XCC are different here.
src/include/sof/common.h
Outdated
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.
why is this different for XCC, need to state this delta in the 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.
@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
201c479
Compare
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. 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>
|
@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 |
|
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
|
|
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.