rmap 17: real prio_tree
Subsystems (3)
PATCH 32/57 rmap 17: real prio_tree
From: Hugh Dickins <[email protected]>
Rajesh Venkatasubramanian's implementation of a radix priority search tree of vmas, to handle object-based reverse mapping corner cases well.
Amongst the objections to object-based rmap were test cases by akpm and by mingo, in which large numbers of vmas mapping disjoint or overlapping parts of a file showed strikingly poor performance of the i_mmap lists. Perhaps those tests are irrelevant in the real world? We cannot be too sure: the prio_tree is well-suited to solving precisely that problem, so unless it turns out to bring too much overhead, let's include it.
Why is this prio_tree.c placed in mm rather than lib? See GET_INDEX: this implementation is geared throughout to use with vmas, though the first half of the file appears more general than the second half.
Each node of the prio_tree is itself (contained within) a vma: might save memory by allocating distinct nodes from which to hang vmas, but wouldn't save much, and would complicate the usage with preallocations. Off each node of the prio_tree itself hangs a list of like vmas, if any.
The connection from node to list is a little awkward, but probably the best
compromise: it would be more straightforward to list likes directly from the tree node, but that would use more memory per vma, for the list_head and to identify that head. Instead, node's shared.vm_set.head points to next vma (whose shared.vm_set.head points back to node vma), and that next contains the list_head from which the rest hang - reusing fields already used in the prio_tree node itself.
Currently lacks prefetch: Rajesh hopes to add some soon.
---
25-akpm/include/linux/mm.h | 37 -- 25-akpm/include/linux/prio_tree.h | 57 ++- 25-akpm/init/main.c | 2 25-akpm/mm/Makefile | 5 25-akpm/mm/mmap.c | 25 - 25-akpm/mm/prio_tree.c | 654 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 723 insertions(+), 57 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~rmap-17-real-prio_tree +17 -20
@@ -73,7 +73,15 @@ struct vm_area_struct {* For areas with an address space and backing store, * one of the address_space->i_mmap{,shared} trees. */ -struct list_head shared; +union { +struct { +struct list_head list; +void *parent;/* aligns with prio_tree_node parent */ +struct vm_area_struct *head; + } vm_set; + +struct prio_tree_node prio_tree_node; + } shared;/* Function pointers to deal with this struct. */ struct vm_operations_struct * vm_ops;
@@ -589,27 +597,16 @@ extern void si_meminfo_node(struct sysinstatic inline void vma_prio_tree_init (struct vm_area_struct *vma) { -INIT_LIST_HEAD (&vma->shared); -} - -static inline void vma_prio_tree_add (struct vm_area_struct *vma, -struct vm_area_struct *old) -{ -list_add (&vma->shared, &old->shared); -} - -static inline void vma_prio_tree_insert (struct vm_area_struct *vma, -struct prio_tree_root *root) -{ -list_add_tail (&vma->shared, &root->list); -} - -static inline void vma_prio_tree_remove (struct vm_area_struct *vma, -struct prio_tree_root *root) -{ -list_del_init (&vma->shared); + vma->shared.vm_set.list.next =NULL ; + vma->shared.vm_set.list.prev =NULL ; + vma->shared.vm_set.parent =NULL ; + vma->shared.vm_set.head =NULL ; } +/* prio_tree.c */ +void vma_prio_tree_add (struct vm_area_struct *,struct vm_area_struct *old); +void vma_prio_tree_insert (struct vm_area_struct *,struct prio_tree_root *); +void vma_prio_tree_remove (struct vm_area_struct *,struct prio_tree_root *);struct vm_area_struct *vma_prio_tree_next (struct vm_area_struct *,struct prio_tree_root *,struct prio_tree_iter *,pgoff_t begin,pgoff_t end);
include/linux/prio_tree.h renamed from include/linux/prio_tree.h~rmap-17-real-prio_tree +47 -10
74 lines not on this page · raw message
init/main.c renamed from init/main.c~rmap-17-real-prio_tree +2 -0
@@ -84,6 +84,7 @@ extern void signals_init(void);extern void buffer_init (void );extern void pidhash_init (void );extern void pidmap_init (void ); +extern void prio_tree_init (void );extern void radix_tree_init (void );extern void free_initmem (void );extern void populate_rootfs (void );
@@ -459,6 +460,7 @@ asmlinkage void __init start_kernel(voidcalibrate_delay ();pidmap_init ();pgtable_cache_init (); +prio_tree_init ();#ifdef CONFIG_X86 if (efi_enabled)efi_enter_virtual_mode ();
mm/Makefile renamed from mm/Makefile~rmap-17-real-prio_tree +3 -2
@@ -8,8 +8,9 @@ mmu-$(CONFIG_MMU) := fremap.o highmem.o shmem.o vmalloc.o obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \ - page_alloc.o page-writeback.o pdflush.o readahead.o \ - slab.o swap.o truncate.o vmscan.o $(mmu-y) + page_alloc.o page-writeback.o pdflush.o prio_tree.o \ + readahead.o slab.o swap.o truncate.o vmscan.o \ + $(mmu-y) obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o obj-$(CONFIG_HUGETLBFS) += hugetlb.o
mm/mmap.c renamed from mm/mmap.c~rmap-17-real-prio_tree +0 -25
@@ -323,31 +323,6 @@ __insert_vm_struct(struct mm_struct * mm }/* -* Dummy version of vma_prio_tree_next, just for this patch: -* no radix priority search tree whatsoever, just implement interface -* using the old lists: return the next vma overlapping [begin,end]. -*/ -struct vm_area_struct *vma_prio_tree_next ( -struct vm_area_struct *vma,struct prio_tree_root *root, -struct prio_tree_iter *iter,pgoff_t begin,pgoff_t end) -{ -struct list_head *next; -pgoff_t vba, vea; - - next = vma? vma->shared.next: root->list.next; -while (next != &root->list) { - vma = list_entry(next, struct vm_area_struct, shared); - vba = vma->vm_pgoff; - vea = vba + ((vma->vm_end - vma->vm_start) >>PAGE_SHIFT ) -1 ; -/* Return vma if it overlaps [begin,end] */ -if (vba <= end && vea >= begin) -return vma; - next = next->next; - } -return NULL ; -} - -/* * We cannot adjust vm_start, vm_end, vm_pgoff fields of a vma that is * already present in an i_mmap{_shared} tree without adjusting the tree. * The following helper function should be used when such adjustments
mm/prio_tree.c new file +654 -0
654 lines not on this page · raw message
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>