Skip to content

memory: added requesting alignment for buffer heap - #1698

Merged
jajanusz merged 3 commits into
thesofproject:masterfrom
dabekjakub:alignment_debug
Oct 11, 2019
Merged

jajanusz merged 3 commits into
thesofproject:masterfrom
dabekjakub:alignment_debug

Conversation

@dabekjakub

Copy link
Copy Markdown
Member

Added buffer alignment API.
Needed to set alignment that different buffers require.
Example: Dma buffer has to be aligned to 128 due to hardware
configuration.

Signed-off-by: Jakub Dabek jakub.dabek@intel.com

@jajanusz

jajanusz commented Aug 2, 2019

Copy link
Copy Markdown
Contributor

ACK

@dabekjakub
dabekjakub force-pushed the alignment_debug branch 3 times, most recently from aa773aa to d6ef0f6 Compare August 2, 2019 15:44
@dabekjakub
dabekjakub requested a review from tlauda August 2, 2019 15:50

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not force all malloc() callers to request an alignment (as most dont care). So we should have

void *malloc(size);
void *malloc_align(size, alignment);

where malloc() internally just calls malloc_align(size, 0)

@dabekjakub
dabekjakub marked this pull request as ready for review August 8, 2019 11:09
@dabekjakub

dabekjakub commented Aug 8, 2019 •

Copy link
Copy Markdown
Member Author

@lgirdwood With @tlauda we asumed that aligning every allocation to casheline will improve overall performance.

@jajanusz jajanusz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change order of commits to not break git bisect for host.

@dbaluta

dbaluta commented Aug 8, 2019 •

Copy link
Copy Markdown
Collaborator

@dabekjakub Please use imperative mood in the commit subject line https://chris.beams.io/posts/git-commit/#imperative

e.g host: fixed memory function definitions -> host: Fix memory function definitions

Also, commit message:

Fixed alloc definitions for host so it does not relay on define being const free.

What does this even mean? Please try to make your commit messages more clear. People should get a feel of your change by reading the commit message.

@dabekjakub
dabekjakub force-pushed the alignment_debug branch 4 times, most recently from 97f8e24 to 1a92c35 Compare August 8, 2019 13:45
@dbaluta

dbaluta commented Aug 8, 2019

Copy link
Copy Markdown
Collaborator

@dabekjakub there is still one commit subject that needs to be fixed. Please be consistent :)

@jajanusz
jajanusz requested a review from lgirdwood August 9, 2019 08:33
@jajanusz

jajanusz commented Aug 9, 2019

Copy link
Copy Markdown
Contributor

SOFCI TEST

@tlauda tlauda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add additional commit to this PR, where you are adding alignment also to rmalloc_sys and by default calling it with PLATFORM_DCACHE_ALIGN? Implementation itself is already in place, so it's just a minor tweak.

Comment thread src/include/sof/lib/alloc.h Resolved
Comment thread src/lib/alloc.c Resolved
Comment thread src/lib/alloc.c Resolved
Comment thread src/lib/alloc.c Resolved
Comment thread src/lib/alloc.c Resolved
Comment thread src/lib/alloc.c Resolved
@dabekjakub

Copy link
Copy Markdown
Member Author

@tlauda changes implemented , as far as i can see rmalloc_sys has selalign in it already

/* align address to dcache line size */
if (cpu_heap->info.used % PLATFORM_DCACHE_ALIGN)
	alignment = PLATFORM_DCACHE_ALIGN -
		(cpu_heap->info.used % PLATFORM_DCACHE_ALIGN);

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use the ISA macro, #1826 has the ISA fix (pending on CI updates) - I will merge it later today since CI qemu updates have been merged.

@tlauda

tlauda commented Sep 30, 2019

Copy link
Copy Markdown
Contributor

We need to use the ISA macro, #1826 has the ISA fix (pending on CI updates) - I will merge it later today since CI qemu updates have been merged.

We need to use the ISA macro, but also have our own additional macro for cache enablement. I think that right now the cache is only enabled on cAVS platforms, so there is no point in aligning to cache line in this case.

@lgirdwood

Copy link
Copy Markdown
Member

We need to use the ISA macro, #1826 has the ISA fix (pending on CI updates) - I will merge it later today since CI qemu updates have been merged.

We need to use the ISA macro, but also have our own additional macro for cache enablement. I think that right now the cache is only enabled on cAVS platforms, so there is no point in aligning to cache line in this case.

Sorry, not following, do you mean there is no point aliging to cache line size on CAVS platforms ?

@tlauda

tlauda commented Sep 30, 2019

Copy link
Copy Markdown
Contributor

We need to use the ISA macro, #1826 has the ISA fix (pending on CI updates) - I will merge it later today since CI qemu updates have been merged.

We need to use the ISA macro, but also have our own additional macro for cache enablement. I think that right now the cache is only enabled on cAVS platforms, so there is no point in aligning to cache line in this case.

Sorry, not following, do you mean there is no point aliging to cache line size on CAVS platforms ?

I'm saying there is no point aligning to cache line on non-cAVS platforms.

@lgirdwood

lgirdwood commented Sep 30, 2019 •

Copy link
Copy Markdown
Member

@tlauda ok, but I'm hesistant here to just use an alignment that does not align with core-isa (even though cache is not implemented). I'm suspiscious that the cache line size value is defined as non zero and that may also be used by compiler for optimised text/data alignment, prefeching or some other undocumented hint used by the compiler to generate optimised code.

@dabekjakub
dabekjakub force-pushed the alignment_debug branch 3 times, most recently from fd84fef to eb583e1 Compare October 10, 2019 09:26
Adjust memory sizes for heaps to provide
enough memory for alignment in buffer heap.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
Fix alloc definitions for host build.
Function definitions were using defines in their body
which blocked usage of const values in said defines.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
@dabekjakub

Copy link
Copy Markdown
Member Author

SOFCI TEST

@dabekjakub

Copy link
Copy Markdown
Member Author

@tlauda @lgirdwood it looks good to me now - bugs fixed

Add alignment option for memory requests.
Fix alloc definitions for UT.
Function definitions were using defines in their body
which blocked usage of const values in said defines.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
@jajanusz
jajanusz dismissed lgirdwood’s stale review October 11, 2019 12:24

Stale review, PR uses correct alignment option

@jajanusz

Copy link
Copy Markdown
Contributor

Checkpatch errors are related to code that was already there and are not effect of this PR

@jajanusz
jajanusz merged commit 66b0a0f into thesofproject:master Oct 11, 2019
@paulstelian97

Copy link
Copy Markdown
Collaborator

Any reason why rebasing on top of the last commit breaks my platform on playback? I'm not seeing any error trace related to some buffer failing to allocate, however the actual alignment looks weird enough to me to need to take a closer look.

@paulstelian97

Copy link
Copy Markdown
Collaborator

Huh, I think you need to return with a fix for when CONFIG_HEAP_DEBUG is enabled. Currently (as-merged) rballoc macro is defined twice instead of defining rballoc and rballoc_align.

@dabekjakub

Copy link
Copy Markdown
Member Author

@paulstelian97 when it comes to playback I saw no issues and CI went through with no problem.

DEBUG_HEAP Fix on the way.

@paulstelian97

Copy link
Copy Markdown
Collaborator

Yeah, I think something else actually caused issues with my SYS_RT heap being too small. I will continue to investigate my issues separately. Whenever I identify an upstream commit I will ask about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants