[Question] Why do clear VM_ACCOUNT before do_munmap() in mremap()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks,


When reading the mremap() code, I found the below code fragmentation:


        /* Conceal VM_ACCOUNT so old reservation is not undone */
        if (vm_flags & VM_ACCOUNT) {
                vma->vm_flags &= ~VM_ACCOUNT;
                excess = vma->vm_end - vma->vm_start - old_len;
                if (old_addr > vma->vm_start &&
                    old_addr + old_len < vma->vm_end)
                        split = 1;
        }

        ...

        do_munmap(mm, old_addr, old_len, uf_unmap)

        ...

        /* Restore VM_ACCOUNT if one or two pieces of vma left */
        if (excess) {
                vma->vm_flags |= VM_ACCOUNT;
                if (split)
                        vma->vm_next->vm_flags |= VM_ACCOUNT;
        }


I don't get why it conceals VM_ACCOUNT, then restores it. This change is pre git period, so there is not commit log about why this is needed. Any hint is appreciated.


Thanks,

Yang




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux