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:p_poll - Retrieves ready events, and delivers them to the caller supplied* event buffer.*@ep: Pointer to the eventpoll context.*@events: Pointer to the userspace buffer where the ready events should be* stored.

Proto:static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, int maxevents, long timeout)

Type:int

Parameter:

TypeParameterName
struct eventpoll *ep
struct epoll_event __user *events
intmaxevents
longtimeout
1807  res = 0 , timed_out = 0
1808  slack = 0
1809  bool waiter = false
1811  ktime_t expires, * to = NULL
1813  lockdep_assert_irqs_enabled()
1815  If timeout > 0 Then
1816  end_time = ep_set_mstimeout(timeout)
1818  slack = select_estimate_accuracy( & end_time)
1819  to = expires
1820  to = vert a timespec64 to ktime_t format:
1821  Else if timeout == 0 Then
1829  timed_out = 1
1831  write_lock_irq( & Lock which protects rdllist and ovflist )
1832  eavail = p_events_available - Checks if ready events might be available.*@ep: Pointer to the eventpoll context.* Returns: Returns a value different than zero if ready events are available,* or zero otherwise.
1833  write_unlock_irq( & Lock which protects rdllist and ovflist )
1835  Go to send_events
1838  fetch_events :
1840  If Not p_events_available - Checks if ready events might be available.*@ep: Pointer to the eventpoll context.* Returns: Returns a value different than zero if ready events are available,* or zero otherwise. Then ep_busy_loop(ep, timed_out)
1843  eavail = p_events_available - Checks if ready events might be available.*@ep: Pointer to the eventpoll context.* Returns: Returns a value different than zero if ready events are available,* or zero otherwise.
1844  If eavail Then Go to send_events
1852  ep_reset_busy_poll_napi_id(ep)
1859  If Not waiter Then
1860  waiter = true
1861  init_waitqueue_entry( & wait, current process)
1863  spin_lock_irq( & lock)
1864  Used for wake-one threads:
1865  spin_unlock_irq( & lock)
1868  cycle
1874  set_current_state(TASK_INTERRUPTIBLE)
1882  res = -EINTR
1883  Break
1886  eavail = p_events_available - Checks if ready events might be available.*@ep: Pointer to the eventpoll context.* Returns: Returns a value different than zero if ready events are available,* or zero otherwise.
1887  If eavail Then Break
1890  res = -EINTR
1891  Break
1895  timed_out = 1
1896  Break
1900  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: )
1902  send_events :
1908  If Not res && eavail && Not (res = ep_send_events(ep, events, maxevents)) && Not timed_out Then Go to fetch_events
1912  If waiter Then
1913  spin_lock_irq( & lock)
1914  __remove_wait_queue( & Wait queue used by sys_epoll_wait() , & wait)
1915  spin_unlock_irq( & lock)
1918  Return res
Caller
NameDescribe
do_epoll_waitImplement the event wait interface for the eventpoll file. It is the kernel* part of the user space epoll_wait(2).