函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称: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

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

返回类型:int

参数:

类型参数名称
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  如果next且非insert
709  struct vm_area_struct * exporter = NULL, * importer = NULL
718  如果next恒等于expand
732  否则
745  exporter等于next
746  importer等于vma
755  否则如果end大于Our start address within vm_mm.
761  exporter等于next
762  importer等于vma
771  exporter等于vma
772  importer等于next
786  如果error则返回:error
790  again :
791  vma_adjust_trans_huge(orig_vma, start, end, adjust_next)
793  如果file
794  mapping等于f_mapping
795  root等于i_mmap
796  Called in context of a munmap of a vma.
798  如果adjust_nextCalled in context of a munmap of a vma.
801  i_mmap_lock_write(mapping)
802  如果insert
813  anon_vma等于Serialized by page_table_lock
814  如果非anon_vmaadjust_nextanon_vma等于Serialized by page_table_lock
816  如果anon_vma
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  如果adjust_nextvma 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  如果root
826  flush_dcache_mmap_lock(mapping)
827  vma_interval_tree_remove(vma, root)
828  如果adjust_nextvma_interval_tree_remove(next, root)
832  如果start不等于Our start address within vm_mm.
833  Our start address within vm_mm. 等于start
834  start_changed = true
836  如果end不等于The first byte after our end addresswithin vm_mm.
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  如果adjust_next
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  如果root
847  如果adjust_nextvma_interval_tree_insert(next, root)
849  vma_interval_tree_insert(vma, root)
850  flush_dcache_mmap_unlock(mapping)
853  如果remove_next
858  如果remove_next不等于3则__vma_unlink_common(mm, next, next)
860  否则__vma_unlink_common(mm, next, vma)
871  如果fileRequires inode->i_mapping->i_mmap_rwsem
873  否则如果insert
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  否则
881  如果start_changedUpdate augmented rbtree rb_subtree_gap values after vma->vm_start or* in the rbtree.
883  如果end_changed
884  如果非next highest vma end address 等于vm_end_gap(vma)
891  如果anon_vma
892  anon_vma_interval_tree_post_update_vma(vma)
893  如果adjust_nextanon_vma_interval_tree_post_update_vma(next)
895  anon_vma_unlock_write(anon_vma)
897  如果mappingi_mmap_unlock_write(mapping)
900  如果root
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  如果adjust_nextCalled 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  如果remove_next
908  如果file
910  fput(file)
912  如果Serialized by page_table_lock anon_vma_merge(vma, next)
914  number of VMAs 自减
915  mpol_put(vma_policy(next))
916  vm_area_free(next)
922  如果remove_next不等于3则
930  否则
941  next等于vma
943  如果remove_next恒等于2则
944  remove_next等于1
946  转到:again
948  否则如果nextUpdate augmented rbtree rb_subtree_gap values after vma->vm_start or* in the rbtree.
950  否则
973  如果insertfileCalled 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  返回:0
调用者
名称描述
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