tools/perf/util/bpf_trace_augment.c
Source file repositories/reference/linux-study-clean/tools/perf/util/bpf_trace_augment.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/bpf_trace_augment.c- Extension
.c- Size
- 3259 bytes
- Lines
- 144
- 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
bpf/libbpf.hinternal/xyarray.hutil/debug.hutil/evlist.hutil/trace_augment.hbpf_skel/augmented_raw_syscalls.skel.h
Detected Declarations
function augmented_syscalls__preparefunction augmented_syscalls__create_bpf_outputfunction augmented_syscalls__setup_bpf_outputfunction augmented_syscalls__set_filter_pidsfunction augmented_syscalls__get_map_fdsfunction bpf_object__for_each_programfunction augmented_syscalls__cleanup
Annotated Snippet
#include <bpf/libbpf.h>
#include <internal/xyarray.h>
#include "util/debug.h"
#include "util/evlist.h"
#include "util/trace_augment.h"
#include "bpf_skel/augmented_raw_syscalls.skel.h"
static struct augmented_raw_syscalls_bpf *skel;
static struct evsel *bpf_output;
int augmented_syscalls__prepare(void)
{
struct bpf_program *prog;
char buf[128];
int err;
skel = augmented_raw_syscalls_bpf__open();
if (!skel) {
pr_debug("Failed to open augmented syscalls BPF skeleton\n");
return -errno;
}
/*
* Disable attaching the BPF programs except for sys_enter and
* sys_exit that tail call into this as necessary.
*/
bpf_object__for_each_program(prog, skel->obj) {
if (prog != skel->progs.sys_enter && prog != skel->progs.sys_exit)
bpf_program__set_autoattach(prog, /*autoattach=*/false);
}
err = augmented_raw_syscalls_bpf__load(skel);
if (err < 0) {
libbpf_strerror(err, buf, sizeof(buf));
pr_debug("Failed to load augmented syscalls BPF skeleton: %s\n", buf);
return err;
}
augmented_raw_syscalls_bpf__attach(skel);
return 0;
}
int augmented_syscalls__create_bpf_output(struct evlist *evlist)
{
int err = parse_event(evlist, "bpf-output/no-inherit=1,name=__augmented_syscalls__/");
if (err) {
pr_err("ERROR: Setup BPF output event failed: %d\n", err);
return err;
}
bpf_output = evlist__last(evlist);
assert(evsel__name_is(bpf_output, "__augmented_syscalls__"));
return 0;
}
void augmented_syscalls__setup_bpf_output(void)
{
struct perf_cpu cpu;
unsigned int i;
if (bpf_output == NULL)
return;
/*
* Set up the __augmented_syscalls__ BPF map to hold for each
* CPU the bpf-output event's file descriptor.
*/
perf_cpu_map__for_each_cpu(cpu, i, bpf_output->core.cpus) {
int mycpu = cpu.cpu;
bpf_map__update_elem(skel->maps.__augmented_syscalls__,
&mycpu, sizeof(mycpu),
xyarray__entry(bpf_output->core.fd,
mycpu, 0),
sizeof(__u32), BPF_ANY);
}
}
int augmented_syscalls__set_filter_pids(unsigned int nr, pid_t *pids)
{
bool value = true;
int err = 0;
if (skel == NULL)
return 0;
Annotation
- Immediate include surface: `bpf/libbpf.h`, `internal/xyarray.h`, `util/debug.h`, `util/evlist.h`, `util/trace_augment.h`, `bpf_skel/augmented_raw_syscalls.skel.h`.
- Detected declarations: `function augmented_syscalls__prepare`, `function augmented_syscalls__create_bpf_output`, `function augmented_syscalls__setup_bpf_output`, `function augmented_syscalls__set_filter_pids`, `function augmented_syscalls__get_map_fds`, `function bpf_object__for_each_program`, `function augmented_syscalls__cleanup`.
- 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.