kernel/bpf/dmabuf_iter.c
Source file repositories/reference/linux-study-clean/kernel/bpf/dmabuf_iter.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/bpf/dmabuf_iter.c- Extension
.c- Size
- 4404 bytes
- Lines
- 193
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hlinux/btf_ids.hlinux/dma-buf.hlinux/kernel.hlinux/seq_file.h
Detected Declarations
struct dmabuf_iter_privstruct bpf_iter__dmabufstruct bpf_iter_dmabufstruct bpf_iter_dmabuf_kernfunction __dmabuf_seq_showfunction dmabuf_iter_seq_showfunction dmabuf_iter_seq_stopfunction bpf_iter_dmabuf_show_fdinfofunction dmabuf_iter_seq_initfunction dmabuf_iter_seq_finifunction dmabuf_iter_initfunction bpf_iter_dmabuf_newfunction bpf_iter_dmabuf_destroy
Annotated Snippet
struct dmabuf_iter_priv {
/*
* If this pointer is non-NULL, the buffer's refcount is elevated to
* prevent destruction between stop/start. If reading is not resumed and
* start is never called again, then dmabuf_iter_seq_fini drops the
* reference when the iterator is released.
*/
struct dma_buf *dmabuf;
};
static void *dmabuf_iter_seq_start(struct seq_file *seq, loff_t *pos)
{
struct dmabuf_iter_priv *p = seq->private;
if (*pos) {
struct dma_buf *dmabuf = p->dmabuf;
if (!dmabuf)
return NULL;
/*
* Always resume from where we stopped, regardless of the value
* of pos.
*/
p->dmabuf = NULL;
return dmabuf;
}
return dma_buf_iter_begin();
}
static void *dmabuf_iter_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct dma_buf *dmabuf = v;
++*pos;
return dma_buf_iter_next(dmabuf);
}
struct bpf_iter__dmabuf {
__bpf_md_ptr(struct bpf_iter_meta *, meta);
__bpf_md_ptr(struct dma_buf *, dmabuf);
};
static int __dmabuf_seq_show(struct seq_file *seq, void *v, bool in_stop)
{
struct bpf_iter_meta meta = {
.seq = seq,
};
struct bpf_iter__dmabuf ctx = {
.meta = &meta,
.dmabuf = v,
};
struct bpf_prog *prog = bpf_iter_get_info(&meta, in_stop);
if (prog)
return bpf_iter_run_prog(prog, &ctx);
return 0;
}
static int dmabuf_iter_seq_show(struct seq_file *seq, void *v)
{
return __dmabuf_seq_show(seq, v, false);
}
static void dmabuf_iter_seq_stop(struct seq_file *seq, void *v)
{
struct dma_buf *dmabuf = v;
if (dmabuf) {
struct dmabuf_iter_priv *p = seq->private;
p->dmabuf = dmabuf;
}
}
static const struct seq_operations dmabuf_iter_seq_ops = {
.start = dmabuf_iter_seq_start,
.next = dmabuf_iter_seq_next,
.stop = dmabuf_iter_seq_stop,
.show = dmabuf_iter_seq_show,
};
static void bpf_iter_dmabuf_show_fdinfo(const struct bpf_iter_aux_info *aux,
struct seq_file *seq)
{
seq_puts(seq, "dmabuf iter\n");
}
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/btf_ids.h`, `linux/dma-buf.h`, `linux/kernel.h`, `linux/seq_file.h`.
- Detected declarations: `struct dmabuf_iter_priv`, `struct bpf_iter__dmabuf`, `struct bpf_iter_dmabuf`, `struct bpf_iter_dmabuf_kern`, `function __dmabuf_seq_show`, `function dmabuf_iter_seq_show`, `function dmabuf_iter_seq_stop`, `function bpf_iter_dmabuf_show_fdinfo`, `function dmabuf_iter_seq_init`, `function dmabuf_iter_seq_fini`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.