-
Notifications
You must be signed in to change notification settings - Fork 8.1k
xtensa: memory domains: reuse page tables until changes are made #96235
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
Open
dcpleung
wants to merge
9
commits into
zephyrproject-rtos:main
Choose a base branch
from
dcpleung:xtensa/mmu_make_l2_tables_cow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
xtensa: memory domains: reuse page tables until changes are made #96235
dcpleung
wants to merge
9
commits into
zephyrproject-rtos:main
from
dcpleung:xtensa/mmu_make_l2_tables_cow
+514
−251
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
This is on top of #93947 as that PR also changes a bit of page table code. |
58252c3 to
5e72267
Compare
Adds snippets-text-sections.ld to linker scripts. So that the mem_map test can run on qemu_xtensa/dc233c/mmu. Signed-off-by: Daniel Leung <[email protected]>
The fields in macro should be done with both shift and mask values to make it clear. So amend some macros so that the presentation are unified for them. Signed-off-by: Daniel Leung <[email protected]>
This skips the redirection of backup attributes and ring via some SW field macros, and use the PTE bits directly. Should make it easier to decode what's going on. Signed-off-by: Daniel Leung <[email protected]>
Almost all page table entry (PTE) related macros are only used in one source file. These macros are considered the internal working of MMU. There is no need to expose them in header file for other to reference. So move them into the source file where it is only place they are used. Bonus is that we can shorten the macro names as they are now local to the file. Makes it easier to read, and few keystrokes to input. Signed-off-by: Daniel Leung <[email protected]>
Some macros for the page tables array are local to the file so there is no need to prefix them with XTENSA_. Simplify by removing the XTENSA_ prefix, and clairfy if needed. Signed-off-by: Daniel Leung <[email protected]>
In l2_page_table_unmap(), invalidating TLBs should be limited to the address and not the whole auto-refill TLBs. Also fix a bug where the EXEC bit should be determined from the L2 PTE and not the L1 PTE. Signed-off-by: Daniel Leung <[email protected]>
If the page tables are not cached, there is no need to do any cache ops to flush or invalidate the data in cache. So skip them if the page tables are not cached. Saves a few CPU cycles. Signed-off-by: Daniel Leung <[email protected]>
When adding new memory domains, we need to start from kernel page tables by duplicating them. However, there is no need to duplicate all in-use page tables as some memory regions remain unchanged. Fror example, hardware register region where only kernel has access does not need to be duplicated across all memory domains. The same L2 table can be used among them. This changes the L2 page table allocation to be copy-on-write where we only need to duplicate a L2 table if changes need to be made on it. Signed-off-by: Daniel Leung <[email protected]>
Adds function for app to obtain page table usage statistics, allowing fine tuning of numbers of L1 and L2 page table array. Signed-off-by: Daniel Leung <[email protected]>
5e72267 to
864b236
Compare
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



This changes the page table duplication to be COW (copy-on-write) to conserve memory space. When a new memory domain is created, the old mechanism was to duplicate all currently being used kernel page tables. The newly duplicated tables would then be modified to accommodate the new memory domain and its memory partitions. This wastes quite a bit of memory space as some tables remain unchanged, for example, page table for hardware register access and kernel only pages. The changes here modifies this mechanism to reuse existing kernel page tables until modifications are needed. Then it makes a copy of the table, and changes applied to the duplicated table.