linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yang Shi <yang.shi@linux.alibaba.com>
To: "linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: [Question] Why do clear VM_ACCOUNT before do_munmap() in mremap()
Date: Fri, 21 Sep 2018 17:00:52 -0700	[thread overview]
Message-ID: <80280fc6-3916-d6e0-7fb0-c5cbc7013221@linux.alibaba.com> (raw)

Hi folks,


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


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

 A A A A A A A  ...

 A A A A A A A  do_munmap(mm, old_addr, old_len, uf_unmap)

 A A A A A A A  ...

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


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

                 reply	other threads:[~2018-09-22  0:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80280fc6-3916-d6e0-7fb0-c5cbc7013221@linux.alibaba.com \
    --to=yang.shi@linux.alibaba.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox