Skip to content
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

linker: add custom align size to reduce alignment memory wasting #17390

Merged
merged 2 commits into from Sep 20, 2019

Conversation

wentongwu
Copy link
Contributor

@wentongwu wentongwu commented Jul 8, 2019

1) When enable CONFIG_CUSTOM_SECTION_ALIGN, it need less alignment memory
for image rom region. But it will consume one more MPU region. For example somehow
we can know the size of .text and .rodata section, 512k+4B, with current code and
CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT enabled, the size of .text
and .rodata section in RAM (suppose only RAM) will be 1M.
But if with CONFIG_CUSTOM_SECTION_ALIGN(for example 64k), the size of .text and 
.rodata section will be 512k+64k(MPU_SUB_REGION_SIZE), that saved memory. 
For MPU configuration, 512k will be in MPU region1 and 64k will be in MPU region 2,
it will waste one more MPU region. 
The trade off for enable CONFIG_CUSTOM_SECTION_ALIGN or not should be decided by
end users according their applications, but Zephyr should provide this option.

2) Add custom align size for code relocation to reduce alignment memory wasting.

Fixes: #17337

Signed-off-by: Wentong Wu wentong.wu@intel.com

@wentongwu wentongwu added the DNM This PR should not be merged (Do Not Merge) label Jul 8, 2019
@zephyrbot zephyrbot added area: ARM ARM (32-bit) Architecture area: API Changes to public APIs area: Tests Issues related to a particular existing or missing test area: Kernel labels Jul 8, 2019
@zephyrbot
Copy link
Collaborator

zephyrbot commented Jul 8, 2019

All checks are passing now.

Review history of this comment for details about previous failed status.
Note that some checks might have not completed yet.

@wentongwu wentongwu removed the DNM This PR should not be merged (Do Not Merge) label Jul 29, 2019
@wentongwu wentongwu changed the title add example to show the advantage for defining custom align size linker: add custom align size to reduce alignment memory wasting Jul 29, 2019
@wentongwu
Copy link
Contributor Author

@ioannisg @andrewboie could you please give some comments about this PR? Thanks

@andrewboie
Copy link
Contributor

when enable CONFIG_CUSTOM_SECTION_ALIGN, it need less alignment
memory for image rom region. But it will consume one more MPU
region. The trade off for enable CONFIG_CUSTOM_SECTION_ALIGN or
not should be decided by end users according their applications,
but Zephyr should provide this option.

I don't understand what you mean by this.
How would section alignment cause an additional MPU region to be used? Please elaborate.

@wentongwu
Copy link
Contributor Author

wentongwu commented Aug 15, 2019

when enable CONFIG_CUSTOM_SECTION_ALIGN, it need less alignment
memory for image rom region. But it will consume one more MPU
region. The trade off for enable CONFIG_CUSTOM_SECTION_ALIGN or
not should be decided by end users according their applications,
but Zephyr should provide this option.

I don't understand what you mean by this.
How would section alignment cause an additional MPU region to be used? Please elaborate.

@andrewboie sorry for the confuse, I have updated the comments, please take a look. Thanks

@ioannisg ioannisg modified the milestones: v2.0.0, v2.1.0 Aug 17, 2019
@wentongwu wentongwu added area: Linker Scripts and removed area: Tests Issues related to a particular existing or missing test labels Sep 4, 2019
@wentongwu wentongwu added code relocation and removed area: API Changes to public APIs labels Sep 8, 2019
@nashif
Copy link
Member

nashif commented Sep 19, 2019

rebase

@zephyrbot zephyrbot added the area: API Changes to public APIs label Sep 19, 2019
when enable CONFIG_CUSTOM_SECTION_ALIGN, it need less alignment
memory for image rom region. But that needs carefully configure
MPU region and sub-regions(ARMv7-M) to cover this feature.

Fixes: zephyrproject-rtos#17337.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
add custom align size for code relocation to reduce alignment memory
wasting.

Fixes: zephyrproject-rtos#17337.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
@nashif nashif merged commit 09af98a into zephyrproject-rtos:master Sep 20, 2019
@backporting
Copy link

backporting bot commented Sep 20, 2019

The backport to v1.14-branch failed:

Commits ["de7aa87e23e8ae92c720f97fc27e6a52b2e42d1a","de7f4d30e886c1f3ac15f137c5cd01d59a2f0f4a"] could not be cherry-picked on top of v1.14-branch

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub.
git fetch
# Create new working tree.
git worktree add .worktrees/backport v1.14-branch
# Navigate to the new directory.
cd .worktrees/backport
# Cherry-pick all the commits of this pull request and resolve the likely conflicts.
git cherry-pick de7aa87e23e8ae92c720f97fc27e6a52b2e42d1a de7f4d30e886c1f3ac15f137c5cd01d59a2f0f4a
# Create a new branch with these backported commits.
git checkout -b backport-17390-to-v1.14-branch
# Push it to GitHub.
git push --set-upstream origin backport-17390-to-v1.14-branch
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport

Then, create a pull request where the base branch is v1.14-branch and the compare/head branch is backport-17390-to-v1.14-branch.

@wentongwu wentongwu deleted the custom_section_align_size branch October 8, 2019 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: ARM ARM (32-bit) Architecture area: Linker Scripts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArmV7-M mpu sub region alignment
6 participants