Lines Matching +full:libbpf +full:- +full:tools
1 // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
4 // Based on cpufreq(8) from BPF-Perf-Tools-Book by Brendan Gregg.
5 // 10-OCT-2020 Wenbo Zhang Created this.
14 #include <bpf/libbpf.h>
25 .duration = -1,
31 "https://github.com/iovisor/bcc/tree/master/libbpf-tools";
33 "Sampling CPU freq system-wide & by process. Ctrl-C to end.\n"
35 "USAGE: cpufreq [--help] [-d DURATION] [-f FREQUENCY]\n"
39 " cpufreq -d 5 # sample for 5 seconds only\n"
40 " cpufreq -f 199 # sample CPU freq at 199HZ\n";
95 fd = syscall(__NR_perf_event_open, &attr, -1, i, -1, 0); in open_and_attach_perf_event()
102 return -1; in open_and_attach_perf_event()
108 return -1; in open_and_attach_perf_event()
141 return -1; in init_freqs_hmz()
147 return -1; in init_freqs_hmz()
175 print_linear_hist(bss->syswide.slots, MAX_SLOTS, 0, HIST_STEP_SIZE, in print_linear_hists()
200 strerror(-nr_cpus)); in main()
215 if (!obj->bss) { in main()
216 …fprintf(stderr, "Memory-mapping BPF maps is supported starting from Linux 5.7, please upgrade.\n"); in main()
220 err = init_freqs_hmz(obj->bss->freqs_mhz, nr_cpus); in main()
226 err = open_and_attach_perf_event(env.freq, obj->progs.do_sample, links); in main()
236 printf("Sampling CPU freq system-wide & by process. Ctrl-C to end.\n"); in main()
241 * We'll get sleep interrupted when someone presses Ctrl-C (which will in main()
247 print_linear_hists(obj->maps.hists, obj->bss); in main()