io_uring/bpf-ops.c
Source file repositories/reference/linux-study-clean/io_uring/bpf-ops.c
File Facts
- System
- Linux kernel
- Corpus path
io_uring/bpf-ops.c- Extension
.c- Size
- 6185 bytes
- Lines
- 274
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mutex.hlinux/bpf.hlinux/bpf_verifier.hio_uring.hregister.hloop.hmemmap.hbpf-ops.h
Detected Declarations
function bpf_io_uring_submit_sqesfunction io_bpf_ops__loop_stepfunction bpf_io_is_valid_accessfunction bpf_io_btf_struct_accessfunction io_lookup_struct_typefunction bpf_io_initfunction bpf_io_check_memberfunction bpf_io_init_memberfunction io_install_bpffunction bpf_io_regfunction scoped_guardfunction io_eject_bpffunction bpf_io_unregfunction io_unregister_bpf_opsfunction io_uring_bpf_init
Annotated Snippet
#include <linux/mutex.h>
#include <linux/bpf.h>
#include <linux/bpf_verifier.h>
#include "io_uring.h"
#include "register.h"
#include "loop.h"
#include "memmap.h"
#include "bpf-ops.h"
static DEFINE_MUTEX(io_bpf_ctrl_mutex);
static const struct btf_type *loop_params_type;
__bpf_kfunc_start_defs();
__bpf_kfunc int bpf_io_uring_submit_sqes(struct iou_ctx *loop_ctx, u32 nr)
{
struct io_ring_ctx *ctx = io_loop_demangle_ctx(loop_ctx);
return io_submit_sqes(ctx, nr);
}
__bpf_kfunc
__u8 *bpf_io_uring_get_region(struct iou_ctx *loop_ctx, __u32 region_id,
const size_t rdwr_buf_size)
{
struct io_ring_ctx *ctx = io_loop_demangle_ctx(loop_ctx);
struct io_mapped_region *r;
lockdep_assert_held(&ctx->uring_lock);
switch (region_id) {
case IOU_REGION_MEM:
r = &ctx->param_region;
break;
case IOU_REGION_CQ:
r = &ctx->ring_region;
break;
case IOU_REGION_SQ:
r = &ctx->sq_region;
break;
default:
return NULL;
}
if (unlikely(rdwr_buf_size > io_region_size(r)))
return NULL;
return io_region_get_ptr(r);
}
__bpf_kfunc_end_defs();
BTF_KFUNCS_START(io_uring_kfunc_set)
BTF_ID_FLAGS(func, bpf_io_uring_submit_sqes, KF_SLEEPABLE);
BTF_ID_FLAGS(func, bpf_io_uring_get_region, KF_RET_NULL);
BTF_KFUNCS_END(io_uring_kfunc_set)
static const struct btf_kfunc_id_set bpf_io_uring_kfunc_set = {
.owner = THIS_MODULE,
.set = &io_uring_kfunc_set,
};
static int io_bpf_ops__loop_step(struct iou_ctx *ctx,
struct iou_loop_params *lp)
{
return IOU_LOOP_STOP;
}
static struct io_uring_bpf_ops io_bpf_ops_stubs = {
.loop_step = io_bpf_ops__loop_step,
};
static bool bpf_io_is_valid_access(int off, int size,
enum bpf_access_type type,
const struct bpf_prog *prog,
struct bpf_insn_access_aux *info)
{
if (type != BPF_READ)
return false;
if (off < 0 || off >= sizeof(__u64) * MAX_BPF_FUNC_ARGS)
return false;
if (off % size != 0)
return false;
return btf_ctx_access(off, size, type, prog, info);
}
static int bpf_io_btf_struct_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg, int off,
int size)
Annotation
- Immediate include surface: `linux/mutex.h`, `linux/bpf.h`, `linux/bpf_verifier.h`, `io_uring.h`, `register.h`, `loop.h`, `memmap.h`, `bpf-ops.h`.
- Detected declarations: `function bpf_io_uring_submit_sqes`, `function io_bpf_ops__loop_step`, `function bpf_io_is_valid_access`, `function bpf_io_btf_struct_access`, `function io_lookup_struct_type`, `function bpf_io_init`, `function bpf_io_check_member`, `function bpf_io_init_member`, `function io_install_bpf`, `function bpf_io_reg`.
- Atlas domain: Kernel Services / io_uring.
- Implementation status: source implementation candidate.
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.