Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name: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

Proto:vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason)

Type:vm_fault_t

Parameter:

TypeParameterName
struct vm_fault *vmf
unsigned longreason
354  mm = vm_mm
357  ret = VM_FAULT_SIGBUS
372  If flags & (Getting shut down | Dumped core ) Then Go to out
379  WARN_ON_ONCE(!In all implementations count != 0 means locked )
381  ctx = ctx
382  If Not ctx Then Go to 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  If atures requested from the userspace & UFFD_FEATURE_SIGBUS Then Go to out
398  If Value for the false possibility is greater at compile time(READ_ONCE(leased )) Then
415  ret = VM_FAULT_NOPAGE
416  Go to out
429  If Value for the false possibility is greater at compile time(!(flags & Retry fault if blocking )) Then
435  BUG_ON(flags & Don't drop mmap_sem and wait when retrying )
444  Go to out
451  ret = VM_FAULT_RETRY
452  If flags & Don't drop mmap_sem and wait when retrying Then Go to 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 = current process
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 = If return_to_userland Then TASK_INTERRUPTIBLE Else 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  If Not is_vm_hugetlb_page(vma) Then 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  Else must_wait = Same functionality as userfaultfd_must_wait below with modifications for* hugepmd ranges.
492  lease a read lock
494  If Value is more likely to compile time(must_wait && !READ_ONCE(leased ) && (return_to_userland ? !signal_pending(current process) : !fatal_signal_pending(current process))) Then
497  wake_up_poll( & waitqueue head for the pseudo fd to wakeup poll/read , Epoll event masks )
498  schedule()
499  ret |= VM_FAULT_MAJOR
508  When Not READ_ONCE(waken) cycle
521  schedule()
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;* (Used in tsk->state: )
527  If return_to_userland Then
564  If Not list_empty_careful - tests whether a list is empty and not being modified*@head: the list to test* Description:* tests whether a list is empty _and_ checks that no other CPU might be* in the process of modifying either member (next or prev)* NOTE: using Then
565  spin_lock_irq( & lock)
570  deletes entry from list
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  Return ret
Caller
NameDescribe
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