Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

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

Proto: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)

Type:struct vm_area_struct

Parameter:

TypeParameterName
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 = end - addr >> PAGE_SHIFT determines the page size
1128  If vm_flags & Special vmas that are non-mergable, non-mlock()able.* Note: mm/huge_memory.c VM_NO_THP depends on this definition. Then Return NULL
1131  If prev Then next = linked list of VM areas per task, sorted by address
1133  Else next = list of VMAs
1135  area = next
1136  If area && The first byte after our end addresswithin vm_mm. == end Then next = 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  If prev && The first byte after our end addresswithin vm_mm. == addr && mpol_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) Then
1167  Else 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  If err Then Return NULL
1172  khugepaged_enter_vma_merge(prev, vm_flags)
1173  Return prev
1179  If next && end == 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) Then
1184  If prev && addr < The first byte after our end addresswithin vm_mm. Then 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  Else
1195  area = next
1197  If err Then Return NULL
1199  khugepaged_enter_vma_merge(area, vm_flags)
1200  Return area
1203  Return NULL
Caller
NameDescribe
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