Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\mremap.c Create Date:2022-07-28 14:53:15
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:move_vma

Proto:static unsigned long move_vma(struct vm_area_struct *vma, unsigned long old_addr, unsigned long old_len, unsigned long new_len, unsigned long new_addr, bool *locked, struct vm_userfaultfd_ctx *uf, struct list_head *uf_unmap)

Type:unsigned long

Parameter:

TypeParameterName
struct vm_area_struct *vma
unsigned longold_addr
unsigned longold_len
unsigned longnew_len
unsigned longnew_addr
bool *locked
struct vm_userfaultfd_ctx *uf
struct list_head *uf_unmap
324  mm = The address space we belong to.
326  vm_flags = Flags, see mm.h.
329  excess = 0
331  split = 0
339  If number of VMAs >= sysctl_max_map_count - 3 Then Return -ENOMEM
349  err = ksm_madvise(vma, old_addr, old_addr + old_len, KSM may not merge identical pages , & vm_flags)
351  If err Then Return err
354  new_pgoff = Offset (within vm_file) in PAGE_SIZEunits + ( old_addr - Our start address within vm_mm. >> PAGE_SHIFT determines the page size )
355  new_vma = Copy the vma structure to a new location in the same mm,* prior to moving page table entries, to effect an mremap move.
357  If Not new_vma Then Return -ENOMEM
360  moved_len = move_page_tables(vma, old_addr, new_vma, new_addr, old_len, need_rmap_locks)
362  If moved_len < old_len Then
363  err = -ENOMEM
364  Else if Function pointers to deal with this struct. && mremap Then
365  err = mremap(new_vma)
368  If Value for the false possibility is greater at compile time(err) Then
374  move_page_tables(new_vma, new_addr, vma, old_addr, moved_len, true)
376  vma = new_vma
377  old_len = new_len
378  old_addr = new_addr
379  new_addr = err
380  Else
381  mremap_userfaultfd_prep(new_vma, uf)
382  arch_remap(mm, old_addr, old_addr + old_len, new_addr, new_addr + new_len)
387  If vm_flags & Is a VM accounted object Then
388  Flags, see mm.h. &= ~Is a VM accounted object
389  excess = The first byte after our end addresswithin vm_mm. - Our start address within vm_mm. - old_len
390  If old_addr > Our start address within vm_mm. && old_addr + old_len < The first byte after our end addresswithin vm_mm. Then split = 1
404  hiwater_vm = High-water virtual memory usage
405  vm_stat_account(mm, Flags, see mm.h. , new_len >> PAGE_SHIFT determines the page size )
408  If Value for the false possibility is greater at compile time(Flags, see mm.h. & Page-ranges managed without "struct page", just pure PFN ) Then untrack_pfn_moved(vma)
411  If do_munmap(mm, old_addr, old_len, uf_unmap) < 0 Then
413  vm_unacct_memory(excess >> PAGE_SHIFT determines the page size )
414  excess = 0
416  High-water virtual memory usage = hiwater_vm
419  If excess Then
420  Flags, see mm.h. |= Is a VM accounted object
421  If split Then Flags, see mm.h. |= Is a VM accounted object
425  If vm_flags & VM_LOCKED Then
426  Pages that have PG_mlocked set += new_len >> PAGE_SHIFT determines the page size
427  * locked = true
430  Return new_addr
Caller
NameDescribe
mremap_to
SYSCALL_DEFINE5Expand (or shrink) an existing mapping, potentially moving it at the* same time (controlled by the MREMAP_MAYMOVE flag and available VM space)* MREMAP_FIXED option added 5-Dec-1999 by Benjamin LaHaise* This option implies MREMAP_MAYMOVE.