core: mm: don't walk translation tables for every mapped page - #7947
Merged
Conversation
Edward-HP
force-pushed
the
core-mmu-map-pages-tbl-cache
branch
from
August 26, 2026 09:03
ee993eb to
2644c43
Compare
Contributor
|
|
core_mmu_map_pages(), core_mmu_map_contiguous_pages() and core_mmu_unmap_pages() called core_mmu_find_table() once per small page, even though the leaf translation table only changes every CORE_MMU_PGDIR_SIZE. For a 2MB pgdir that means 511 out of 512 walks returned the same table, each one masking exceptions, reading mpidr_el1 and doing a phys_to_virt() per level descended, all with mmu_spinlock held. The user mapping path in set_um_region() and set_pg_region() already switches leaf table only once per CORE_MMU_PGDIR_SIZE. Add tbl_info_covers_va() and only walk the tables when the virtual address has left the table found for the previous page. Registering an 8MB non-secure shared buffer now walks 4 times instead of 2048 (8 the first time, when each pgdir entry still has to be split), and the same again on unmap. No functional change. Link: OP-TEE#7946 Signed-off-by: edward-hp.wu <edward-hp.wu@mediatek.com> Reviewed-by: Jens Wiklander <jens.wiklander@oss.qualcomm.com>
Edward-HP
force-pushed
the
core-mmu-map-pages-tbl-cache
branch
from
August 28, 2026 06:13
2644c43 to
ccc9af2
Compare
Contributor
|
I'll merge this when the CI tests have passed. |
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
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.
core_mmu_map_pages(), core_mmu_map_contiguous_pages() and core_mmu_unmap_pages() called core_mmu_find_table() once per small page, even though the leaf translation table only changes every CORE_MMU_PGDIR_SIZE. For a 2MB pgdir that means 511 out of 512 walks returned the same table, each one masking exceptions, reading mpidr_el1 and doing a phys_to_virt() per level descended, all with mmu_spinlock held. The user mapping path in set_um_region() and set_pg_region() already switches leaf table only once per CORE_MMU_PGDIR_SIZE.
Add tbl_info_covers_va() and only walk the tables when the virtual address has left the table found for the previous page. Registering an 8MB non-secure shared buffer now walks 4 times instead of 2048 (8 the first time, when each pgdir entry still has to be split), and the same again on unmap. No functional change.
Link: #7946