函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\mremap.c Create Date:2022-07-27 16:22:06
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:move_vma

函数原型: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)

返回类型:unsigned long

参数:

类型参数名称
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  如果 number of VMAs 大于等于sysctl_max_map_count减3则返回:负ENOMEM
349  err等于ksm_madvise(vma, old_addr, old_addr + old_len, KSM may not merge identical pages , & vm_flags)
351  如果err则返回:err
354  new_pgoff等于Offset (within vm_file) in PAGE_SIZEunits old_addrOur 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  如果非new_vma则返回:负ENOMEM
360  moved_len等于move_page_tables(vma, old_addr, new_vma, new_addr, old_len, need_rmap_locks)
362  如果moved_len小于old_len
363  err等于负ENOMEM
364  否则如果Function pointers to deal with this struct. mremap
365  err等于mremap(new_vma)
368  如果此条件成立可能性小(为编译器优化)(err)则
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  否则
381  mremap_userfaultfd_prep(new_vma, uf)
382  arch_remap(mm, old_addr, old_addr + old_len, new_addr, new_addr + new_len)
387  如果vm_flags按位与Is a VM accounted object
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  如果old_addr大于Our start address within vm_mm. old_addrold_len小于The first byte after our end addresswithin vm_mm. 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  如果此条件成立可能性小(为编译器优化)(Flags, see mm.h. & Page-ranges managed without "struct page", just pure PFN )则untrack_pfn_moved(vma)
411  如果do_munmap(mm, old_addr, old_len, uf_unmap)小于0则
413  vm_unacct_memory(excess >> PAGE_SHIFT determines the page size )
414  excess等于0
416  High-water virtual memory usage 等于hiwater_vm
419  如果excess
420  Flags, see mm.h. 或等于Is a VM accounted object
421  如果splitFlags, see mm.h. 或等于Is a VM accounted object
425  如果vm_flags按位与VM_LOCKED
426  Pages that have PG_mlocked set 加等于new_len右移PAGE_SHIFT determines the page size
427  * locked = true
430  返回:new_addr
调用者
名称描述
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.