函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:Must be called with "mtx" held.

函数原型:static int ep_insert(struct eventpoll *ep, const struct epoll_event *event, struct file *tfile, int fd, int full_check)

返回类型:int

参数:

类型参数名称
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  如果此条件成立可能性小(为编译器优化)(user_watches >= Maximum number of epoll watched descriptors, per user )则返回:负ENOSPC
1489  如果非epi等于分配高速缓存区则返回:负ENOMEM
1493  初始化链表头
1494  初始化链表头
1495  初始化链表头
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  如果events按位与Request the handling of system wakeup events so as to prevent system suspends* from happening while those events are being processed
1502  error等于ep_create_wakeup_source(epi)
1503  如果error则转到:error_create_wakeup_source
1505  否则
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  如果Number of active wait queue attached to poll operations 小于0则转到:error_unregister
1532  加自旋锁
1533  添加RCU链表项
1534  自旋锁解锁
1540  ep_rbtree_insert(ep, epi)
1543  error等于负EINVAL
1544  如果full_checkverse_path_check - The tfile_check_list is list of file *, which have* links that are proposed to be newly added则转到:error_remove_epi
1548  write_lock_irq( & Lock which protects rdllist and ovflist )
1551  ep_set_busy_poll_napi_id(epi)
1554  如果revents且非Tells us if the item is currently linked
1555  添加链表项
1556  all only when ep->mtx is held
1559  如果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_wake_up( & Wait queue used by sys_epoll_wait() )
1561  如果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_pwake自加
1565  write_unlock_irq( & Lock which protects rdllist and ovflist )
1567  atomic_long_inc( & The number of file descriptors currently watched )
1570  如果pwakeep_poll_safewake( & Wait queue used by file->poll() )
1573  返回:0
1575  error_remove_epi :
1576  加自旋锁
1577  删除不需要重新初始化的列表项
1578  自旋锁解锁
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  如果Tells us if the item is currently linked 删除链表项并重新初始化
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  返回:error
调用者
名称描述
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.