函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:__mcopy_atomic

函数原型:static __always_inline ssize_t __mcopy_atomic(struct mm_struct *dst_mm, unsigned long dst_start, unsigned long src_start, unsigned long len, bool zeropage, bool *mmap_changing)

返回类型:ssize_t

参数:

类型参数名称
struct mm_struct *dst_mm
unsigned longdst_start
unsigned longsrc_start
unsigned longlen
boolzeropage
bool *mmap_changing
462  BUG_ON(dst_start & ~PAGE_MASK)
463  BUG_ON(len & ~PAGE_MASK)
466  BUG_ON(src_start + len <= src_start)
467  BUG_ON(dst_start + len <= dst_start)
469  src_addr等于src_start
470  dst_addr等于dst_start
471  copied等于0
472  page = NULL
473  retry :
474  lock for reading
481  err等于负EAGAIN
482  如果mmap_changingREAD_ONCE( * mmap_changing)则转到:out_unlock
489  err等于负ENOENT
490  dst_vma等于find_dst_vma(dst_mm, dst_start, len)
491  如果非dst_vma则转到:out_unlock
494  err等于负EINVAL
499  如果WARN_ON_ONCE(vma_is_anonymous(dst_vma) && Flags, see mm.h. & VM_SHARED)则转到:out_unlock
506  如果is_vm_hugetlb_page(dst_vma)则返回:__mcopy_atomic processing for HUGETLB vmas. Note that this routine is* called with mmap_sem held, it will release mmap_sem before returning.
510  如果非vma_is_anonymous(dst_vma)且非vma_is_shmem(dst_vma)则转到:out_unlock
518  err等于负ENOMEM
519  如果非Flags, see mm.h. 按位与VM_SHARED的值且此条件成立可能性小(为编译器优化)(anon_vma_prepare(dst_vma))则转到:out_unlock
523 src_addr小于src_startlen循环
526  BUG_ON(dst_addr >= dst_start + len)
528  dst_pmd等于mm_alloc_pmd(dst_mm, dst_addr)
530  err等于负ENOMEM
531  退出
534  dst_pmdval等于pmd_read_atomic(dst_pmd)
540  err等于负EEXIST
541  退出
545  err等于负ENOMEM
546  退出
550  err等于负EFAULT
551  退出
554  BUG_ON(pmd_none( * dst_pmd))
555  BUG_ON(pmd_trans_huge( * dst_pmd))
557  err等于mfill_atomic_pte(dst_mm, dst_pmd, dst_vma, dst_addr, src_addr, & page, zeropage)
559  cond_resched()
565  BUG_ON(!page)
567  page_kaddr等于kmap(page)
568  err等于copy_from_user(page_kaddr, (constvoid__user * )src_addr, PAGE_SIZE)
571  kunmap(page)
573  err等于负EFAULT
574  转到:out
576  转到:retry
577  否则BUG_ON(page)
580  如果非err
581  dst_addr加等于PAGE_SIZE
582  src_addr加等于PAGE_SIZE
583  copied加等于PAGE_SIZE
585  如果fatal_signal_pending(当前进程)则err等于负EINTR
588  如果err退出
592  out_unlock :
593  lease a read lock
594  out :
595  如果pagePerform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
597  BUG_ON(copied < 0)
598  BUG_ON(err > 0)
599  BUG_ON(!copied && !err)
600  返回:如果copiedcopied否则err
调用者
名称描述
mcopy_atomic
mfill_zeropage