forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: mmu: shrink and align struct z_page_frame
The struct z_page_frame is marked __packed to avoid extra padding as such padding may represent significant memory waste when lots of page frames are used. However this is a bad strategy. The code contained this somewhat dubious comment and code in free_page_frame_list_put(): /* The structure is packed, which ensures that this is true */ void *node = pf; sys_slist_append(&free_page_frame_list, node); This is bad for many reasons: - type checking is completely bypassed; - if the sys_snode_t node member is no longer located at the front of struct z_page_frame then the code will still compile and possibly run but be broken with memory corruption as a likely outcome; - the sys_slist_append() code is completely unaware of the packed attribute which breaks architectures with alignment restrictions. Let's improve code efficiency as well as memory usage by removing the packed attribute and manually packing the flags in the unused virtual address bits. This way the page frame array remains naturally aligned, data access becomes optimal and the actual array size gets even smaller. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
- Loading branch information
Showing
3 changed files
with
85 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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