static void get_index(const struct prio_tree_root *root, const struct prio_tree_node *node, unsigned long *radix, unsigned long *heap) { if (root->raw) { struct vm_area_struct *vma = prio_tree_entry( node, struct vm_area_struct, shared.prio_tree_node); *radix = RADIX_INDEX(vma); *heap = HEAP_INDEX(vma); } else {
/* * Add a new vma known to map the same set of pages as the old vma: * useful for fork's dup_mmap as well as vma_prio_tree_insert below. * Note that it just happens to work correctly on i_mmap_nonlinear too. */ void vma_prio_tree_add(struct vm_area_struct *vma, struct vm_area_struct *old) { /* Leave these BUG_ONs till prio_tree patch stabilizes */ BUG_ON(RADIX_INDEX(vma) != RADIX_INDEX(old)); BUG_ON(HEAP_INDEX(vma) != HEAP_INDEX(old)); vma->shared.vm_set.head = NULL; vma->shared.vm_set.parent = NULL; if (!old->shared.vm_set.parent) list_add(&vma->shared.vm_set.list, &old->shared.vm_set.list); else if (old->shared.vm_set.head) list_add_tail(&vma->shared.vm_set.list, &old->shared.vm_set.head->shared.vm_set.list); else { INIT_LIST_HEAD(&vma->shared.vm_set.list); vma->shared.vm_set.head = old; old->shared.vm_set.head = vma; } }