Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:eventfd_read

Proto:static ssize_t eventfd_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
char __user *buf
size_tcount
loff_t *ppos
222  ctx = needed for tty driver, and maybe others
224  ucnt = 0
225  DECLARE_WAITQUEUE(wait, current process)
227  If count < size of ucnt Then Return -EINVAL
230  spin_lock_irq( & lock)
231  res = -EAGAIN
232  If * Every time that a write(2) is performed on an eventfd, the * value of the __u64 being written is added to "count" and a * wakeup is performed on "wqh". A read(2) will return the "count" * value to userspace, and will reset "count" to zero. The kernel * s > 0 Then res = size of ucnt
234  Else if Not (f_flags & O_NONBLOCK) Then
235  __add_wait_queue( & wqh, & wait)
236  cycle
239  res = size of ucnt
240  Break
246  spin_unlock_irq( & lock)
247  schedule()
248  spin_lock_irq( & lock)
250  __remove_wait_queue( & wqh, & wait)
251  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: )
253  If Value is more likely to compile time(res > 0) Then
254  eventfd_ctx_do_read(ctx, & ucnt)
255  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_locked_poll( & wqh, EPOLLOUT)
258  spin_unlock_irq( & lock)
260  If res > 0 && Write a simple value into user space(ucnt, (__u64__user * )buf) Then Return -EFAULT
263  Return res