tools/testing/selftests/bpf/progs/iters_testmod_seq.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/iters_testmod_seq.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/iters_testmod_seq.c- Extension
.c- Size
- 2930 bytes
- Lines
- 130
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf_misc.h
Detected Declarations
struct bpf_iter_testmod_seqfunction __log_levelfunction __log_levelfunction __log_levelfunction bpf_for_eachfunction __msgfunction __msgfunction __retval
Annotated Snippet
struct bpf_iter_testmod_seq {
u64 :64;
u64 :64;
};
extern int bpf_iter_testmod_seq_new(struct bpf_iter_testmod_seq *it, s64 value, int cnt) __ksym;
extern s64 *bpf_iter_testmod_seq_next(struct bpf_iter_testmod_seq *it) __ksym;
extern s64 bpf_iter_testmod_seq_value(int blah, struct bpf_iter_testmod_seq *it) __ksym;
extern void bpf_iter_testmod_seq_destroy(struct bpf_iter_testmod_seq *it) __ksym;
const volatile __s64 exp_empty = 0 + 1;
__s64 res_empty;
SEC("raw_tp/sys_enter")
__success __log_level(2)
__msg("fp-16=iter_testmod_seq(id=1,state=active,depth=0)")
__msg("fp-16=iter_testmod_seq(id=1,state=drained,depth=0)")
__msg("call bpf_iter_testmod_seq_destroy")
int testmod_seq_empty(const void *ctx)
{
__s64 sum = 0, *i;
bpf_for_each(testmod_seq, i, 1000, 0) sum += *i;
res_empty = 1 + sum;
return 0;
}
const volatile __s64 exp_full = 1000000;
__s64 res_full;
SEC("raw_tp/sys_enter")
__success __log_level(2)
__msg("fp-16=iter_testmod_seq(id=1,state=active,depth=0)")
__msg("fp-16=iter_testmod_seq(id=1,state=drained,depth=0)")
__msg("call bpf_iter_testmod_seq_destroy")
int testmod_seq_full(const void *ctx)
{
__s64 sum = 0, *i;
bpf_for_each(testmod_seq, i, 1000, 1000) sum += *i;
res_full = sum;
return 0;
}
const volatile __s64 exp_truncated = 10 * 1000000;
__s64 res_truncated;
static volatile int zero = 0;
SEC("raw_tp/sys_enter")
__success __log_level(2)
__msg("fp-16=iter_testmod_seq(id=1,state=active,depth=0)")
__msg("fp-16=iter_testmod_seq(id=1,state=drained,depth=0)")
__msg("call bpf_iter_testmod_seq_destroy")
int testmod_seq_truncated(const void *ctx)
{
__s64 sum = 0, *i;
int cnt = zero;
bpf_for_each(testmod_seq, i, 10, 2000000) {
sum += *i;
cnt++;
if (cnt >= 1000000)
break;
}
res_truncated = sum;
return 0;
}
SEC("?raw_tp")
__failure
__msg("expected an initialized iter_testmod_seq as R2")
int testmod_seq_getter_before_bad(const void *ctx)
{
struct bpf_iter_testmod_seq it;
return bpf_iter_testmod_seq_value(0, &it);
}
SEC("?raw_tp")
__failure
__msg("expected an initialized iter_testmod_seq as R2")
int testmod_seq_getter_after_bad(const void *ctx)
{
struct bpf_iter_testmod_seq it;
s64 sum = 0, *v;
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `struct bpf_iter_testmod_seq`, `function __log_level`, `function __log_level`, `function __log_level`, `function bpf_for_each`, `function __msg`, `function __msg`, `function __retval`.
- Atlas domain: Support Tooling And Documentation / tools.
- 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.