函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:The locking rules involved in returning VM_FAULT_RETRY depending on* FAULT_FLAG_ALLOW_RETRY, FAULT_FLAG_RETRY_NOWAIT and* FAULT_FLAG_KILLABLE are not straightforward

函数原型:vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)

返回类型:vm_fault_t

参数:

类型参数名称
struct vm_fault *vmf
unsigned longreason
354  mm等于vm_mm
357  ret等于VM_FAULT_SIGBUS
372  如果flags按位与Getting shut down 按位或Dumped core 的值则转到:out
379  WARN_ON_ONCE(!In all implementations count != 0 means locked )
381  ctx等于ctx
382  如果非ctx则转到:out
385  BUG_ON(mm with one ore more vmas attached to this userfaultfd_ctx != mm)
387  VM_BUG_ON(reason & ~(missing pages tracking | wrprotect pages tracking ))
388  VM_BUG_ON(!(reason & missing pages tracking ) ^ !!(reason & wrprotect pages tracking ))
390  如果atures requested from the userspace 按位与UFFD_FEATURE_SIGBUS则转到:out
398  如果此条件成立可能性小(为编译器优化)(READ_ONCE(leased ))则
415  ret等于VM_FAULT_NOPAGE
416  转到:out
429  如果此条件成立可能性小(为编译器优化)(!(flags & Retry fault if blocking ))则
435  BUG_ON(flags & Don't drop mmap_sem and wait when retrying )
444  转到:out
451  ret等于VM_FAULT_RETRY
452  如果flags按位与Don't drop mmap_sem and wait when retrying 则转到:out
456  serfaultfd_ctx_get - Acquires a reference to the internal userfaultfd* context.*@ctx: [in] Pointer to the userfaultfd context.
458  init_waitqueue_func_entry( & wq, userfaultfd_wake_function)
459  private等于当前进程
460  msg等于userfault_msg(address, flags, reason, atures requested from the userspace )
462  ctx等于ctx
463  waken = false
465  return_to_userland等于flags按位与The fault originated in userspace 按位或The fault task is in SIGKILL killable region 的值的值恒等于The fault originated in userspace 按位或The fault task is in SIGKILL killable region 的值
468  blocking_state等于如果return_to_userland睡眠态否则Convenience macros for the sake of set_current_state:
471  spin_lock_irq( & lock)
476  __add_wait_queue( & waitqueue head for the pending (i.e. not read) userfaults , & wq)
482  set_current_state(blocking_state)
483  spin_unlock_irq( & lock)
485  如果非is_vm_hugetlb_page(vma)则must_wait等于Verify the pagetables are still not ok after having reigstered into* the fault_pending_wqh to avoid userland having to UFFDIO_WAKE any* userfault that has already been resolved, if userfaultfd_read and* UFFDIO_COPY|ZEROPAGE are being run simultaneously on
488  否则must_wait等于Same functionality as userfaultfd_must_wait below with modifications for* hugepmd ranges.
492  lease a read lock
494  如果此条件成立可能性大(为编译器优化)(must_wait && !READ_ONCE(leased ) && (return_to_userland ? !signal_pending(当前进程) : !fatal_signal_pending(当前进程)))则
497  wake_up_poll( & waitqueue head for the pseudo fd to wakeup poll/read , Epoll event masks )
498  进程调度
499  ret或等于VM_FAULT_MAJOR
508  当非READ_ONCE(waken)循环
521  进程调度
525  set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:* for (;;) {* set_current_state(TASK_UNINTERRUPTIBLE);* if (!need_sleep)* break;* (就绪态)
527  如果return_to_userland
547  ret等于VM_FAULT_NOPAGE
564  如果非链表为空且不修改
565  spin_lock_irq( & lock)
570  删除链表项
571  spin_unlock_irq( & lock)
578  serfaultfd_ctx_put - Releases a reference to the internal userfaultfd* context.*@ctx: [in] Pointer to userfaultfd context.* The userfaultfd context reference must have been previously acquired either* with userfaultfd_ctx_get() or userfaultfd_ctx_fdget().
580  out :
581  返回:ret
调用者
名称描述
do_anonymous_pageWe enter with non-exclusive mmap_sem (to exclude vma changes,* but allow concurrent faults), and pte mapped but not yet locked.* We return with mmap_sem still held, but pte unmapped and unlocked.
hugetlb_no_page
__do_huge_pmd_anonymous_page
do_huge_pmd_anonymous_page