### Run Syscall Example - Client Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/minimal/README.md This command starts the syscall example client, connecting to a specified victim process. ```bash sudo ~/.bpftime/bpftime start -s example/minimal/victim ``` -------------------------------- ### Build the Example with CUDA Support Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/threadscheduling_dynamic_hook/README.md Build the bpftime example with CUDA support enabled. Ensure CUDA is installed and its root path is correctly specified. ```bash cmake -Bbuild -DBPFTIME_ENABLE_CUDA_ATTACH=1 -DBPFTIME_CUDA_ROOT=/usr/local/cuda . make -C build -j$(nproc) make -C example/gpu/threadscheduling_dynamic_hook ``` -------------------------------- ### Run Syscall Example - Client (AGENT_SO) Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/minimal/README.md This command starts the syscall example client, specifying the agent SO path and using a text segment transformer. ```bash sudo AGENT_SO=build/runtime/agent/libbpftime-agent.so LD_PRELOAD=build/attach/text_segment_transformer/libbpftime-agent-transformer.so example/minimal/victim ``` -------------------------------- ### Load and Start bpftime Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/CLAUDE.md Loads an eBPF program using the `bpftime` command and then starts a victim process to interact with it. Ensure `bpftime` is in your PATH. ```bash export PATH=$PATH:~/.bpftime/ ``` ```bash bpftime load ./example/malloc/malloc ``` ```bash bpftime start ./example/malloc/victim ``` -------------------------------- ### Build bpftime and Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/launchlate-kernel-gpu-shared-map/README.md Builds the main bpftime project with CUDA support and then compiles the specific example. Ensure CUDA is installed and its root path is correctly specified. ```bash # Navigate to the bpftime root directory cd bpftime # Build the main bpftime project first cmake -Bbuild -DBPFTIME_ENABLE_CUDA_ATTACH=1 -DBPFTIME_CUDA_ROOT=/usr/local/cuda . cmake --build build -j$(nproc) # Build the example make -C example/gpu/launchlate-kernel-gpu-shared-map ``` -------------------------------- ### Example Execution Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/host_map_test/README.md Demonstrates a full example of running the host map test, starting the server with 20 threads and the agent with specific block and sleep configurations. ```bash # Terminal 1: Monitor 20 threads BPFTIME_LOG_OUTPUT=console \ LD_PRELOAD=build/runtime/syscall-server/libbpftime-syscall-server.so \ example/gpu/host_map_test/host_map_test 20 # Terminal 2: Run with 10 threads/block, 2 blocks = 20 total threads BPFTIME_LOG_OUTPUT=console \ LD_PRELOAD=build/runtime/agent/libbpftime-agent.so \ example/gpu/host_map_test/vec_add 10 2 500 ``` -------------------------------- ### Run Syscall Example - Server (bpftime load) Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/minimal/README.md This command loads the syscall example using the `bpftime` tool, specifying the path to the example. ```bash sudo ~/.bpftime/bpftime load example/minimal/syscall ``` -------------------------------- ### Run Example: Start Target (No Preload) Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/threadscheduling_dynamic_hook/README.md Start the CUDA application without preloading any agents. This is the first step for dynamic attachment. ```bash example/gpu/threadscheduling_dynamic_hook/vec_add 4 64 ``` -------------------------------- ### Build the Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/bpf_features/tailcall_minimal/README.md Compile the eBPF example using make. ```bash make -j$(nproc) ``` -------------------------------- ### Run bpftime CLI Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Example of how to invoke the bpftime command-line interface after installation. This shows the basic usage and command structure. ```console $ bpftime Usage: bpftime [OPTIONS] ... ``` -------------------------------- ### Run Nginx with RLBox Sandbox Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/rlbox_plugin/README.md Navigate to the example directory, set environment variables for the RLBox plugin, and start Nginx. ```bash cd /path/to/bpftime/example/attach_implementation # Set the environment variables DYNAMIC_LOAD_LIB_PATH="$(pwd)/benchmark/rlbox_plugin/libfilter_rlbox.so" DYNAMIC_LOAD_URL_PREFIX="/aaaa" ./nginx_plugin_output/nginx -p $(pwd) -c benchmark/dynamic_load_module.conf ``` -------------------------------- ### Build Example Programs Source: https://github.com/eunomia-bpf/bpftime/blob/master/CLAUDE.md Compiles the example programs, such as the malloc example. This is a prerequisite for running examples. ```bash make -C example/malloc ``` -------------------------------- ### Run Example: Preload at Process Start (Client) Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/threadscheduling_dynamic_hook/README.md Run the CUDA application (client) with the bpftime agent preloaded. Specify the number of blocks and threads per block as arguments. ```bash BPFTIME_LOG_OUTPUT=console LD_PRELOAD=build/runtime/agent/libbpftime-agent.so \ example/gpu/threadscheduling_dynamic_hook/vec_add [num_blocks] [threads_per_block] ``` -------------------------------- ### Run Example: Preload at Process Start (Loader) Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/threadscheduling_dynamic_hook/README.md Launch the eBPF program (loader) by preloading the bpftime syscall server. This method is for the legacy approach. ```bash BPFTIME_LOG_OUTPUT=console LD_PRELOAD=build/runtime/syscall-server/libbpftime-syscall-server.so \ example/gpu/threadscheduling_dynamic_hook/threadscheduling ``` -------------------------------- ### Build Prerequisites for libbpftime Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/libbpftime_example/README.md This command installs the static libbpftime library to the ~/.bpftime directory, which is required for building the example program. ```shell cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=Release \ -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO -DBPFTIME_BUILD_STATIC_LIB=ON cmake --build build --config Release --target install ``` -------------------------------- ### Build the threadhist example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/llama-cpp-test/README.md Build the threadhist example from the bpftime root directory. Requires bpftime to be built with CUDA support and the CUDA toolkit installed. ```bash # From bpftime root directory make -C example/gpu/threadhist ``` -------------------------------- ### Build KernelRetsnoop Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/kernelretsnoop/README.md Build the kernel retsnoop example from the bpftime root directory. Ensure bpftime is built with CUDA support and the CUDA toolkit is installed. ```bash # From bpftime root directory make -C example/gpu/kernelretsnoop ``` -------------------------------- ### Run Syscall Example - Server (LD_PRELOAD) Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/minimal/README.md This command loads the syscall example by preloading the bpftime syscall server library. ```bash sudo LD_PRELOAD=build/runtime/syscall-server/libbpftime-syscall-server.so example/minimal/syscall ``` -------------------------------- ### Run Nginx with Wasm2c Sandbox Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/rlbox_plugin/README.md Navigate to the example directory, set environment variables for the Wasm2c plugin, and start Nginx. ```bash cd /path/to/bpftime/example/attach_implementation # Set the environment variables export DYNAMIC_LOAD_LIB_PATH="$(pwd)/benchmark/rlbox_plugin/libfilter_rlbox_wasm2c.so" export DYNAMIC_LOAD_URL_PREFIX="/aaaa" # Start Nginx with the dynamic load module ./nginx_plugin_output/nginx -p $(pwd) -c benchmark/dynamic_load_module.conf ``` -------------------------------- ### Run Example Programs Source: https://github.com/eunomia-bpf/bpftime/blob/master/benchmark/gpu/micro/README.md Execute real-world eBPF examples on the GPU. Ensure you are in the bpftime project root directory before running. ```bash cd /path/to/bpftime python3 benchmark/gpu/run_cuda_bench.py benchmark/gpu/micro/examples_vec_add_config.json ``` -------------------------------- ### Install bpftime CLI Tools and Libraries Source: https://github.com/eunomia-bpf/bpftime/blob/master/tools/README.md Installs all command-line interface tools and libraries for bpftime. Ensure the installation directory is added to your PATH. ```bash make install export PATH=$PATH:~/.bpftime ``` -------------------------------- ### Build CUDA Graph Example Application Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/cudagraph/README.md Build the CUDA graph example application after building bpftime. This command navigates to the example directory and uses make. ```bash # or: export PATH=$BPFTIME_CUDA_ROOT/bin:$PATH make -C example/gpu/cudagraph ``` -------------------------------- ### Build bpftime Project and Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/launchlate/README.md Build the main bpftime project with CUDA attachment enabled, followed by building the launchlate example. Ensure you navigate to the bpftime root directory first. ```bash # Navigate to the bpftime root directory cd bpftime # Build the main bpftime project first cmake -Bbuild -DBPFTIME_ENABLE_CUDA_ATTACH=1 -DBPFTIME_CUDA_ROOT=/usr/local/cuda . cmake --build build -j$(nproc) # Build the example make -C example/gpu/launchlate ``` -------------------------------- ### Load and Run opensnoop Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/usage.md Loads the opensnoop eBPF program and then starts a victim program to trace file operations. Observe the output showing PID, command, file descriptor, errors, and path. ```console $ sudo ~/.bpftime/bpftime load ./example/opensnoop/opensnoop [2023-10-09 04:36:33.891] [info] manager constructed [2023-10-09 04:36:33.892] [info] global_shm_open_type 0 for bpftime_maps_shm [2023-10-09 04:36:33][info][23999] Enabling helper groups ffi, kernel, shm_map by default PID COMM FD ERR PATH 72101 victim 3 0 test.txt 72101 victim 3 0 test.txt 72101 victim 3 0 test.txt 72101 victim 3 0 test.txt ``` ```console $ sudo ~/.bpftime/bpftime start -s example/opensnoop/victim [2023-10-09 04:38:16.196] [info] Entering new main.. [2023-10-09 04:38:16.197] [info] Using agent /root/.bpftime/libbpftime-agent.so [2023-10-09 04:38:16.198] [info] Page zero setted up.. [2023-10-09 04:38:16.198] [info] Rewriting executable segments.. [2023-10-09 04:38:19.260] [info] Loading dynamic library.. ... test.txt closed Opening test.txt test.txt opened, fd=3 Closing test.txt... ``` -------------------------------- ### Installation Source: https://github.com/eunomia-bpf/bpftime/blob/master/tools/cli/CMakeLists.txt Installs the bpftime-cli-cpp target to the ~/.bpftime directory for Release, Debug, and RelWithDebInfo configurations. ```cmake install(TARGETS bpftime-cli-cpp CONFIGURATIONS Release Debug RelWithDebInfo DESTINATION ~/.bpftime) ``` -------------------------------- ### Start Nginx Server Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/README.md Start the Nginx server using the provided configuration. Ensure you are in the correct directory. ```bash nginx_plugin_output/nginx -p $(pwd) -c ./nginx.conf ``` -------------------------------- ### Build and Install bpftime with Make Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Compiles and installs the bpftime runtime to `~/.bpftime`. The `JOBS` variable should be set to the number of available CPU cores for faster compilation. After installation, the `~/.bpftime` directory is added to the system's PATH. ```bash make release JOBS=$(nproc) # Build and install the runtime export PATH=$PATH:~/.bpftime ``` -------------------------------- ### Starting Passthrough Fuse for Benchmarking Source: https://github.com/eunomia-bpf/bpftime/blob/master/benchmark/fuse/bpf/README.md Activates a Python virtual environment and starts the passthrough.py script, likely to set up a FUSE filesystem for subsequent benchmarking. This is part of the 'no cache' setup. ```console source ~/OpenCopilot/venv/bin/activate python3 passthrough.py ~/linux ./data/ ``` -------------------------------- ### Run uprobe Example - Server Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/minimal/README.md This command demonstrates how to run the uprobe example as a server. It involves preloading a specific bpftime library. ```bash example/minimal# LD_PRELOAD=~/.bpftime/libbpftime-syscall-server.so ./uprobe ``` -------------------------------- ### Build bpftime and the CUDA Atomizer Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/atomizer/README.md Navigate to the bpftime root directory, build the main project with CUDA attachment enabled, and then build the specific atomizer example. ```bash cd bpftime cmake -Bbuild -DBPFTIME_ENABLE_CUDA_ATTACH=1 -DBPFTIME_CUDA_ROOT=/usr/local/cuda . cmake --build build -j$(nproc) make -C example/gpu/atomizer ``` -------------------------------- ### Run uprobe Example - Client Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/minimal/README.md This command demonstrates how to run the uprobe example as a client, likely interacting with a running server. ```bash example/minimal# LD_PRELOAD=~/.bpftime/libbpftime-agent.so ./victim ``` -------------------------------- ### Start BPF Program (Server) Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/host_map_test/README.md Starts the BPF program as a server. Requires bpftime syscall server library to be preloaded. Optionally specify the number of GPU threads to monitor. ```bash BPFTIME_LOG_OUTPUT=console \ LD_PRELOAD=build/runtime/syscall-server/libbpftime-syscall-server.so \ example/gpu/host_map_test/host_map_test [thread_count] ``` -------------------------------- ### Install bpftime to System Source: https://github.com/eunomia-bpf/bpftime/blob/master/CLAUDE.md Installs the built bpftime components to the system. This typically requires root privileges and should be done after a successful build. ```bash sudo cmake --install build ``` -------------------------------- ### Start Baseline Nginx Controller Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/README.md Starts the baseline controller for the C module. Ensure this is started before Nginx. ```bash cd /path/to/bpftime build/example/attach_implementation/benchmark/baseline_nginx_plugin/nginx_baseline_controller /aaaa ``` -------------------------------- ### Install WASI-SDK Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/wasm_plugin/README.md Installs the WASI-SDK to a specified directory. Ensure the target directory exists or adjust the command. ```bash # Install WASI-SDK to /opt/wasi-sdk make install-deps ``` ```bash wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz tar xf wasi-sdk-19.0-linux.tar.gz sudo mv wasi-sdk-19.0 /opt/wasi-sdk ``` -------------------------------- ### Build bpftime and mem_trace Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/mem_trace/README.md Builds the bpftime runtime and the mem_trace eBPF example. Requires nvcc for the CUDA victim program. ```bash # Build bpftime first (from the bpftime root directory) cd bpftime make release # Build the example make -C example/gpu/mem_trace ``` -------------------------------- ### Start the Target Application Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/bpf_features/tailcall_minimal/README.md Start the './victim' application, which will be probed by the eBPF program. ```bash bpftime start ./victim ``` -------------------------------- ### Install bpftrace Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/README.md Installs bpftrace using apt. This is a prerequisite for running bpftime with bpftrace. ```bash sudo apt install bpftrace ``` -------------------------------- ### Build eBPF Examples Source: https://github.com/eunomia-bpf/bpftime/blob/master/benchmark/gpu/micro/README.md Compile eBPF examples for GPU support. This is necessary if you encounter 'Custom probe not found' errors. ```bash cd /path/to/bpftime make -C example/gpu ``` -------------------------------- ### Install bpftimetool Executable Source: https://github.com/eunomia-bpf/bpftime/blob/master/tools/bpftimetool/CMakeLists.txt Installs the bpftimetool executable to the ~/.bpftime directory for Release, Debug, and RelWithDebInfo configurations. ```cmake install(TARGETS bpftimetool CONFIGURATIONS Release Debug RelWithDebInfo DESTINATION ~/.bpftime) ``` -------------------------------- ### Build and Install bpftime with CMake Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Configures and builds the bpftime project using cmake, installing the release version to `~/.bpftime`. The `SPDLOG_ACTIVE_LEVEL` can be adjusted to control log verbosity. After installation, the `~/.bpftime` directory is added to the system's PATH. ```bash cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=Release \ -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO cmake --build build --config Release --target install export PATH=$PATH:~/.bpftime ``` -------------------------------- ### Start Nginx with Dynamic Load Module Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/README.md Starts Nginx with the dynamic load module, configured via environment variables for the library path and URL prefix. ```bash cd /path/to/bpftime/example/attach_implementation DYNAMIC_LOAD_LIB_PATH="/home/yunwei37/bpftime/example/attach_implementation/benchmark/dynamic_load_plugin/dynamic_tests/libfilter_impl.so" DYNAMIC_LOAD_URL_PREFIX="/aaaa" nginx_plugin_output/nginx -p $(pwd) -c benchmark/dynamic_load_module.conf ``` -------------------------------- ### Start Nginx with bpftime Module Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/README.md Starts Nginx with the bpftime eBPF module. This module utilizes the eBPF controller. ```bash cd /path/to/bpftime/example/attach_implementation ./nginx_plugin_output/nginx -p $(pwd) -c nginx.conf ``` -------------------------------- ### Build and Load Uprobe Example with bpftime CLI Source: https://github.com/eunomia-bpf/bpftime/blob/master/README.md Builds the malloc eBPF program example and loads it using the bpftime CLI. Ensure the bpftime path is exported. ```bash make -C example/malloc # Build the eBPF program example export PATH=$PATH:~/.bpftime/ bpftime load ./example/malloc/malloc ``` -------------------------------- ### Build and Install Runtime in Release Mode (llvm jit) Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Builds and installs the bpftime runtime in release mode using the LLVM JIT. LTO is disabled. ```bash cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DBPFTIME_ENABLE_LTO=NO -DBPFTIME_LLVM_JIT=YES cmake --build build --config RelWithDebInfo --target install ``` -------------------------------- ### Install Daemon Executable Source: https://github.com/eunomia-bpf/bpftime/blob/master/daemon/CMakeLists.txt Installs the 'bpftime_daemon' executable to the '~/.bpftime' directory for Release, Debug, and RelWithDebInfo configurations. ```cmake install(TARGETS bpftime_daemon CONFIGURATIONS Release Debug RelWithDebInfo DESTINATION ~/.bpftime) ``` -------------------------------- ### Start bpftime Daemon Source: https://github.com/eunomia-bpf/bpftime/blob/master/daemon/README.md Starts the bpftime daemon with debug logging enabled. Ensure you have the necessary permissions (sudo) and the daemon is built. ```console sudo SPDLOG_LEVEL=Debug build/daemon/bpftime_daemon [2023-10-24 11:07:13.143] [info] Global shm constructed. shm_open_type 0 for bpftime_maps_shm ``` -------------------------------- ### Build and Load libbpf eBPF Program Source: https://github.com/eunomia-bpf/bpftime/blob/master/usage.md Build an eBPF program example using make and load it with the bpftime CLI. Ensure the example is built before loading. ```bash make -C example/malloc # Build the eBPF program example bpftime load ./example/malloc/malloc ``` -------------------------------- ### Build Thread Scheduling Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/threadscheduling/README.md Compile the thread scheduling eBPF example after building the main bpftime project with CUDA support. ```bash make -C example/gpu/threadscheduling ``` -------------------------------- ### Build and Install Runtime in Release Mode (ubpf jit) Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Builds and installs the bpftime runtime in release mode using the ubpf JIT. LTO is disabled. ```bash cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DBPFTIME_ENABLE_LTO=NO cmake --build build --config Release --target install ``` -------------------------------- ### Build and Install Runtime in Debug Mode (ubpf jit) Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Builds and installs the bpftime runtime in debug mode using the ubpf JIT. LTO is disabled. ```bash cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -DBPFTIME_ENABLE_LTO=NO cmake --build build --config Debug --target install ``` -------------------------------- ### Build the CUDA eBPF Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/rocm-counter/README.md Compile the specific CUDA eBPF counter example after building the main bpftime project. ```bash make -C example/gpu/rocm-counter ``` -------------------------------- ### Install libelf Development Package Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/launchlate/README.md Install the libelf development package on Debian/Ubuntu systems. This is required for the launchlate example to resolve CUDA symbols. ```bash sudo apt-get install libelf-dev ``` -------------------------------- ### Compile Example Program with g++ Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/libbpftime_example/README.md This command compiles the main.cpp example program using g++, linking against libbpftime and other necessary libraries. It is used when not employing llvm-jit. ```shell g++ -o example main.cpp -I../../runtime/include -I../../vm/compat/include/ -I../../third_party/spdlog/include -I../../vm/vm-core/include -L~/.bpftime -lbpftime -lboost_system -lrt -lbpf ``` -------------------------------- ### Install System Dependencies (Ubuntu) Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Installs essential packages required for building bpftime on Ubuntu systems. Ensure your package list is up-to-date before running. ```bash sudo apt-get update && sudo apt-get install \ libelf1 libelf-dev zlib1g-dev make cmake git libboost-all-dev \ binutils-dev libyaml-cpp-dev ca-certificates clang pkg-config llvm-dev ``` ```bash git submodule update --init --recursive ``` -------------------------------- ### Start Nginx with Baseline C Module Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/README.md Starts Nginx with the baseline C module. This module connects to the shared memory created by the controller. ```bash cd /path/to/bpftime/example/attach_implementation/ nginx_plugin_output/nginx -p $(pwd) -c benchmark/baseline_c_module.conf ``` -------------------------------- ### Build the CUDA eBPF Counter Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/cuda-counter/README.md Build the specific CUDA eBPF counter example after building the main bpftime project. ```bash make -C example/gpu/cuda-counter ``` -------------------------------- ### Run malloc Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/daemon/README.md Executes a malloc example. This demonstrates the daemon's ability to modify BPF and perf event loading and attachment, resulting in no output from the malloc function itself. ```console sudo example/malloc/malloc libbpf: loading object 'malloc_bpf' from buffer 11:08:11 11:08:12 11:08:13 ``` -------------------------------- ### Run Example: Dynamic Attach Probing Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/threadscheduling_dynamic_hook/README.md Start probing the target CUDA application dynamically after it has been running. This injects the bpftime agent into an existing process. ```bash sudo BPFTIME_LOG_OUTPUT=console ./build/tools/cli/bpftime trace --pidof vec_add --auto-refresh-ms 500 \ example/gpu/threadscheduling_dynamic_hook/threadscheduling ``` -------------------------------- ### Run GEMM eBPF Program on CUDA Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/directly_run_on_gpu/README.md Quick start for running the GEMM (Matrix Multiplication) eBPF program on CUDA. Example parameters for 64x64 matrices with specified grid and block sizes are provided. ```bash make -j8 build/tools/cli/bpftime load ./directly_run & # example: 64x64, grid=4x4, block=16x16 build/tools/bpftimetool/bpftimetool run-on-cuda cuda__gemm 1 4 4 1 16 16 1 ``` -------------------------------- ### Create VM with Specific Backend Source: https://github.com/eunomia-bpf/bpftime/blob/master/vm/README.md Instantiate a VM using either the high-performance 'llvm' backend or the lightweight 'ubpf' backend. ```c // Create VM with specific backend struct ebpf_vm *vm = ebpf_create("llvm"); // High performance struct ebpf_vm *vm = ebpf_create("ubpf"); // Lightweight ``` -------------------------------- ### PyTorch CUDA Tensor Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/pytorch-test/README.md A Python script demonstrating the creation of a CUDA tensor and performing a sort operation. This script requires PyTorch to be installed with CUDA support and should be run within an activated virtual environment. ```python import torch data = torch.randint(0, 1000, (10,), dtype=torch.int32, device='cuda') sorted_data = torch.sort(data) print(f"Original: {data[:10]}") print(f"Sorted: {sorted_data.values[:10]}") ``` -------------------------------- ### Conditional Installation of Targets Source: https://github.com/eunomia-bpf/bpftime/blob/master/CMakeLists.txt Installs Bpftime targets (executables and libraries) to a specified destination directory. The installation is conditional based on whether libbpf is enabled, affecting which targets are installed. ```cmake if(${BPFTIME_BUILD_WITH_LIBBPF}) install(TARGETS bpftime-agent bpftime_text_segment_transformer bpftime-syscall-server CONFIGURATIONS Release Debug RelWithDebInfo DESTINATION ${DEST_DIR}) else() install(TARGETS bpftime-agent bpftime-syscall-server CONFIGURATIONS Release Debug RelWithDebInfo DESTINATION ${DEST_DIR}) endif() ``` -------------------------------- ### Makefile Targets for Examples Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/libbpftime_example/README.md Lists the available targets in the Makefile for building and cleaning example programs, such as the shared memory example. ```shell Available targets: shm_example build shared memory example clean clean the build ``` -------------------------------- ### Define Installation Directory Source: https://github.com/eunomia-bpf/bpftime/blob/master/CMakeLists.txt Sets the destination directory for installation using the HOME environment variable. This allows users to customize where Bpftime components are installed. ```cmake set(DEST_DIR "$ENV{HOME}/.bpftime") ``` -------------------------------- ### Start Nginx Server Source: https://github.com/eunomia-bpf/bpftime/blob/master/benchmark/ssl-nginx/README.md Launch the Nginx server using a specified configuration file and path. This is a prerequisite for running the benchmark tests. ```shell nginx -c $(pwd)/nginx.conf -p $(pwd) ``` -------------------------------- ### Run Example: Preload with Custom Configuration Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/threadscheduling_dynamic_hook/README.md Execute the CUDA application with a custom configuration for thread blocks and threads per block using preload. ```bash # Run with 8 blocks and 128 threads per block LD_PRELOAD=build/runtime/agent/libbpftime-agent.so \ example/gpu/threadscheduling_dynamic_hook/vec_add 8 128 ``` -------------------------------- ### Launch the Sample CUDA Program Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/kernel_trace/README.md Runs the sample CUDA program (`vec_add`), preloading the bpftime agent to enable fatbin interception and PTX rewriting. ```bash BPFTIME_LOG_OUTPUT=console \ LD_PRELOAD=build/runtime/agent/libbpftime-agent.so \ example/gpu/kernel_trace/vec_add ``` -------------------------------- ### Build CUTLASS Demo Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/cutlass/README.md Builds the CUTLASS demo for the GPU attach example. Ensure bpftime is built with CUDA attach enabled. ```bash # from repo root make -C example/gpu/cutlass CUTLASS_DIR=.../cutlass ``` -------------------------------- ### NVBit Instrumentation Output Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/benchmark/gpu/README.md Example output from NVBit instrumentation, showing per-kernel timing and a summary. ```text NVBit: Minimal Vector Addition Instrumentation Tool ------------------------------------------------ NVBit: Kernel _Z9vectorAddPKfS0_Pf - Time: XXX.XXX us ... NVBit Instrumentation Summary: Total kernel calls: XXX Total execution time: XXX.XXX ms Average kernel time: XXX.XXX us ``` -------------------------------- ### Install bpftime-aot-cli Executable Source: https://github.com/eunomia-bpf/bpftime/blob/master/tools/aot/CMakeLists.txt Installs the bpftime-aot-cli target to the '~/.bpftime' directory for Release, Debug, and RelWithDebInfo configurations. ```cmake install(TARGETS bpftime-aot-cli CONFIGURATIONS Release Debug RelWithDebInfo DESTINATION ~/.bpftime) ``` -------------------------------- ### Build and Run Bpftime Unit Tests Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Enable unit testing by setting BPFTIME_ENABLE_UNIT_TESTING to YES. This example shows how to configure the build with LLVM JIT support and then build and run the bpftime_runtime_tests target. ```sh cmake -DCMAKE_PREFIX_PATH=/usr/include/llvm -DBPFTIME_LLVM_JIT=YES -DBPFTIME_ENABLE_UNIT_TESTING=YES -DCMAKE_BUILD_TYPE=Release -B build cmake --build build --config RelWithDebInfo --target bpftime_runtime_tests sudo ./build/runtime/unit-test/bpftime_runtime_tests ``` -------------------------------- ### Run Go server program Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/tracing/goroutine/README.md Start the Go server application that will be traced. This requires setting the bpftime agent's LD_PRELOAD path. ```console example/goroutine# LD_PRELOAD=../../build/runtime/agent/libbpftime-agent.so go-server-http/main Server started! ``` -------------------------------- ### Install SPDK Dependencies Source: https://github.com/eunomia-bpf/bpftime/wiki/Benchmark-of-SPDK Installs the necessary dependencies for SPDK. This script should be run from within the SPDK directory. ```sh cd spdk scripts/pkgdep.sh ``` -------------------------------- ### Create VM Instance Source: https://github.com/eunomia-bpf/bpftime/blob/master/vm/README.md Creates a VM instance. Specify the desired backend using the vm_name parameter. ```c // Create a VM instance with specified backend struct ebpf_vm *ebpf_create(const char *vm_name); ``` -------------------------------- ### Start bpftime agent Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/threadhist-gpu-kernel-shared-map/README.md Start the bpftime agent to run the vec_add program after loading the threadhist program. ```bash bpftime start ./vec_add ``` -------------------------------- ### Integrate bpftimetool with bpftime Runtime Source: https://github.com/eunomia-bpf/bpftime/blob/master/tools/bpftimetool/README.md Demonstrates the workflow for using bpftimetool with the bpftime runtime. This involves starting a target application with the bpftime syscall server, inspecting its state, and running benchmarks. ```bash # Terminal 1: Start target with bpftime LD_PRELOAD=~/.bpftime/libbpftime-syscall-server.so ./my_app ``` ```bash # Terminal 2: Inspect state bpftimetool export current_state.json ``` ```bash # Terminal 3: Run benchmarks bpftimetool run 4 test_data.bin repeat 100000 type JIT ``` -------------------------------- ### BPF Probe Output Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/benchmark/gpu/README.md Example output format for the BPF probe, displaying statistics per process. ```text PID XXX: kernel calls = N, total time = XXX ns, avg = XXX ns ``` -------------------------------- ### Install bpftime Patch for Redis Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/hotpatch/redis/README.md Command to install the bpftime patch for the Redis vulnerability using the bpftime-cli tool. ```console $ sudo build/tools/cli/bpftime-cli workloads/ebpf-patch-dev/poc4-redis/poc.json Successfully injected. ID: 1 ``` -------------------------------- ### Install RLBox Dependencies Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/rlbox_plugin/README.md Installs RLBox and its dependencies using the provided Makefile. Ensure you are in the plugin's directory. ```bash cd /path/to/bpftime/example/attach_implementation/benchmark/rlbox_plugin # Install RLBox and its dependencies make install-deps ``` -------------------------------- ### Start eBPF Controller Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/README.md Starts the eBPF controller for the bpftime module. This controller manages the eBPF filter logic. ```bash cd /path/to/bpftime/build ./example/attach_implementation/benchmark/ebpf_controller/nginx_benchmark_ebpf_controller /aaaa ``` -------------------------------- ### Example Usage with wget Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/tracing/sslsniff/README.md This command demonstrates running sslsniff by preloading the bpftime agent library and then using wget to download a webpage. ```sh sudo LD_PRELOAD=build/runtime/agent/libbpftime-agent.so wget https://www.google.com ``` -------------------------------- ### Compile Bpftime VM Only (Lightweight Build) Source: https://github.com/eunomia-bpf/bpftime/blob/master/installation.md Create a lightweight build that includes only the VM library and LLVM JIT, excluding the runtime and uprobe support. Use 'make build-vm' for a simple JIT or 'make build-llvm' for LLVM JIT. ```bash make build-vm # build the simple vm with a simple jit make build-llvm # build the vm with llvm jit ``` -------------------------------- ### Load and Run opensnoop Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/tracing/opensnoop_ring_buf/README.md Demonstrates how to load the opensnoop BPF program and then run it to trace file operations. The output shows PID, command, file descriptor, error, and path for open/close events. ```bash sudo ~/.bpftime/bpftime load ./example/opensnoop/opensnoop [2023-10-09 04:36:33.891] [info] manager constructed [2023-10-09 04:36:33.892] [info] global_shm_open_type 0 for bpftime_maps_shm [2023-10-09 04:36:33][info][23999] Enabling helper groups ffi, kernel, shm_map by default PID COMM FD ERR PATH 72101 victim 3 0 test.txt 72101 victim 3 0 test.txt 72101 victim 3 0 test.txt 72101 victim 3 0 test.txt ``` ```bash sudo ~/.bpftime/bpftime start -s example/opensnoop/victim [2023-10-09 04:38:16.196] [info] Entering new main.. [2023-10-09 04:38:16.197] [info] Using agent /root/.bpftime/libbpftime-agent.so [2023-10-09 04:38:16.198] [info] Page zero setted up.. [2023-10-09 04:38:16.198] [info] Rewriting executable segments.. [2023-10-09 04:38:19.260] [info] Loading dynamic library.. ... test.txt closed Opening test.txt test.txt opened, fd=3 Closing test.txt... ``` -------------------------------- ### Install bpftime-aot Tool Source: https://github.com/eunomia-bpf/bpftime/blob/master/tools/aot/README.md Shows how to access the bpftime-aot tool after building bpftime. It can be run directly or added to the system's PATH. ```bash ~/.bpftime/bpftime-aot # Or add to PATH export PATH=$PATH:~/.bpftime/ ``` -------------------------------- ### CUDA Benchmark Output Example Source: https://github.com/eunomia-bpf/bpftime/blob/master/benchmark/gpu/README.md Example output format for the CUDA benchmark, showing total and average kernel times. ```text Running benchmark with N iterations... Benchmark results: Total time: XXX ms Average kernel time: XXX ms Validation check: C[0] = 0, C[1] = 3 ``` -------------------------------- ### Example KernelRetsnoop Output Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/kernelretsnoop/README.md This is an example of the output generated by the kernel retsnoop tool, showing thread information and timestamps for collected events. ```text Thread (0, 0, 0) timestamp: 1749147474550023136 Thread (1, 0, 0) timestamp: 1749147474550023140 Thread (2, 0, 0) timestamp: 1749147474550023145 Thread (3, 0, 0) timestamp: 1749147474550023150 Thread (4, 0, 0) timestamp: 1749147474550023155 Total events collected: 5 ``` -------------------------------- ### Run NGINX with WebAssembly Filter Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/attach_implementation/benchmark/wasm_plugin/README.md Starts NGINX with the dynamic load module, setting necessary environment variables for the WebAssembly filter's path and URL prefix. ```bash cd /path/to/bpftime/example/attach_implementation # Start NGINX with the dynamic load module export DYNAMIC_LOAD_LIB_PATH="$(pwd)/benchmark/wasm_plugin/libwasm_filter.so" export DYNAMIC_LOAD_URL_PREFIX="/aaaa" export WASM_MODULE_PATH="$(pwd)/benchmark/wasm_plugin/url_filter.wasm" ./nginx_plugin_output/nginx -p $(pwd) -c benchmark/dynamic_load_module.conf ``` -------------------------------- ### Run Queue Demo Manually (Terminal 1) Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/bpf_features/queue_demo/QUEUE_TEST_README.md Starts the bpftime Server which monitors events and loads the eBPF program. This command should be run in the first terminal. ```bash LD_PRELOAD=../../build/runtime/syscall-server/libbpftime-syscall-server.so ./uprobe_queue ``` -------------------------------- ### Start the CUDA Kernel Tracer Source: https://github.com/eunomia-bpf/bpftime/blob/master/example/gpu/kernel_trace/README.md Launches the kernel trace application, preloading the bpftime syscall server. Environment variables control map size, GPU thread count, and logging. ```bash BPFTIME_MAP_GPU_THREAD_COUNT=8192 \ BPFTIME_SHM_MEMORY_MB=256 \ BPFTIME_LOG_OUTPUT=console \ LD_PRELOAD=build/runtime/syscall-server/libbpftime-syscall-server.so \ example/gpu/kernel_trace/kernel_trace ``` -------------------------------- ### Install Benchmark Dependencies Source: https://github.com/eunomia-bpf/bpftime/blob/master/benchmark/README.md Installs necessary Python dependencies for running benchmark experiments. Ensure you are in the root directory of the bpftime project. ```sh cd /path/to/bpftime pip install -r benchmark/requirements.txt ```