From: David Howells The attached patch includes prio-tree support and adds cross-referencing of VMAs with address spaces back in, as is done under normal MMU Linux. Signed-Off-By: David Howells Signed-off-by: Andrew Morton --- 25-akpm/mm/Makefile | 4 ++-- 25-akpm/mm/nommu.c | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff -puN mm/Makefile~cross-reference-nommu-vmas-with-mappings mm/Makefile --- 25/mm/Makefile~cross-reference-nommu-vmas-with-mappings Thu Dec 16 15:29:14 2004 +++ 25-akpm/mm/Makefile Thu Dec 16 15:29:14 2004 @@ -5,12 +5,12 @@ mmu-y := nommu.o mmu-$(CONFIG_MMU) := fremap.o highmem.o madvise.o memory.o mincore.o \ mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \ - vmalloc.o prio_tree.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) + prio_tree.o $(mmu-y) obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o obj-$(CONFIG_HUGETLBFS) += hugetlb.o diff -puN mm/nommu.c~cross-reference-nommu-vmas-with-mappings mm/nommu.c --- 25/mm/nommu.c~cross-reference-nommu-vmas-with-mappings Thu Dec 16 15:29:14 2004 +++ 25-akpm/mm/nommu.c Thu Dec 16 15:29:14 2004 @@ -51,10 +51,6 @@ DECLARE_RWSEM(nommu_vma_sem); struct vm_operations_struct generic_file_vm_ops = { }; -void __init prio_tree_init(void) -{ -} - /* * Handle all mappings that got truncated by a "truncate()" * system call. @@ -322,6 +318,15 @@ static void add_nommu_vma(struct vm_area struct rb_node **p = &nommu_vma_tree.rb_node; struct rb_node *parent = NULL; + /* add the VMA to the mapping */ + if (vma->vm_file) { + mapping = vma->vm_file->f_mapping; + + flush_dcache_mmap_lock(mapping); + vma_prio_tree_insert(vma, &mapping->i_mmap); + flush_dcache_mmap_unlock(mapping); + } + /* add the VMA to the master list */ while (*p) { parent = *p; @@ -356,6 +361,15 @@ static void delete_nommu_vma(struct vm_a { struct address_space *mapping; + /* remove the VMA from the mapping */ + if (vma->vm_file) { + mapping = vma->vm_file->f_mapping; + + flush_dcache_mmap_lock(mapping); + vma_prio_tree_remove(vma, &mapping->i_mmap); + flush_dcache_mmap_unlock(mapping); + } + /* remove from the master list */ rb_erase(&vma->vm_rb, &nommu_vma_tree); } _