linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [Question] Why do clear VM_ACCOUNT before do_munmap() in mremap()
@ 2018-09-22  0:00 Yang Shi
  0 siblings, 0 replies; only message in thread
From: Yang Shi @ 2018-09-22  0:00 UTC (permalink / raw)
  To: linux-mm

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-09-22  0:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-22  0:00 [Question] Why do clear VM_ACCOUNT before do_munmap() in mremap() Yang Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox