Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\fork.c Create Date:2022-07-28 08:57:43
Last Modify:2020-03-17 11:04:53 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:dup_mmap

Proto:static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)

Type:int

Parameter:

TypeParameterName
struct mm_struct *mm
struct mm_struct *oldmm
488  LIST_HEAD(uf)
490  uprobe_start_dup_mmap()
491  If down_write_killable( & mmap_sem) Then
492  retval = -EINTR
493  Go to fail_uprobe_end
495  flush_cache_dup_mm(oldmm)
496  uprobe_dup_mmap(oldmm, mm)
500  down_write_nested( & mmap_sem, For trivial one-depth nesting of a lock-class, the following* global define can be used. (Subsystems with multiple levels* of nesting should define their own lock-nesting subclasses.))
503  RCU_INIT_POINTER() - initialize an RCU protected pointer*@p: The pointer to be initialized.*@v: The value to initialized the pointer to.* Initialize an RCU-protected pointer in special cases where readers( store ref to file /proc//exe symlink points to , get_mm_exe_file - acquire a reference to the mm's executable file* Returns %NULL if mm has no associated executable file.* User must release file via fput().)
505  Total pages mapped = Total pages mapped
506  VM_WRITE & ~VM_SHARED & ~VM_STACK = VM_WRITE & ~VM_SHARED & ~VM_STACK
507  VM_EXEC & ~VM_WRITE & ~VM_STACK = VM_EXEC & ~VM_WRITE & ~VM_STACK
508  VM_STACK = VM_STACK
510  rb_link = rb_node
511  rb_parent = NULL
512  pprev = list of VMAs
513  retval = ksm_fork(mm, oldmm)
514  If retval Then Go to out
516  retval = khugepaged_fork(mm, oldmm)
517  If retval Then Go to out
520  prev = NULL
521  When mpnt cycle
526  Continue
528  charge = 0
534  retval = -EINTR
535  Go to out
538  len = vma_pages(mpnt)
542  charge = len
544  tmp = vm_area_dup(mpnt)
545  If Not tmp Then Go to fail_nomem
547  retval = vma_dup_policy(mpnt, tmp)
548  If retval Then Go to fail_nomem_policy
550  The address space we belong to. = mm
551  retval = dup_userfaultfd(tmp, & uf)
552  If retval Then Go to fail_nomem_anon_vma_fork
559  Else if Attach vma to its own anon_vma, as well as to the anon_vmas that* the corresponding VMA in the parent process is attached to.* Returns 0 on success, non-zero on failure. Then Go to fail_nomem_anon_vma_fork
561  Flags, see mm.h. &= ~(VM_LOCKED | Lock the pages covered when they are faulted in )
562  linked list of VM areas per task, sorted by address = linked list of VM areas per task, sorted by address = NULL
563  file = File we map to (can be NULL).
564  If file Then
565  inode = file_inode(file)
566  mapping = f_mapping
568  get_file(file)
587  If is_vm_hugetlb_page(tmp) Then reset_vma_resv_huge_pages(tmp)
593  pprev = tmp
594  pprev = linked list of VM areas per task, sorted by address
595  linked list of VM areas per task, sorted by address = prev
596  prev = tmp
598  __vma_link_rb(mm, tmp, rb_link, rb_parent)
599  rb_link = rb_right
600  rb_parent = vm_rb
602  number of VMAs ++
603  If Not (Flags, see mm.h. & Wipe VMA contents in child. ) Then retval = copy_page_range(mm, oldmm, mpnt)
606  If Function pointers to deal with this struct. && open Then open(tmp)
609  If retval Then Go to out
613  retval = arch_dup_mmap(oldmm, mm)
614  out :
615  lease a write lock
616  flush_tlb_mm(oldmm)
617  lease a write lock
618  dup_userfaultfd_complete( & uf)
619  fail_uprobe_end :
620  uprobe_end_dup_mmap()
621  Return retval
622  fail_nomem_anon_vma_fork :
623  mpol_put(vma_policy(tmp))
624  fail_nomem_policy :
625  vm_area_free(tmp)
626  fail_nomem :
627  retval = -ENOMEM
628  vm_unacct_memory(charge)
629  Go to out
Caller
NameDescribe
dup_mmdup_mm() - duplicates an existing mm structure*@tsk: the task_struct with which the new mm will be associated.*@oldmm: the mm to duplicate.* Allocates a new mm structure and duplicates the provided @oldmm structure* content into it.