函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:Given a mapping request (addr,end,vm_flags,file,pgoff), figure out* whether that can be merged with its predecessor or its successor

函数原型:struct vm_area_struct *vma_merge(struct mm_struct *mm, struct vm_area_struct *prev, unsigned long addr, unsigned long end, unsigned long vm_flags, struct anon_vma *anon_vma, struct file *file, unsigned long pgoff, struct mempolicy *policy, struct vm_userfaultfd_ctx vm_userfaultfd_ctx)

返回类型:struct vm_area_struct

参数:

类型参数名称
struct mm_struct *mm
struct vm_area_struct *prev
unsigned longaddr
unsigned longend
unsigned longvm_flags
struct anon_vma *anon_vma
struct file *file
unsigned longpgoff
struct mempolicy *policy
struct vm_userfaultfd_ctxvm_userfaultfd_ctx
1120  pglen等于endaddr右移PAGE_SHIFT determines the page size
1128  如果vm_flags按位与Special vmas that are non-mergable, non-mlock()able.* Note: mm/huge_memory.c VM_NO_THP depends on this definition.则返回:NULL
1131  如果prevnext等于linked list of VM areas per task, sorted by address
1133  否则next等于 list of VMAs
1135  area等于next
1136  如果areaThe first byte after our end addresswithin vm_mm. 恒等于endnext等于linked list of VM areas per task, sorted by address
1140  VM_WARN_ON(prev && addr <= Our start address within vm_mm. )
1141  VM_WARN_ON(area && end > The first byte after our end addresswithin vm_mm. )
1142  VM_WARN_ON(addr >= end)
1147  如果prevThe first byte after our end addresswithin vm_mm. 恒等于addrmpol_equal(vma_policy(prev), policy)且Return true if we can merge this (vm_flags,anon_vma,file,vm_pgoff)* beyond (at a higher virtual address and file offset than) the vma.* We cannot merge two vmas if they have differently assigned (non-NULL)
1167  否则err等于We cannot adjust vm_start, vm_end, vm_pgoff fields of a vma that* is already present in an i_mmap tree without adjusting the tree.* The following helper function should be used when such adjustments* are necessary
1170  如果err则返回:NULL
1172  khugepaged_enter_vma_merge(prev, vm_flags)
1173  返回:prev
1179  如果nextend恒等于Our start address within vm_mm. mpol_equal(policy, vma_policy(next))且Return true if we can merge this (vm_flags,anon_vma,file,vm_pgoff)* in front of (at a lower virtual address and file offset than) the vma.* We cannot merge two vmas if they have differently assigned (non-NULL)
1184  如果prevaddr小于The first byte after our end addresswithin vm_mm. err等于We cannot adjust vm_start, vm_end, vm_pgoff fields of a vma that* is already present in an i_mmap tree without adjusting the tree.* The following helper function should be used when such adjustments* are necessary
1187  否则
1195  area等于next
1197  如果err则返回:NULL
1199  khugepaged_enter_vma_merge(area, vm_flags)
1200  返回:area
1203  返回:NULL
调用者
名称描述
mmap_region
do_brk_flagshis is really a simplified "do_mmap". it only handles* anonymous maps. eventually we may be able to do some* brk-specific accounting here.
copy_vmaCopy the vma structure to a new location in the same mm,* prior to moving page table entries, to effect an mremap move.
mprotect_fixup
madvise_behaviorWe can potentially split a vm area into separate* areas, each area with its own behavior.
mbind_rangeStep 2: apply policy to a range and do splits.
userfaultfd_register
userfaultfd_unregister
mlock_fixupmlock_fixup - handle mlock[all]/munlock[all] requests.* Filters out "special" vmas -- VM_LOCKED never gets set for these, and* munlock is a no-op. However, for some special vmas, we go ahead and* populate the ptes.
userfaultfd_release