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.

Dependency Surface

Detected Declarations

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

Implementation Notes