tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c- Extension
.c- Size
- 2627 bytes
- Lines
- 171
- 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_tracing.hbpf/bpf_helpers.hbpf_misc.hcgrp_kfunc_common.hcpumask_common.htask_kfunc_common.h
Detected Declarations
function task_kfunc_load_testfunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction cgrp_kfunc_load_testfunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction cpumask_kfunc_load_testfunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction BPF_PROG
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
#include <vmlinux.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
#include "cgrp_kfunc_common.h"
#include "cpumask_common.h"
#include "task_kfunc_common.h"
char _license[] SEC("license") = "GPL";
/***************
* Task kfuncs *
***************/
static void task_kfunc_load_test(void)
{
struct task_struct *current, *ref_1, *ref_2;
current = bpf_get_current_task_btf();
ref_1 = bpf_task_from_pid(current->pid);
if (!ref_1)
return;
ref_2 = bpf_task_acquire(ref_1);
if (ref_2)
bpf_task_release(ref_2);
bpf_task_release(ref_1);
}
SEC("raw_tp")
__success
int BPF_PROG(task_kfunc_raw_tp)
{
task_kfunc_load_test();
return 0;
}
SEC("syscall")
__success
int BPF_PROG(task_kfunc_syscall)
{
task_kfunc_load_test();
return 0;
}
SEC("tracepoint")
__success
int BPF_PROG(task_kfunc_tracepoint)
{
task_kfunc_load_test();
return 0;
}
SEC("perf_event")
__success
int BPF_PROG(task_kfunc_perf_event)
{
task_kfunc_load_test();
return 0;
}
/*****************
* cgroup kfuncs *
*****************/
static void cgrp_kfunc_load_test(void)
{
struct cgroup *cgrp, *ref;
cgrp = bpf_cgroup_from_id(0);
if (!cgrp)
return;
ref = bpf_cgroup_acquire(cgrp);
if (!ref) {
bpf_cgroup_release(cgrp);
return;
}
bpf_cgroup_release(ref);
bpf_cgroup_release(cgrp);
}
SEC("raw_tp")
__success
int BPF_PROG(cgrp_kfunc_raw_tp)
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_tracing.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`, `cgrp_kfunc_common.h`, `cpumask_common.h`, `task_kfunc_common.h`.
- Detected declarations: `function task_kfunc_load_test`, `function BPF_PROG`, `function BPF_PROG`, `function BPF_PROG`, `function BPF_PROG`, `function cgrp_kfunc_load_test`, `function BPF_PROG`, `function BPF_PROG`, `function BPF_PROG`, `function BPF_PROG`.
- 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.