函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:eventfd_read

函数原型:static ssize_t eventfd_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)

返回类型:ssize_t

参数:

类型参数名称
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, 当前进程)
227  如果count小于ucnt的长度则返回:负EINVAL
230  spin_lock_irq( & lock)
231  res等于负EAGAIN
232  如果* 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则res等于ucnt的长度
234  否则如果非f_flags按位与O_NONBLOCK的值则
235  __add_wait_queue( & wqh, & wait)
236  循环
239  res等于ucnt的长度
240  退出
242  如果signal_pending(当前进程)则
246  spin_unlock_irq( & lock)
247  进程调度
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;* (就绪态)
253  如果此条件成立可能性大(为编译器优化)(res > 0)则
254  eventfd_ctx_do_read(ctx, & ucnt)
255  如果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_locked_poll( & wqh, EPOLLOUT)
258  spin_unlock_irq( & lock)
260  如果res大于0且put_user - Write a simple value into user space(ucnt, (__u64__user * )buf)则返回:负EFAULT
263  返回:res