Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\futex.c Create Date:2022-07-28 10:53:30
Last Modify:2020-03-17 15:28:32 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:get_futex_key() - Get parameters which are the keys for a futex*@uaddr: virtual address of the futex*@fshared: 0 for a PROCESS_PRIVATE futex, 1 for PROCESS_SHARED*@key: address where result is stored

Proto:static int get_futex_key(unsigned int __user *uaddr, int fshared, union futex_key *key, enum futex_access rw)

Type:int

Parameter:

TypeParameterName
unsigned int __user *uaddr
intfshared
union futex_key *key
enum futex_accessrw
529  address = uaddr
530  mm = mm
533  ro = 0
538  offset = address % PAGE_SIZE
539  If Value for the false possibility is greater at compile time((address % sizeof(u32)) != 0) Then Return -EINVAL
541  address -= offset
543  If Value for the false possibility is greater at compile time(!access_ok - Checks if a user space pointer is valid*@addr: User space pointer to start of block to check*@size: Size of block to check* Context: User context only. This function may sleep if pagefaults are* enabled.(uaddr, sizeof(u32))) Then Return -EFAULT
546  If Value for the false possibility is greater at compile time(should_fail_futex(fshared)) Then Return -EFAULT
556  If Not fshared Then
557  mm = mm
558  address = address
559  Take a reference to the resource addressed by a key.* Can be called while holding spinlocks.
560  Return 0
563  again :
565  If Value for the false possibility is greater at compile time(should_fail_futex(fshared)) Then Return -EFAULT
568  err = get_user_pages_fast(address, 1, check pte is writable , & page)
573  If err == -EFAULT && rw == FUTEX_READ Then
574  err = get_user_pages_fast(address, 1, 0, & page)
575  ro = 1
577  If err < 0 Then Return err
579  Else err = 0
600  tail = page
601  page = compound_head(page)
602  mapping = READ_ONCE( See page-flags.h for PAGE_MAPPING_FLAGS )
619  If Value for the false possibility is greater at compile time(!mapping) Then
627  lock_page may only be called if we have the page's inode pinned.
628  shmem_swizzled = PageSwapCache(page) || See page-flags.h for PAGE_MAPPING_FLAGS
629  unlock_page(page)
630  put_page(page)
632  If shmem_swizzled Then Go to again
635  Return -EFAULT
648  If PageAnon(page) Then
654  err = -EFAULT
655  Go to out
658  offset |= We set bit 1 if key has a reference on mm
659  mm = mm
660  address = address
662  Take a reference to the resource addressed by a key.* Can be called while holding spinlocks.
664  Else
678  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
682  put_page(page)
684  Go to again
687  inode = READ_ONCE(host)
688  If Not inode Then
690  put_page(page)
692  Go to again
709  put_page(page)
711  Go to again
715  If WARN_ON_ONCE(i_mapping != mapping) Then
716  err = -EFAULT
718  put an inode
720  Go to out
723  offset |= We set bit 0 if key has a reference on inode
724  inode = inode
725  pgoff = Return page->index in PAGE_SIZE units
726  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
729  out :
730  put_page(page)
731  Return err
Caller
NameDescribe
futex_wakeWake up waiters matching bitset queued on this futex (uaddr).
futex_wake_opWake up all waiters hashed on the physical page that is mapped* to this virtual address:
futex_requeueex_requeue() - Requeue waiters from uaddr1 to uaddr2*@uaddr1: source futex user address*@flags: futex flags (FLAGS_SHARED, etc
futex_wait_setupex_wait_setup() - Prepare to wait on a futex*@uaddr: the futex userspace address*@val: the expected value*@flags: futex flags (FLAGS_SHARED, etc.)*@q: the associated futex_q*@hb: storage for hash_bucket pointer to be returned to caller
futex_lock_piUserspace tried a 0 -> TID atomic transition of the futex value* and failed. The kernel side here does the whole locking operation:* if there are waiters then it will block as a consequence of relying* on rt-mutexes, it does PI, etc
futex_unlock_piUserspace attempted a TID -> 0 atomic transition, and failed.* This is the in-kernel slowpath: we look up the PI state (if any),* and do the rt-mutex unlock.
futex_wait_requeue_piex_wait_requeue_pi() - Wait on uaddr and take uaddr2*@uaddr: the futex we initially wait on (non-pi)*@flags: futex flags (FLAGS_SHARED, FLAGS_CLOCKRT, etc