Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\select.c Create Date:2022-07-28 20:07:02
Last Modify:2020-03-18 10:25:38 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:do_select

Proto:static int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time)

Type:int

Parameter:

TypeParameterName
intn
fd_set_bits *fds
struct timespec64 *end_time
478  ktime_t expire, * to = NULL
481  timed_out = 0
482  slack = 0
483  busy_flag = If net_busy_loop_on() Then POLL_BUSY_LOOP Else 0
484  busy_start = 0
486  _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
487  retval = max_select_fd(n, fds)
488  _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()
490  If retval < 0 Then Return retval
492  n = retval
494  poll_initwait( & table)
495  wait = pt
496  If end_time && Not seconds && Not nanoseconds Then
497  _qproc = NULL
498  timed_out = 1
501  If end_time && Not timed_out Then slack = select_estimate_accuracy(end_time)
504  retval = 0
505  cycle
507  bool can_busy_loop = false
509  inp = in
509  outp = out
509  exp = ex
510  rinp = res_in
510  routp = res_out
510  rexp = res_ex
512  When i < n cycle
513  bit = 1
514  res_in = 0 , res_out = 0 , res_ex = 0
517  in = inp++
517  out = outp++
517  ex = exp++
518  all_bits = in | out | ex
519  If all_bits == 0 Then
520  i += BITS_PER_LONG
521  Continue
524  When j < BITS_PER_LONG cycle
526  If i >= n Then Break
528  If Not (bit & all_bits) Then Continue
530  f = fdget(i)
531  If file Then
534  mask = vfs_poll(file, wait)
536  fdput(f)
537  If mask & POLLIN_SET && in & bit Then
538  res_in |= bit
539  retval++
540  _qproc = NULL
542  If mask & POLLOUT_SET && out & bit Then
543  res_out |= bit
544  retval++
545  _qproc = NULL
547  If mask & POLLEX_SET && ex & bit Then
548  res_ex |= bit
549  retval++
550  _qproc = NULL
553  If retval Then
554  can_busy_loop = false
555  busy_flag = 0
561  Else if busy_flag & mask Then can_busy_loop = true
566  If res_in Then rinp = res_in
568  If res_out Then routp = res_out
570  If res_ex Then rexp = res_ex
572  cond_resched()
574  _qproc = NULL
575  If retval || timed_out || signal_pending(current process) Then Break
577  If error Then
578  retval = error
579  Break
583  If can_busy_loop && Not need_resched() Then
584  If Not busy_start Then
586  Continue
591  busy_flag = 0
598  If end_time && Not to Then
600  to = expire
603  If Not poll_schedule_timeout( & table, TASK_INTERRUPTIBLE, to, slack) Then timed_out = 1
608  poll_freewait( & table)
610  Return retval
Caller
NameDescribe
core_sys_selectWe can actually return ERESTARTSYS instead of EINTR, but I'd* like to be certain this leads to no problems. So I return* EINTR just for safety.* Update: ERESTARTSYS breaks at least the xview clock binary, so
compat_core_sys_selectWe can actually return ERESTARTSYS instead of EINTR, but I'd* like to be certain this leads to no problems. So I return* EINTR just for safety.* Update: ERESTARTSYS breaks at least the xview clock binary, so