• Hugh Dickins's avatar
    [PATCH] vmtrunc: restart_addr in truncate_count · 8a1a48b7
    Hugh Dickins authored
    Despite its restart_pgoff pretentions, unmap_mapping_range_vma was fatally
    unable to distinguish a vma to be restarted from the case where that vma
    has been freed, and its vm_area_struct reused for the top part of a
    !new_below split of an isomorphic vma yet to be scanned.
    
    The obvious answer is to note restart_vma in the struct address_space, and
    cancel it when that vma is freed; but I'm reluctant to enlarge every struct
    inode just for this.  Another answer is to flag valid restart in the
    vm_area_struct; but vm_flags is protected by down_write of mmap_sem, which
    we cannot take within down_write of i_sem.  If we're going to need yet
    another field, better to record the restart_addr itself: restart_vma only
    recorded the last restart, but a busy tree could well use more.
    
    Actually, we don't need another field: we can neatly (though naughtily)
    keep restart_addr in vm_truncate_count, provided mapping->truncate_count
    leaps over those values which look like a page-aligned address.  Zero
    remains good for forcing a scan (though now interpreted as restart_addr 0),
    and it turns out no change is needed to any of the vm_truncate_count
    settings in dup_mmap, vma_link, vma_adjust, move_one_page.
    Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    8a1a48b7
memory.c 58.6 KB