Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:__mcopy_atomic

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

Type:ssize_t

Parameter:

TypeParameterName
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  If mmap_changing && READ_ONCE( * mmap_changing) Then Go to out_unlock
489  err = -ENOENT
490  dst_vma = find_dst_vma(dst_mm, dst_start, len)
491  If Not dst_vma Then Go to out_unlock
494  err = -EINVAL
499  If WARN_ON_ONCE(vma_is_anonymous(dst_vma) && Flags, see mm.h. & VM_SHARED) Then Go to out_unlock
506  If is_vm_hugetlb_page(dst_vma) Then Return __mcopy_atomic processing for HUGETLB vmas. Note that this routine is* called with mmap_sem held, it will release mmap_sem before returning.
510  If Not vma_is_anonymous(dst_vma) && Not vma_is_shmem(dst_vma) Then Go to out_unlock
518  err = -ENOMEM
519  If Not (Flags, see mm.h. & VM_SHARED) && Value for the false possibility is greater at compile time(anon_vma_prepare(dst_vma)) Then Go to out_unlock
523  When src_addr < src_start + len cycle
526  BUG_ON(dst_addr >= dst_start + len)
528  dst_pmd = mm_alloc_pmd(dst_mm, dst_addr)
530  err = -ENOMEM
531  Break
534  dst_pmdval = pmd_read_atomic(dst_pmd)
540  err = -EEXIST
541  Break
545  err = -ENOMEM
546  Break
550  err = -EFAULT
551  Break
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)
571  kunmap(page)
573  err = -EFAULT
574  Go to out
576  Go to retry
577  Else BUG_ON(page)
580  If Not err Then
581  dst_addr += PAGE_SIZE
582  src_addr += PAGE_SIZE
583  copied += PAGE_SIZE
588  If err Then Break
592  out_unlock :
593  lease a read lock
594  out :
595  If page Then Perform 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  Return If copied Then copied Else err
Caller
NameDescribe
mcopy_atomic
mfill_zeropage