io_uring/fdinfo.c
Source file repositories/reference/linux-study-clean/io_uring/fdinfo.c
File Facts
- System
- Linux kernel
- Corpus path
io_uring/fdinfo.c- Extension
.c- Size
- 7705 bytes
- Lines
- 273
- Domain
- Kernel Services
- Bucket
- io_uring
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/errno.hlinux/fs.hlinux/file.hlinux/proc_fs.hlinux/seq_file.hlinux/nospec.hlinux/io_uring.huapi/linux/io_uring.hfiletable.hsqpoll.hfdinfo.hcancel.hrsrc.hopdef.h
Detected Declarations
function common_tracking_show_fdinfofunction napi_show_fdinfofunction napi_show_fdinfofunction io_uring_show_fdinfo
Annotated Snippet
if (sq_shift) {
sqe128 = true;
} else if (io_issue_defs[opcode].is_128) {
if (!(ctx->flags & IORING_SETUP_SQE_MIXED)) {
seq_printf(m,
"%5u: invalid sqe, 128B entry on non-mixed sq\n",
sq_idx);
break;
}
if (sq_idx == sq_mask) {
seq_printf(m,
"%5u: corrupted sqe, wrapping 128B entry\n",
sq_idx);
break;
}
sq_head++;
i++;
sqe128 = true;
}
seq_printf(m, "%5u: opcode:%s, fd:%d, flags:%x, off:%llu, "
"addr:0x%llx, rw_flags:0x%x, buf_index:%d "
"user_data:%llu",
sq_idx, io_uring_get_opcode(opcode), sqe->fd,
sqe->flags, (unsigned long long) sqe->off,
(unsigned long long) sqe->addr, sqe->rw_flags,
sqe->buf_index, sqe->user_data);
if (sqe128) {
u64 *sqeb = (void *) (sqe + 1);
int size = sizeof(struct io_uring_sqe) / sizeof(u64);
int j;
for (j = 0; j < size; j++) {
seq_printf(m, ", e%d:0x%llx", j,
(unsigned long long) *sqeb);
sqeb++;
}
}
seq_printf(m, "\n");
cond_resched();
}
seq_printf(m, "CQEs:\t%u\n", cq_tail - cq_head);
cq_entries = min(cq_tail - cq_head, ctx->cq_entries);
for (i = 0; i < cq_entries; i++) {
struct io_uring_cqe *cqe;
bool cqe32 = false;
cqe = &r->cqes[(cq_head & cq_mask)];
if (cqe->flags & IORING_CQE_F_32 || ctx->flags & IORING_SETUP_CQE32)
cqe32 = true;
seq_printf(m, "%5u: user_data:%llu, res:%d, flags:%x",
cq_head & cq_mask, cqe->user_data, cqe->res,
cqe->flags);
if (cqe32)
seq_printf(m, ", extra1:%llu, extra2:%llu",
cqe->big_cqe[0], cqe->big_cqe[1]);
seq_printf(m, "\n");
cq_head++;
if (cqe32) {
cq_head++;
i++;
}
cond_resched();
}
if (ctx->flags & IORING_SETUP_SQPOLL) {
struct io_sq_data *sq = ctx->sq_data;
struct task_struct *tsk;
rcu_read_lock();
tsk = rcu_dereference(sq->thread);
/*
* sq->thread might be NULL if we raced with the sqpoll
* thread termination.
*/
if (tsk) {
u64 usec;
get_task_struct(tsk);
rcu_read_unlock();
usec = io_sq_cpu_usec(tsk);
sq_pid = task_pid_nr_ns(tsk,
proc_pid_ns(file_inode(m->file)->i_sb));
put_task_struct(tsk);
sq_cpu = sq->sq_cpu;
sq_total_time = usec;
sq_work_time = sq->work_time;
} else {
rcu_read_unlock();
}
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/fs.h`, `linux/file.h`, `linux/proc_fs.h`, `linux/seq_file.h`, `linux/nospec.h`, `linux/io_uring.h`.
- Detected declarations: `function common_tracking_show_fdinfo`, `function napi_show_fdinfo`, `function napi_show_fdinfo`, `function io_uring_show_fdinfo`.
- Atlas domain: Kernel Services / io_uring.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.