Skip to content

Sberm/sberf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docs website version

Sberf

Profiling/tracing/visualization tool based on eBPF

Quick start

Download the newest version in Releases

Usage

sudo ./sberf record <PID1>,<PID2>
# sudo ./sberf record 1001
# sudo ./sberf record 1001,32847
  Usage:

    sberf record [options]

  Options:

    -p[--pid]: Record running time
    -t[--tracepoint]: Record tracepoints' triggered time
    -s[--syscall]: Record stack traces when a syscall is triggered
    -m[--memory]: Record memory usage
    -op[--off-cpu]: Record OFF-CPU time
    -h[--help]: Print this help message

    -f: Frequency in Hz
    -np: No plotting, print the stacks instead
    -a: Record all processes
    -o: File name for the plot

Compilation

  1. Install bpftool
git clone https://github.com/libbpf/bpftool.git
cd src
make
make install
  1. Install libbpf
git clone https://github.com/libbpf/libbpf.git
cd src
make
make install
  1. Install Clang
# ubuntu
sudo apt-get install clang

# centos
sudo yum install clang
  1. Clone this repo
git clone https://github.com/Sberm/sberf.git
cd sberf
  1. Generate vmlinux.h
# generate vmlinux.h file to vmlinux folder
bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux/vmlinux.h
  1. Make
# mute
make

# verbose message
DEBUG=1 make

Files & their uses

bpf.c Programs that run on eBPF virtual machine

.c Regular c programs

Makefile compilation pipeline

# *.bpf.c: eBPF-c files
# *.bpf.o: eBPF target file generated by clang and bpftool (in the build_bpf folder)
# *.skel.h: skeleton header generated by bpftool, such as sberf.skel.h (in the build_bpf folder)
# *.c: regular c file, calling eBPF virtual machine through include skeleton header 
# *.o: through CC, link all regular .o files to generate sberf executable file
#
# bpf.c --Clang--> bpf.tmp.o --bpftool--> bpf.o --bpftool--> skel.h
#                                                               \_ .c --gcc--> .o
#                                                                               \_ sberf