Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name: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

Proto:int __vma_adjust(struct vm_area_struct *vma, unsigned long start, unsigned long end, unsigned long pgoff, struct vm_area_struct *insert, struct vm_area_struct *expand)

Type:int

Parameter:

TypeParameterName
struct vm_area_struct *vma
unsigned longstart
unsigned longend
unsigned longpgoff
struct vm_area_struct *insert
struct vm_area_struct *expand
698  mm = The address space we belong to.
699  next = linked list of VM areas per task, sorted by address , orig_vma = vma
700  struct address_space * mapping = NULL
701  struct rb_root_cached * root = NULL
702  struct anon_vma * anon_vma = NULL
703  file = File we map to (can be NULL).
704  bool start_changed = TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., end_changed = false
705  adjust_next = 0
706  remove_next = 0
708  If next && Not insert Then
709  struct vm_area_struct * exporter = NULL, * importer = NULL
718  If next == expand Then
732  Else
745  exporter = next
746  importer = vma
761  exporter = next
762  importer = vma
771  exporter = vma
772  importer = next
786  If error Then Return error
790  again :
791  vma_adjust_trans_huge(orig_vma, start, end, adjust_next)
793  If file Then
794  mapping = f_mapping
795  root = i_mmap
796  Called in context of a munmap of a vma.
798  If adjust_next Then Called in context of a munmap of a vma.
801  i_mmap_lock_write(mapping)
802  If insert Then
813  anon_vma = Serialized by page_table_lock
814  If Not anon_vma && adjust_next Then anon_vma = Serialized by page_table_lock
816  If anon_vma Then
817  VM_WARN_ON(adjust_next && Serialized by page_table_lock && anon_vma != Serialized by page_table_lock )
819  anon_vma_lock_write(anon_vma)
820  vma has some anon_vma assigned, and is already inserted on that* anon_vma's interval trees.* Before updating the vma's vm_start / vm_end / vm_pgoff fields, the* vma must be removed from the anon_vma's interval trees using
821  If adjust_next Then vma has some anon_vma assigned, and is already inserted on that* anon_vma's interval trees.* Before updating the vma's vm_start / vm_end / vm_pgoff fields, the* vma must be removed from the anon_vma's interval trees using
825  If root Then
826  flush_dcache_mmap_lock(mapping)
827  vma_interval_tree_remove(vma, root)
828  If adjust_next Then vma_interval_tree_remove(next, root)
832  If start != Our start address within vm_mm. Then
833  Our start address within vm_mm. = start
834  start_changed = true
836  If end != The first byte after our end addresswithin vm_mm. Then
837  The first byte after our end addresswithin vm_mm. = end
838  end_changed = true
840  Offset (within vm_file) in PAGE_SIZEunits = pgoff
841  If adjust_next Then
842  Our start address within vm_mm. += adjust_next << PAGE_SHIFT determines the page size
843  Offset (within vm_file) in PAGE_SIZEunits += adjust_next
846  If root Then
847  If adjust_next Then vma_interval_tree_insert(next, root)
849  vma_interval_tree_insert(vma, root)
850  flush_dcache_mmap_unlock(mapping)
853  If remove_next Then
858  If remove_next != 3 Then __vma_unlink_common(mm, next, next)
860  Else __vma_unlink_common(mm, next, vma)
871  If file Then Requires inode->i_mapping->i_mmap_rwsem
873  Else if insert Then
879  Helper for vma_adjust() in the split_vma insert case: insert a vma into the* mm's list and rbtree. It has already been inserted into the interval tree.
880  Else
881  If start_changed Then Update augmented rbtree rb_subtree_gap values after vma->vm_start or* in the rbtree.
883  If end_changed Then
891  If anon_vma Then
892  anon_vma_interval_tree_post_update_vma(vma)
893  If adjust_next Then anon_vma_interval_tree_post_update_vma(next)
895  anon_vma_unlock_write(anon_vma)
897  If mapping Then i_mmap_unlock_write(mapping)
900  If root Then
901  Called from mmap_region/vma_adjust with mm->mmap_sem acquired.* Currently we ignore all errors and always return 0, the callers* can't handle the failure anyway.
903  If adjust_next Then Called from mmap_region/vma_adjust with mm->mmap_sem acquired.* Currently we ignore all errors and always return 0, the callers* can't handle the failure anyway.
907  If remove_next Then
908  If file Then
910  fput(file)
912  If Serialized by page_table_lock Then anon_vma_merge(vma, next)
914  number of VMAs --
915  mpol_put(vma_policy(next))
916  vm_area_free(next)
922  If remove_next != 3 Then
930  Else
941  next = vma
943  If remove_next == 2 Then
944  remove_next = 1
946  Go to again
948  Else if next Then Update augmented rbtree rb_subtree_gap values after vma->vm_start or* in the rbtree.
950  Else
973  If insert && file Then Called from mmap_region/vma_adjust with mm->mmap_sem acquired.* Currently we ignore all errors and always return 0, the callers* can't handle the failure anyway.
976  validate_mm(mm)
978  Return 0
Caller
NameDescribe
vma_mergeGiven a mapping request (addr,end,vm_flags,file,pgoff), figure out* whether that can be merged with its predecessor or its successor
vma_adjust