aboutsummaryrefslogtreecommitdiff
path: root/vm/vm_resident.c
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2023-06-26 14:26:50 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-07-03 01:59:49 +0200
commit505ecd7b30fca1dc296205ff3c0dc3aff9d76e12 (patch)
treef19cb99981292863d2db5ae6a0ad43e559b3acac /vm/vm_resident.c
parentd5464d531aaba049a3e734adb80fb0bfd28093a7 (diff)
downloadgnumach-505ecd7b30fca1dc296205ff3c0dc3aff9d76e12.tar.gz
gnumach-505ecd7b30fca1dc296205ff3c0dc3aff9d76e12.tar.bz2
gnumach-505ecd7b30fca1dc296205ff3c0dc3aff9d76e12.zip
Shrink struct vm_page size
struct vm_page is supposed to be a "small structure", but it takes up 96 bytes on x86_64 (to represent a 4k page). By utilizing bitfields and strategically reordering members to avoid excessive padding, it can be shrunk to 80 bytes. - page_lock and unlock_request only need to store a bitmask of VM_PROT_READ, VM_PROT_WRITE, and VM_PROT_EXECUTE. Even though the special values VM_PROT_NO_CHANGE and VM_PROT_NOTIFY are defined, they are not used for the two struct vm_page members. - type and seg_index both need to store one of the four possible values in the range from 0 to 3. Two bits are sufficient for this. - order needs to store a number from 0 to VM_PAGE_NR_FREE_LISTS (which is 11), or a special value VM_PAGE_ORDER_UNLISTED. Four bits are sufficient for this. No functional change. Message-Id: <20230626112656.435622-2-bugaevc@gmail.com>
Diffstat (limited to 'vm/vm_resident.c')
-rw-r--r--vm/vm_resident.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/vm/vm_resident.c b/vm/vm_resident.c
index e0a03bf5..d4777e70 100644
--- a/vm/vm_resident.c
+++ b/vm/vm_resident.c
@@ -746,7 +746,7 @@ boolean_t vm_page_convert(struct vm_page **mp)
memcpy(&real_m->vm_page_header,
&fict_m->vm_page_header,
- sizeof(*fict_m) - VM_PAGE_HEADER_SIZE);
+ VM_PAGE_BODY_SIZE);
real_m->fictitious = FALSE;
vm_page_insert(real_m, object, offset);