Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:eventfd_write

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

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
const char __user *buf
size_tcount
loff_t *ppos
269  ctx = needed for tty driver, and maybe others
272  DECLARE_WAITQUEUE(wait, current process)
274  If count < size of ucnt Then Return -EINVAL
276  If copy_from_user( & ucnt, buf, size of ucnt ) Then Return -EFAULT
278  If ucnt == ULLONG_MAX Then Return -EINVAL
280  spin_lock_irq( & lock)
281  res = -EAGAIN
282  If ULLONG_MAX - * 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 > ucnt Then res = size of ucnt
284  Else if Not (f_flags & O_NONBLOCK) Then
285  __add_wait_queue( & wqh, & wait)
286  cycle
289  res = size of ucnt
290  Break
296  spin_unlock_irq( & lock)
297  schedule()
298  spin_lock_irq( & lock)
300  __remove_wait_queue( & wqh, & wait)
301  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: )
303  If Value is more likely to compile time(res > 0) Then
304  * 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 += ucnt
305  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, Epoll event masks )
308  spin_unlock_irq( & lock)
310  Return res