Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Must be called with "mtx" held.

Proto:static int ep_insert(struct eventpoll *ep, const struct epoll_event *event, struct file *tfile, int fd, int full_check)

Type:int

Parameter:

TypeParameterName
struct eventpoll *ep
const struct epoll_event *event
struct file *tfile
intfd
intfull_check
1478  pwake = 0
1484  lockdep_assert_irqs_enabled()
1486  user_watches = atomic_long_read( & The number of file descriptors currently watched )
1487  If Value for the false possibility is greater at compile time(user_watches >= Maximum number of epoll watched descriptors, per user ) Then Return -ENOSPC
1489  If Not (epi = kmem_cache_alloc(Slab cache used to allocate "struct epitem" , GFP_KERNEL)) Then Return -ENOMEM
1493  Initialization list head
1494  Initialization list head
1495  Initialization list head
1496  The "container" of this item = ep
1497  Setup the structure that is used as key for the RB tree
1498  The structure that describe the interested events and the source fd = event
1499  Number of active wait queue attached to poll operations = 0
1500  Works together "struct eventpoll"->ovflist in keeping the* single linked chain of items. = EP_UNACTIVE_PTR
1501  If events & Request the handling of system wakeup events so as to prevent system suspends* from happening while those events are being processed Then
1502  error = ep_create_wakeup_source(epi)
1503  If error Then Go to error_create_wakeup_source
1505  Else
1506  RCU_INIT_POINTER() - initialize an RCU protected pointer*@p: The pointer to be initialized.*@v: The value to initialized the pointer to.* Initialize an RCU-protected pointer in special cases where readers(wakeup_source used when EPOLLWAKEUP is set , NULL)
1510  epi = epi
1511  init_poll_funcptr( & pt, ep_ptable_queue_proc)
1520  revents = Differs from ep_eventpoll_poll() in that internal callers already have* the ep->mtx so we need to start from depth=1, such that mutex_lock_nested()* is correctly annotated.
1527  error = -ENOMEM
1528  If Number of active wait queue attached to poll operations < 0 Then Go to error_unregister
1532  spin_lock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
1533  list_add_tail_rcu - add a new entry to rcu-protected list*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head
1534  spin_unlock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
1540  ep_rbtree_insert(ep, epi)
1543  error = -EINVAL
1544  If full_check && verse_path_check - The tfile_check_list is list of file *, which have* links that are proposed to be newly added Then Go to error_remove_epi
1548  write_lock_irq( & Lock which protects rdllist and ovflist )
1551  ep_set_busy_poll_napi_id(epi)
1554  If revents && Not Tells us if the item is currently linked Then
1555  list_add_tail - add a new entry*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head.* This is useful for implementing queues.
1556  all only when ep->mtx is held
1559  If waitqueue_active -- locklessly test for waiters on the queue*@wq_head: the waitqueue to test for waiters* returns true if the wait list is not empty* NOTE: this function is lockless and requires care, incorrect usage _will_ Then wake_up( & Wait queue used by sys_epoll_wait() )
1561  If waitqueue_active -- locklessly test for waiters on the queue*@wq_head: the waitqueue to test for waiters* returns true if the wait list is not empty* NOTE: this function is lockless and requires care, incorrect usage _will_ Then pwake++
1565  write_unlock_irq( & Lock which protects rdllist and ovflist )
1567  atomic_long_inc( & The number of file descriptors currently watched )
1570  If pwake Then ep_poll_safewake( & Wait queue used by file->poll() )
1573  Return 0
1575  error_remove_epi :
1576  spin_lock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
1577  list_del_rcu - deletes entry from list without re-initialization*@entry: the element to delete from the list
1578  spin_unlock( & * Protects f_ep_links, f_flags. * Must not be taken from IRQ context.)
1580  rb_erase_cached( & RB tree node links this structure to the eventpoll RB tree , & RB tree root used to store monitored fd structs )
1582  error_unregister :
1583  This function unregisters poll callbacks from the associated file* descriptor. Must be called with "mtx" held (or "epmutex" if called from* ep_free).
1591  write_lock_irq( & Lock which protects rdllist and ovflist )
1592  If Tells us if the item is currently linked Then list_del_init - deletes entry from list and reinitialize it.*@entry: the element to delete from the list.
1594  write_unlock_irq( & Lock which protects rdllist and ovflist )
1596  wakeup_source_unregister(all only when ep->mtx is held )
1598  error_create_wakeup_source :
1599  kmem_cache_free(Slab cache used to allocate "struct epitem" , epi)
1601  Return error
Caller
NameDescribe
SYSCALL_DEFINE4The following function implements the controller interface for* the eventpoll file that enables the insertion/removal/change of* file descriptors inside the interest set.