include/linux/bpf_mprog.h
Source file repositories/reference/linux-study-clean/include/linux/bpf_mprog.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/bpf_mprog.h- Extension
.h- Size
- 9691 bytes
- Lines
- 354
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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.
- 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/bpf.h
Detected Declarations
struct bpf_mprog_fpstruct bpf_mprog_cpstruct bpf_mprog_entrystruct bpf_mprog_bundlestruct bpf_tuplefunction bpf_mprog_foreach_progfunction bpf_mprog_peerfunction bpf_mprog_bundle_initfunction bpf_mprog_incfunction bpf_mprog_decfunction bpf_mprog_maxfunction bpf_mprog_totalfunction bpf_mprog_existsfunction bpf_mprog_foreach_progfunction bpf_mprog_mark_for_releasefunction bpf_mprog_complete_releasefunction bpf_mprog_revision_newfunction bpf_mprog_commitfunction bpf_mprog_revisionfunction bpf_mprog_entry_copyfunction bpf_mprog_entry_clearfunction bpf_mprog_clear_allfunction bpf_mprog_entry_growfunction bpf_mprog_entry_shrinkfunction bpf_mprog_readfunction bpf_mprog_writefunction bpf_mprog_supportedfunction bpf_mprog_detach_empty
Annotated Snippet
struct bpf_mprog_fp {
struct bpf_prog *prog;
};
struct bpf_mprog_cp {
struct bpf_link *link;
};
struct bpf_mprog_entry {
struct bpf_mprog_fp fp_items[BPF_MPROG_MAX];
struct bpf_mprog_bundle *parent;
};
struct bpf_mprog_bundle {
struct bpf_mprog_entry a;
struct bpf_mprog_entry b;
struct bpf_mprog_cp cp_items[BPF_MPROG_MAX];
struct bpf_prog *ref;
atomic64_t revision;
u32 count;
};
struct bpf_tuple {
struct bpf_prog *prog;
struct bpf_link *link;
};
static inline struct bpf_mprog_entry *
bpf_mprog_peer(const struct bpf_mprog_entry *entry)
{
if (entry == &entry->parent->a)
return &entry->parent->b;
else
return &entry->parent->a;
}
static inline void bpf_mprog_bundle_init(struct bpf_mprog_bundle *bundle)
{
BUILD_BUG_ON(sizeof(bundle->a.fp_items[0]) > sizeof(u64));
BUILD_BUG_ON(ARRAY_SIZE(bundle->a.fp_items) !=
ARRAY_SIZE(bundle->cp_items));
memset(bundle, 0, sizeof(*bundle));
atomic64_set(&bundle->revision, 1);
bundle->a.parent = bundle;
bundle->b.parent = bundle;
}
static inline void bpf_mprog_inc(struct bpf_mprog_entry *entry)
{
entry->parent->count++;
}
static inline void bpf_mprog_dec(struct bpf_mprog_entry *entry)
{
entry->parent->count--;
}
static inline int bpf_mprog_max(void)
{
return ARRAY_SIZE(((struct bpf_mprog_entry *)NULL)->fp_items) - 1;
}
static inline int bpf_mprog_total(struct bpf_mprog_entry *entry)
{
int total = entry->parent->count;
WARN_ON_ONCE(total > bpf_mprog_max());
return total;
}
static inline bool bpf_mprog_exists(struct bpf_mprog_entry *entry,
struct bpf_prog *prog)
{
const struct bpf_mprog_fp *fp;
const struct bpf_prog *tmp;
bpf_mprog_foreach_prog(entry, fp, tmp) {
if (tmp == prog)
return true;
}
return false;
}
static inline void bpf_mprog_mark_for_release(struct bpf_mprog_entry *entry,
struct bpf_tuple *tuple)
{
WARN_ON_ONCE(entry->parent->ref);
if (!tuple->link)
entry->parent->ref = tuple->prog;
Annotation
- Immediate include surface: `linux/bpf.h`.
- Detected declarations: `struct bpf_mprog_fp`, `struct bpf_mprog_cp`, `struct bpf_mprog_entry`, `struct bpf_mprog_bundle`, `struct bpf_tuple`, `function bpf_mprog_foreach_prog`, `function bpf_mprog_peer`, `function bpf_mprog_bundle_init`, `function bpf_mprog_inc`, `function bpf_mprog_dec`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.