History

mm/vmalloc: modify struct vmap_area to reduce its size

Objective --------- The current implementation of struct vmap_area wasted space. After applying this commit, sizeof(struct vmap_area) has been reduced from 11 words to 8 words. Description ----------- 1) Pack "subtree_max_size", "vm" and "purge_list". This is no problem because A) "subtree_max_size" is only used when vmap_area is in "free" tree B) "vm" is only used when vmap_area is in "busy" tree C) "purge_list" is only used when vmap_area is in vmap_purge_list 2) Eliminate "flags". ;Since only one flag VM_VM_AREA is being used, and the same thing can be done by judging whether "vm" is NULL, then the "flags" can be eliminated.

Pengfei Li committed 7 years ago

Commit 688fcbf1 parent dd3b8352 files · +23 −21Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/vmalloc.h+13−7
@@ -53,15 +53,21 @@ struct vmap_area { · 52 unmodified lines
5353 unsigned long va_start;
5454 unsigned long va_end;
5555
56− /*
57− * Largest available free size in subtree.
58− */
59− unsigned long subtree_max_size;
60− unsigned long flags;
6156 struct rb_node rb_node; /* address sorted rbtree */
6257 struct list_head list; /* address sorted list */
63− struct llist_node purge_list; /* "lazy purge" list */
64− struct vm_struct *vm;
58+
59+ /*
60+ * The following three variables can be packed, because
61+ * a vmap_area object is always one of the three states:
62+ * 1) in "free" tree (root is vmap_area_root)
63+ * 2) in "busy" tree (root is free_vmap_area_root)
64+ * 3) in purge list (head is vmap_purge_list)
65+ */
66+ union {
67+ unsigned long subtree_max_size; /* in "free" tree */
68+ struct vm_struct *vm; /* in "busy" tree */
69+ struct llist_node purge_list; /* in purge list */
70+ };
6571 };
6672
6773 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t